@@ -15,11 +15,11 @@ #include "config.h" #import "TestsAppDelegate.h" -static OFString *module = @"OFINIFile"; +static OFString *module; @implementation TestsAppDelegate (OFINIFileTests) - (void)INIFileTests { void *pool = objc_autoreleasePoolPush(); @@ -47,14 +47,16 @@ OFINICategory *tests, *foobar, *types; OFArray *array; #ifndef OF_NINTENDO_DS OFString *writePath; #endif + + module = @"OFINIFile"; TEST(@"+[fileWithPath:encoding:]", (file = [OFINIFile fileWithPath: @"testfile.ini" - encoding: OF_STRING_ENCODING_CODEPAGE_437])) + encoding: OFStringEncodingCodepage437])) tests = [file categoryForName: @"tests"]; foobar = [file categoryForName: @"foobar"]; types = [file categoryForName: @"types"]; TEST(@"-[categoryForName:]", @@ -65,54 +67,46 @@ TEST(@"-[stringForKey:]", [[tests stringForKey: @"foo"] isEqual: @"bar"] && [[foobar stringForKey: @"quxquxqux"] isEqual: @"hello\"wörld"]) TEST(@"-[setString:forKey:]", - R([tests setString: @"baz" - forKey: @"foo"]) && - R([tests setString: @"new" - forKey: @"new"]) && - R([foobar setString: @"a\fb" - forKey: @"qux3"])) - - TEST(@"-[integerForKey:defaultValue:]", - [types integerForKey: @"integer" - defaultValue: 2] == 0x20) - - TEST(@"-[setInteger:forKey:]", R([types setInteger: 0x10 - forKey: @"integer"])) + R([tests setString: @"baz" forKey: @"foo"]) && + R([tests setString: @"new" forKey: @"new"]) && + R([foobar setString: @"a\fb" forKey: @"qux3"])) + + TEST(@"-[longLongForKey:defaultValue:]", + [types longLongForKey: @"integer" defaultValue: 2] == 0x20) + + TEST(@"-[setLongLong:forKey:]", + R([types setLongLong: 0x10 forKey: @"integer"])) TEST(@"-[boolForKey:defaultValue:]", - [types boolForKey: @"bool" - defaultValue: false] == true) + [types boolForKey: @"bool" defaultValue: false] == true) - TEST(@"-[setBool:forKey:]", R([types setBool: false - forKey: @"bool"])) + TEST(@"-[setBool:forKey:]", R([types setBool: false forKey: @"bool"])) TEST(@"-[floatForKey:defaultValue:]", - [types floatForKey: @"float" - defaultValue: 1] == 0.5f) + [types floatForKey: @"float" defaultValue: 1] == 0.5f) - TEST(@"-[setFloat:forKey:]", R([types setFloat: 0.25f - forKey: @"float"])) + TEST(@"-[setFloat:forKey:]", + R([types setFloat: 0.25f forKey: @"float"])) TEST(@"-[doubleForKey:defaultValue:]", - [types doubleForKey: @"double" - defaultValue: 3] == 0.25) + [types doubleForKey: @"double" defaultValue: 3] == 0.25) - TEST(@"-[setDouble:forKey:]", R([types setDouble: 0.75 - forKey: @"double"])) + TEST(@"-[setDouble:forKey:]", + R([types setDouble: 0.75 forKey: @"double"])) array = [OFArray arrayWithObjects: @"1", @"2", nil]; - TEST(@"-[arrayForKey:]", - [[types arrayForKey: @"array1"] isEqual: array] && - [[types arrayForKey: @"array2"] isEqual: array] && - [[types arrayForKey: @"array3"] isEqual: [OFArray array]]) + TEST(@"-[stringArrayForKey:]", + [[types stringArrayForKey: @"array1"] isEqual: array] && + [[types stringArrayForKey: @"array2"] isEqual: array] && + [[types stringArrayForKey: @"array3"] isEqual: [OFArray array]]) array = [OFArray arrayWithObjects: @"foo", @"bar", nil]; - TEST(@"-[setArray:forKey:]", R([types setArray: array - forKey: @"array1"])) + TEST(@"-[setStringArray:forKey:]", + R([types setStringArray: array forKey: @"array1"])) TEST(@"-[removeValueForKey:]", R([foobar removeValueForKey: @"quxqux "]) && R([types removeValueForKey: @"array2"])) @@ -127,18 +121,18 @@ [[OFApplication environment] objectForKey: @"HOME"], @"tmp", @"tmpfile.ini", nil]]; # endif TEST(@"-[writeToFile:encoding:]", R([file writeToFile: writePath - encoding: OF_STRING_ENCODING_CODEPAGE_437]) && + encoding: OFStringEncodingCodepage437]) && [[OFString stringWithContentsOfFile: writePath - encoding: OF_STRING_ENCODING_CODEPAGE_437] + encoding: OFStringEncodingCodepage437] isEqual: output]) [[OFFileManager defaultManager] removeItemAtPath: writePath]; #else (void)output; #endif objc_autoreleasePoolPop(pool); } @end