ObjFW  Check-in [34cf1fb8c2]

Overview
Comment:Clean up OFINIFileTests.m
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 34cf1fb8c2824b64e2c67e1dca78d8725aa55abb97aec6c0471952c4aecbcfb9
User & Date: js on 2014-06-13 16:41:41
Other Links: manifest | tags
Context
2014-06-14
09:44
OFINIFile: Add support for different encodings check-in: 44de69ef31 user: js tags: trunk
2014-06-13
16:41
Clean up OFINIFileTests.m check-in: 34cf1fb8c2 user: js tags: trunk
2014-06-12
13:43
OFINIFile: Add support for quoted keys / values check-in: 12c5b7ee91 user: js tags: trunk
Changes

Modified tests/OFINIFileTests.m from [556f5814fc] to [b708218fa8].

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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
	    @";comment" NL
	    @"new=new" NL
	    NL
	    @"[foobar]" NL
	    @";foobarcomment" NL
	    @"qux=\" asd\"" NL
	    @"quxquxqux=\"hello\\\"world\"" NL
	    @"qux2=\"\\f\"" NL

	    NL
	    @"[types]" NL
	    @"integer=16" NL
	    @"bool=false" NL
	    @"float=0.25" NL
	    @"double=0.75" NL;
	OFINIFile *file;
	OFINICategory *category;

	TEST(@"+[fileWithPath:]",
	    (file = [OFINIFile fileWithPath: @"testfile.ini"]))




	TEST(@"-[categoryForName:]",
	    (category = [file categoryForName: @"tests"]))

	module = @"OFINICategory";

	TEST(@"-[stringForKey:]",
	    [[category stringForKey: @"foo"] isEqual: @"bar"] &&
	    (category = [file categoryForName: @"foobar"]) &&
	    [[category stringForKey: @"quxquxqux"] isEqual: @"hello\"world"])

	category = [file categoryForName: @"tests"];

	TEST(@"-[setString:forKey:]",
	    R([category setString: @"baz"
			   forKey: @"foo"]) &&
	    R([category setString: @"new"
			   forKey: @"new"]))

	category = [file categoryForName: @"types"];

	TEST(@"-[integerForKey:defaultValue:]",
	    [category integerForKey: @"integer"
		       defaultValue: 2] == 0x20)

	TEST(@"-[setInteger:forKey:]", R([category setInteger: 0x10
						       forKey: @"integer"]))

	TEST(@"-[boolForKey:defaultValue:]",
	    [category boolForKey: @"bool"
		    defaultValue: false] == true)

	TEST(@"-[setBool:forKey:]", R([category setBool: false
						 forKey: @"bool"]))

	TEST(@"-[floatForKey:defaultValue:]",
	    [category floatForKey: @"float"
		     defaultValue: 1] == 0.5f)

	TEST(@"-[setFloat:forKey:]", R([category setFloat: 0.25f
						   forKey: @"float"]))

	TEST(@"-[doubleForKey:defaultValue:]",
	    [category doubleForKey: @"double"
		      defaultValue: 3] == 0.25)

	TEST(@"-[setDouble:forKey:]", R([category setDouble: 0.75
						     forKey: @"double"]))

	category = [file categoryForName: @"foobar"];

	TEST(@"-[removeValueForKey:]",
	    R([category 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"]







|
>







|




>
>
>

|




|
<
|

<
<

|
|
|
|
|
|


|
|

|
|


|
|

|
|


|
|

|
|


|
|

|
|

<
<

|







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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110


111
112
113
114
115
116
117
118
119
	    @";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"
			 forKey: @"qux3"]))

	TEST(@"-[integerForKey:defaultValue:]",
	    [types integerForKey: @"integer"
		    defaultValue: 2] == 0x20)

	TEST(@"-[setInteger:forKey:]", R([types setInteger: 0x10
						    forKey: @"integer"]))

	TEST(@"-[boolForKey:defaultValue:]",
	    [types boolForKey: @"bool"
		 defaultValue: false] == true)

	TEST(@"-[setBool:forKey:]", R([types setBool: false
					      forKey: @"bool"]))

	TEST(@"-[floatForKey:defaultValue:]",
	    [types floatForKey: @"float"
		  defaultValue: 1] == 0.5f)

	TEST(@"-[setFloat:forKey:]", R([types setFloat: 0.25f
						forKey: @"float"]))

	TEST(@"-[doubleForKey:defaultValue:]",
	    [types doubleForKey: @"double"
		   defaultValue: 3] == 0.25)

	TEST(@"-[setDouble:forKey:]", R([types setDouble: 0.75
						  forKey: @"double"]))



	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"]

Modified tests/testfile.ini from [cf73f59c64] to [2addf8918f].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
[tests]
foo = bar
foobar=baz
;comment

[foobar]
;foobarcomment
qux=" asd"
"quxqux " = asd
quxquxqux="hello\"world"
qux2="\f"

[types]
integer = 0x20
bool = true
float = 0.5
double = 0.25










|






1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
[tests]
foo = bar
foobar=baz
;comment

[foobar]
;foobarcomment
qux=" asd"
"quxqux " = asd
quxquxqux="hello\"world"
qux2="a\f"

[types]
integer = 0x20
bool = true
float = 0.5
double = 0.25