-
Notifications
You must be signed in to change notification settings - Fork 1
/
StringUtilsTestCase.m
71 lines (55 loc) · 2.53 KB
/
StringUtilsTestCase.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
//
// StringUtilsTest.m
// SSHLauncher
//
// Created by Martin Jansen on 13.05.10.
// Copyright 2010 Martin Jansen. All rights reserved.
//
#import "StringUtilsTestCase.h"
#import "StringUtils.h"
@implementation StringUtilsTestCase
- (void) testRepeat
{
NSString* result;
result = [StringUtils repeat: @"hello" times: 3];
STAssertEqualObjects(@"hellohellohello", result, @"String repetition does not work.");
result = [StringUtils repeat: @"hello" times: 0];
STAssertEqualObjects(@"", result, @"String repetition does not work.");
result = [StringUtils repeat: @"" times: 0];
STAssertEqualObjects(@"", result, @"String repetition does not work.");
result = [StringUtils repeat: @"" times: 10];
STAssertEqualObjects(@"", result, @"String repetition does not work.");
result = [StringUtils repeat: @"a" times: 2];
STAssertEqualObjects(@"aa", result, @"String repetition does not work.");
result = [StringUtils repeat: @"a" times: 1];
STAssertEqualObjects(@"a", result, @"String repetition does not work.");
result = [StringUtils repeat: @"a" times: 0];
STAssertEqualObjects(@"", result, @"String repetition does not work.");
}
- (void) testContainsDigits
{
STAssertTrue([StringUtils containsDigits: @"1"], @"");
STAssertTrue([StringUtils containsDigits: @"a1a"], @"");
STAssertTrue([StringUtils containsDigits: @"aa1"], @"");
STAssertTrue([StringUtils containsDigits: @" 1 b 2"], @"");
STAssertFalse([StringUtils containsDigits: @""], @"");
STAssertFalse([StringUtils containsDigits: @" "], @"");
STAssertFalse([StringUtils containsDigits: @"a"], @"");
STAssertTrue([StringUtils containsDigits: @"0"], @"");
STAssertTrue([StringUtils containsDigits: @"0123456789"], @"");
STAssertTrue([StringUtils containsDigits: @"0123456789a"], @"");
}
- (void) testContainsOnlyDigits
{
STAssertTrue([StringUtils containsOnlyDigits: @"1"], @"");
STAssertFalse([StringUtils containsOnlyDigits: @"a1a"], @"");
STAssertFalse([StringUtils containsOnlyDigits: @"aa1"], @"");
STAssertFalse([StringUtils containsOnlyDigits: @" 1 b 2"], @"");
STAssertFalse([StringUtils containsOnlyDigits: @""], @"");
STAssertFalse([StringUtils containsOnlyDigits: @" "], @"");
STAssertFalse([StringUtils containsOnlyDigits: @"a"], @"");
STAssertTrue([StringUtils containsOnlyDigits: @"0"], @"");
STAssertTrue([StringUtils containsOnlyDigits: @"0123456789"], @"");
STAssertFalse([StringUtils containsOnlyDigits: @"0123456789a"], @"");
}
@end