forked from ZaBlanc/RaptureXML
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ErrorTests.m
62 lines (46 loc) · 1.4 KB
/
ErrorTests.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
//
// ErrorTests.m
// RaptureXML
//
// Created by John Blanco on 9/24/11.
// Copyright (c) 2011 Rapture In Venice. All rights reserved.
//
#import "RXMLElement.h"
@interface ErrorTests : SenTestCase {
NSString *simplifiedXML_;
NSString *badXML_;
}
@end
@implementation ErrorTests
- (void)setUp {
simplifiedXML_ = @"\
<shapes>\
<square>Square</square>\
<triangle>Triangle</triangle>\
<circle>Circle</circle>\
</shapes>";
badXML_ = @"</xml";
}
- (void)testBadXML {
RXMLElement *rxml = [RXMLElement elementFromXMLString:badXML_ encoding:NSUTF8StringEncoding];
STAssertFalse([rxml isValid], nil);
}
- (void)testMissingTag {
RXMLElement *rxml = [RXMLElement elementFromXMLString:simplifiedXML_ encoding:NSUTF8StringEncoding];
RXMLElement *hexagon = [rxml child:@"hexagon"];
STAssertNil(hexagon, nil);
}
- (void)testMissingTagIteration {
RXMLElement *rxml = [RXMLElement elementFromXMLString:simplifiedXML_ encoding:NSUTF8StringEncoding];
__block NSInteger i = 0;
[rxml iterate:@"hexagon" usingBlock:^(RXMLElement *e) {
i++;
}];
STAssertEquals(i, 0, nil);
}
- (void)testMissingAttribute {
RXMLElement *rxml = [RXMLElement elementFromXMLString:simplifiedXML_ encoding:NSUTF8StringEncoding];
NSString *missingName = [rxml attribute:@"name"];
STAssertNil(missingName, nil);
}
@end