/
HTMLPurifier_AttrDef_EnumTest.m
75 lines (59 loc) · 1.88 KB
/
HTMLPurifier_AttrDef_EnumTest.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
63
64
65
66
67
68
69
70
71
72
73
74
75
//
// HTMLPurifier_AttrDef_EnumTest.m
// HTMLPurifier
//
// Created by Lukas Neumann on 22.01.14.
#import <XCTest/XCTest.h>
#import "HTMLPurifier_AttrDefHarness.h"
#import "HTMLPurifier_AttrDef_Enum.h"
@interface HTMLPurifier_AttrDef_EnumTest : HTMLPurifier_AttrDefHarness
{
HTMLPurifier_AttrDef_Enum* def;
}
@end
@implementation HTMLPurifier_AttrDef_EnumTest
- (void)setUp
{
[super setUp];
}
- (void)tearDown
{
// Put teardown code here. This method is called after the invocation of each test method in the class.
[super tearDown];
}
- (void) assertDef:(NSString*) string expect:(NSObject*)expect
{
// expect can be a string or bool
if ([expect isEqual:@YES])
expect = string;
NSString* result = [def validateWithString:string config:[super config] context:[super context]];
XCTAssertEqualObjects(expect, result, @"");
}
-(void) testCaseInsensitive
{
def = [[HTMLPurifier_AttrDef_Enum alloc] initWithValidValues:@[@"one",@"two"]];
[self assertDef:@"one" expect:@YES];
[self assertDef:@"ONE" expect:@"one"];
}
-(void) testCaseSensitive
{
def = [[HTMLPurifier_AttrDef_Enum alloc] initWithValidValues:@[@"one",@"two"] caseSensitive:YES];
[self assertDef:@"one" expect:@YES];
[self assertDef:@"ONE" expect:nil];
}
-(void) testFixing
{
def = [[HTMLPurifier_AttrDef_Enum alloc] initWithValidValues:@[@"one"]];
[self assertDef:@" one " expect:@"one"];
}
-(void) test_make
{
HTMLPurifier_AttrDef_Enum* factory = [HTMLPurifier_AttrDef_Enum new];
def = [factory make:@"foo,bar"];
HTMLPurifier_AttrDef_Enum* def2 = [[HTMLPurifier_AttrDef_Enum alloc] initWithValidValues:@[@"foo",@"bar"]];
XCTAssertEqualObjects(def, def2);
def = [factory make:@"s:foo,BAR"];
def2 = [[HTMLPurifier_AttrDef_Enum alloc] initWithValidValues:@[@"foo",@"BAR"] caseSensitive:YES];
XCTAssertEqualObjects(def, def2);
}
@end