Differences From Artifact [cd6a5cb346]:
- File
tests/OFXMLParserTests.m
— part of check-in
[dc0c6c34ab]
at
2019-02-17 22:44:23
on branch trunk
— tests: Only import ObjFW.h
This prevents forgetting to add an import to ObjFW.h, as the tests would
then not compile. (user: js, size: 11772) [annotate] [blame] [check-ins using]
To Artifact [3b6a87e478]:
- File tests/OFXMLParserTests.m — part of check-in [b045cbb9c7] at 2019-03-25 00:21:30 on branch trunk — tests: Use dot syntax (user: js, size: 11745) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
55 56 57 58 59 60 61 | break; case 2: TEST(msg, type == PROCESSING_INSTRUCTIONS && [string isEqual: @"p?i"]) break; case 3: TEST(msg, type == TAG_START && [name isEqual: @"root"] && | | | | | | | | | 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 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 | break; case 2: TEST(msg, type == PROCESSING_INSTRUCTIONS && [string isEqual: @"p?i"]) break; case 3: TEST(msg, type == TAG_START && [name isEqual: @"root"] && prefix == nil && ns == nil && attrs.count == 0) break; case 4: TEST(msg, type == STRING && [string isEqual: @"\n\n "]) break; case 5: TEST(msg, type == CDATA && [string isEqual: @"f<]]]oo]"] && parser.lineNumber == 3) break; case 6: TEST(msg, type == TAG_START && [name isEqual: @"bar"] && prefix == nil && ns == nil && attrs == nil) break; case 7: TEST(msg, type == TAG_END && [name isEqual: @"bar"] && prefix == nil && ns == nil && attrs == nil) break; case 8: TEST(msg, type == STRING && [string isEqual: @"\n "]) break; case 9: TEST(msg, type == TAG_START && [name isEqual: @"foobar"] && prefix == nil && [ns isEqual: @"urn:objfw:test:foobar"] && attrs.count == 1 && /* xmlns attr */ [[[attrs objectAtIndex: 0] name] isEqual: @"xmlns"] && [[attrs objectAtIndex: 0] namespace] == nil && [[[attrs objectAtIndex: 0] stringValue] isEqual: @"urn:objfw:test:foobar"]) break; case 10: TEST(msg, type == STRING && [string isEqual: @"\n "]) break; case 11: TEST(msg, type == TAG_START && [name isEqual: @"qux"] && prefix == nil && [ns isEqual: @"urn:objfw:test:foobar"] && attrs.count == 1 && /* xmlns:foo attr */ [[[attrs objectAtIndex: 0] name] isEqual: @"foo"] && [[[attrs objectAtIndex: 0] namespace] isEqual: @"http://www.w3.org/2000/xmlns/"] && [[[attrs objectAtIndex: 0] stringValue] isEqual: @"urn:objfw:test:foo"]) break; case 12: TEST(msg, type == STRING && [string isEqual: @"\n "]) break; case 13: TEST(msg, type == TAG_START && [name isEqual: @"bla"] && [prefix isEqual: @"foo"] && [ns isEqual: @"urn:objfw:test:foo"] && attrs.count == 2 && /* foo:bla attr */ [[[attrs objectAtIndex: 0] name] isEqual: @"bla"] && [[[attrs objectAtIndex: 0] namespace] isEqual: @"urn:objfw:test:foo"] && [[[attrs objectAtIndex: 0] stringValue] isEqual: @"bla"] && /* blafoo attr */ [[[attrs objectAtIndex: 1] name] isEqual: @"blafoo"] && [[attrs objectAtIndex: 1] namespace] == nil && [[[attrs objectAtIndex: 1] stringValue] isEqual: @"foo"]) break; case 14: TEST(msg, type == STRING && [string isEqual: @"\n "]) break; case 15: TEST(msg, type == TAG_START && [name isEqual: @"blup"] && prefix == nil && [ns isEqual: @"urn:objfw:test:foobar"] && attrs.count == 2 && /* foo:qux attr */ [[[attrs objectAtIndex: 0] name] isEqual: @"qux"] && [[[attrs objectAtIndex: 0] namespace] isEqual: @"urn:objfw:test:foo"] && [[[attrs objectAtIndex: 0] stringValue] isEqual: @"asd"] && /* quxqux attr */ [[[attrs objectAtIndex: 1] name] isEqual: @"quxqux"] && [[attrs objectAtIndex: 1] namespace] == nil && [[[attrs objectAtIndex: 1] stringValue] isEqual: @"test"]) break; case 16: TEST(msg, type == TAG_END && [name isEqual: @"blup"] && prefix == nil && [ns isEqual: @"urn:objfw:test:foobar"]) break; case 17: TEST(msg, type == STRING && [string isEqual: @"\n "]) break; case 18: TEST(msg, type == TAG_START && [name isEqual: @"bla"] && [prefix isEqual: @"bla"] && [ns isEqual: @"urn:objfw:test:bla"] && attrs.count == 3 && /* xmlns:bla attr */ [[[attrs objectAtIndex: 0] name] isEqual: @"bla"] && [[[attrs objectAtIndex: 0] namespace] isEqual: @"http://www.w3.org/2000/xmlns/"] && [[[attrs objectAtIndex: 0] stringValue] isEqual: @"urn:objfw:test:bla"] && /* qux attr */ |
︙ | ︙ | |||
172 173 174 175 176 177 178 | break; case 20: TEST(msg, type == STRING && [string isEqual: @"\n "]) break; case 21: TEST(msg, type == TAG_START && [name isEqual: @"abc"] && prefix == nil && [ns isEqual: @"urn:objfw:test:abc"] && | | | 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 | break; case 20: TEST(msg, type == STRING && [string isEqual: @"\n "]) break; case 21: TEST(msg, type == TAG_START && [name isEqual: @"abc"] && prefix == nil && [ns isEqual: @"urn:objfw:test:abc"] && attrs.count == 3 && /* xmlns attr */ [[[attrs objectAtIndex: 0] name] isEqual: @"xmlns"] && [[attrs objectAtIndex: 0] namespace] == nil && [[[attrs objectAtIndex: 0] stringValue] isEqual: @"urn:objfw:test:abc"] && /* abc attr */ [[[attrs objectAtIndex: 1] name] isEqual: @"abc"] && |
︙ | ︙ | |||
339 340 341 342 343 344 345 | " </foobar>\n" "</root>"; OFXMLParser *parser; size_t j, len; TEST(@"+[parser]", (parser = [OFXMLParser parser])) | | | | | | 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 | " </foobar>\n" "</root>"; OFXMLParser *parser; size_t j, len; TEST(@"+[parser]", (parser = [OFXMLParser parser])) TEST(@"-[setDelegate:]", (parser.delegate = self)) /* Simulate a stream where we only get chunks */ len = strlen(str); for (j = 0; j < len; j+= 2) { if (parser.hasFinishedParsing) abort(); if (j + 2 > len) [parser parseBuffer: str + j length: 1]; else [parser parseBuffer: str + j length: 2]; } TEST(@"Checking if everything was parsed", i == 32 && parser.lineNumber == 18) TEST(@"-[hasFinishedParsing]", parser.hasFinishedParsing) TEST(@"Parsing whitespaces after the document", R([parser parseString: @" \t\r\n "])) TEST(@"Parsing comments after the document", R([parser parseString: @" \t<!-- foo -->\r<!--bar-->\n "])) |
︙ | ︙ |