41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
@"foobar=baz" NL
@";comment" NL
@"new=new" NL
NL
@"[foobar]" NL
@";foobarcomment" NL
@"qux=\" asd\"" NL
@"quxquxqux=\"hello\\\"world\"" NL
@"qux2=\"a\\f\"" NL
@"qux3=a\fb" NL
NL
@"[types]" NL
@"integer=16" NL
@"bool=false" NL
@"float=0.25" NL
@"double=0.75" NL;
OFINIFile *file;
OFINICategory *tests, *foobar, *types;
TEST(@"+[fileWithPath:]",
(file = [OFINIFile fileWithPath: @"testfile.ini"]))
tests = [file categoryForName: @"tests"];
foobar = [file categoryForName: @"foobar"];
types = [file categoryForName: @"types"];
TEST(@"-[categoryForName:]",
tests != nil && foobar != nil && types != nil)
module = @"OFINICategory";
TEST(@"-[stringForKey:]",
[[tests stringForKey: @"foo"] isEqual: @"bar"] &&
[[foobar stringForKey: @"quxquxqux"] isEqual: @"hello\"world"])
TEST(@"-[setString:forKey:]",
R([tests setString: @"baz"
forKey: @"foo"]) &&
R([tests setString: @"new"
forKey: @"new"]) &&
R([foobar setString: @"a\fb"
|
|
|
|
>
|
|
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
@"foobar=baz" NL
@";comment" NL
@"new=new" NL
NL
@"[foobar]" NL
@";foobarcomment" NL
@"qux=\" asd\"" NL
@"quxquxqux=\"hello\\\"wörld\"" NL
@"qux2=\"a\\f\"" NL
@"qux3=a\fb" NL
NL
@"[types]" NL
@"integer=16" NL
@"bool=false" NL
@"float=0.25" NL
@"double=0.75" NL;
OFINIFile *file;
OFINICategory *tests, *foobar, *types;
TEST(@"+[fileWithPath:encoding:]",
(file = [OFINIFile fileWithPath: @"testfile.ini"
encoding: OF_STRING_ENCODING_CODEPAGE_437]))
tests = [file categoryForName: @"tests"];
foobar = [file categoryForName: @"foobar"];
types = [file categoryForName: @"types"];
TEST(@"-[categoryForName:]",
tests != nil && foobar != nil && types != nil)
module = @"OFINICategory";
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"
|
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
|
TEST(@"-[removeValueForKey:]",
R([foobar removeValueForKey: @"quxqux "]))
module = @"OFINIFile";
/* FIXME: Find a way to write files on Nintendo DS */
#ifndef OF_NINTENDO_DS
TEST(@"-[writeToFile:]", R([file writeToFile: @"tmpfile.ini"]) &&
[[OFString stringWithContentsOfFile: @"tmpfile.ini"]
isEqual: output])
[OFFile removeItemAtPath: @"tmpfile.ini"];
#else
(void)output;
#endif
[pool drain];
}
@end
|
>
|
>
>
|
>
|
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
|
TEST(@"-[removeValueForKey:]",
R([foobar removeValueForKey: @"quxqux "]))
module = @"OFINIFile";
/* FIXME: Find a way to write files on Nintendo DS */
#ifndef OF_NINTENDO_DS
TEST(@"-[writeToFile:encoding:]",
R([file writeToFile: @"tmpfile.ini"
encoding: OF_STRING_ENCODING_CODEPAGE_437]) &&
[[OFString
stringWithContentsOfFile: @"tmpfile.ini"
encoding: OF_STRING_ENCODING_CODEPAGE_437]
isEqual: output])
[OFFile removeItemAtPath: @"tmpfile.ini"];
#else
(void)output;
#endif
[pool drain];
}
@end
|