-
Notifications
You must be signed in to change notification settings - Fork 237
/
NSStringDTPathsTest.m
93 lines (66 loc) · 2.57 KB
/
NSStringDTPathsTest.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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
//
// NSStringDTPathsTest.m
// DTFoundation
//
// Created by Oliver Drobnik on 30.09.13.
// Copyright (c) 2013 Cocoanetics. All rights reserved.
//
#import "NSStringDTPathsTest.h"
#if !TARGET_OS_WATCH
@import DTFoundation;
@implementation NSStringDTPathsTest
#pragma mark - Standard Paths
- (void)testCachesPath
{
NSString *string1 = [NSString cachesPath];
XCTAssertTrue([string1 length], @"There should be a result");
NSString *string2 = [NSString cachesPath];
XCTAssertTrue([string2 length], @"There should be a result");
XCTAssertTrue([string1 isEqualToString:string2], @"Caches path should always be same");
}
- (void)testDocumentsPath
{
NSString *string1 = [NSString documentsPath];
XCTAssertTrue([string1 length], @"There should be a result");
NSString *string2 = [NSString documentsPath];
XCTAssertTrue([string2 length], @"There should be a result");
XCTAssertTrue([string1 isEqualToString:string2], @"Documents path should always be same");
}
#pragma mark - Temporary Paths
- (void)testTempPath
{
NSString *string1 = [NSString temporaryPath];
XCTAssertTrue([string1 length], @"There should be a result");
NSString *string2 = [NSString temporaryPath];
XCTAssertTrue([string2 length], @"There should be a result");
XCTAssertTrue([string1 isEqualToString:string2], @"Temp path should always be same");
}
- (void)testTempPathForFile
{
NSString *string1 = [NSString pathForTemporaryFile];
XCTAssertTrue([string1 length], @"There should be a result");
NSString *string2 = [NSString pathForTemporaryFile];
XCTAssertTrue([string2 length], @"There should be a result");
XCTAssertFalse([string1 isEqualToString:string2], @"Temp path for file should be different");
}
#pragma mark - Test Sequence Numbers
- (void)testIncrementSequenceNumber
{
NSString *fileName = @"file(9).jpg";
NSString *incremented = [fileName pathByIncrementingSequenceNumber];
XCTAssertTrue([incremented isEqualToString:@"file(10).jpg"], @"sequence number should be incremented");
fileName = @"file.jpg";
incremented = [fileName pathByIncrementingSequenceNumber];
XCTAssertTrue([incremented isEqualToString:@"file(1).jpg"], @"sequence number should be incremented");
fileName = @"file";
incremented = [fileName pathByIncrementingSequenceNumber];
XCTAssertTrue([incremented isEqualToString:@"file(1)"], @"sequence number should be incremented");
}
- (void)testDeleteSequenceNumber
{
NSString *fileName = @"file(999).jpg";
NSString *deleted = [fileName pathByDeletingSequenceNumber];
XCTAssertTrue([deleted isEqualToString:@"file.jpg"], @"sequence number should be removed");
}
@end
#endif