ObjFW  Check-in [3b440aa16a]

Overview
Comment:OFPropertyListTests: Use OTAssertThrowsSpecific
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | objfwtest
Files: files | file ages | folders
SHA3-256: 3b440aa16a4ed5717251a07c7d018e195eff1fc4554ee40d3d53e8c9dd76e255
User & Date: js on 2024-02-11 12:17:20
Other Links: branch diff | manifest | tags
Context
2024-02-11
12:24
Migrate OFPluginTests to ObjFWTest check-in: 540160ff20 user: js tags: objfwtest
12:17
OFPropertyListTests: Use OTAssertThrowsSpecific check-in: 3b440aa16a user: js tags: objfwtest
12:06
Merge trunk into branch "objfwtest" check-in: 4b635088b6 user: js tags: objfwtest
Changes

Modified new_tests/OFPropertyListTests.m from [7815182aa6] to [2c2f0ce2a0].

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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
	    @"array", array,
	    @"foo", @"bar",
	    nil]));
}

- (void)testDetectUnsupportedVersion
{
	bool caught = false;
	@try {
		[[PLIST(@"<string/>")
		    stringByReplacingOccurrencesOfString: @"1.0"
					      withString: @"1.1"]
		objectByParsingPropertyList];
	} @catch (OFUnsupportedVersionException *e) {
		caught = true;
	}
	OTAssertTrue(caught);
}

- (void)testDetectInvalidFormat
{
	bool caught;

	caught = false;
	@try {
		[PLIST(@"<string x='b'/>") objectByParsingPropertyList];
	} @catch (OFInvalidFormatException *e) {
		caught = true;
	}
	OTAssertTrue(caught);

	caught = false;
	@try {
		[PLIST(@"<string xmlns='foo'/>") objectByParsingPropertyList];
	} @catch (OFInvalidFormatException *e) {
		caught = true;
	}
	OTAssertTrue(caught);

	caught = false;
	@try {
		[PLIST(@"<dict count='0'/>") objectByParsingPropertyList];
	} @catch (OFInvalidFormatException *e) {
		caught = true;
	}
	OTAssertTrue(caught);

	caught = false;
	@try {
		[PLIST(@"<dict><key/><string/><key/></dict>")
		    objectByParsingPropertyList];
	} @catch (OFInvalidFormatException *e) {
		caught = true;
	}
	OTAssertTrue(caught);

	caught = false;
	@try {
		[PLIST(@"<dict><key x='x'/><string/></dict>")
		    objectByParsingPropertyList];
	} @catch (OFInvalidFormatException *e) {
		caught = true;
	}
	OTAssertTrue(caught);
}
@end







|
<
|
|
|
|
|
<
<
<




<
|
<
<
|
|
<
|
|
<
<
<
|
|
<
|
|
<
<
<
|
|
<
|
|
<
<
<
|
|
|
<
|
|
<
<
<
|
|
|
<
|
<
<

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
	    @"array", array,
	    @"foo", @"bar",
	    nil]));
}

- (void)testDetectUnsupportedVersion
{
	OTAssertThrowsSpecific(

	    [[PLIST(@"<string/>")
	    stringByReplacingOccurrencesOfString: @"1.0"
				      withString: @"1.1"]
	    objectByParsingPropertyList],
	    OFUnsupportedVersionException);



}

- (void)testDetectInvalidFormat
{

	OTAssertThrowsSpecific(


	    [PLIST(@"<string x='b'/>") objectByParsingPropertyList],
	    OFInvalidFormatException);


	OTAssertThrowsSpecific(



	    [PLIST(@"<string xmlns='foo'/>") objectByParsingPropertyList],
	    OFInvalidFormatException);


	OTAssertThrowsSpecific(



	    [PLIST(@"<dict count='0'/>") objectByParsingPropertyList],
	    OFInvalidFormatException);


	OTAssertThrowsSpecific(



	    [PLIST(@"<dict><key/><string/><key/></dict>")
	    objectByParsingPropertyList],
	    OFInvalidFormatException);


	OTAssertThrowsSpecific(



	    [PLIST(@"<dict><key x='x'/><string/></dict>")
	    objectByParsingPropertyList],
	    OFInvalidFormatException);

}


@end