Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 86 lines (69 sloc) 2.445 kB
ed20d90 @soffes Added tests for categories
soffes authored
1 //
2 // DictionaryCategoryTest.m
3 // SSToolkit
4 //
5 // Created by Sam Soffes on 4/14/11.
6 // Copyright 2011 Sam Soffes. All rights reserved.
7 //
8
9 #import <SSToolkit/NSDictionary+SSToolkitAdditions.h>
10
11 @interface DictionaryCategoryTest : GHTestCase
12 @end
13
14 @implementation DictionaryCategoryTest
15
16 - (void)testURLEncoding {
17 NSDictionary *dictionary = [NSDictionary dictionaryWithObjectsAndKeys:
18 @"value1", @"key1",
19 @"value2", @"key2",
20 nil];
21
22 NSString *string = [dictionary stringWithFormEncodedComponents];
23 GHAssertEqualObjects([NSDictionary dictionaryWithFormEncodedString:string], dictionary, nil);
24
25 // Go nuts
26 dictionary = [NSDictionary dictionaryWithObjectsAndKeys:
27 @"£™¢£∞¢§∞¶•§ª¶º!@#$%^&*()", @"œ∑´∞®†¥¨ˆø",
28 @"ÎÍÏ˝ÓÔÒژ¯", @"ç√≈∫˜µ≤∆˚¬˙©",
29 nil];
30
31 string = [dictionary stringWithFormEncodedComponents];
32 GHAssertEqualObjects([NSDictionary dictionaryWithFormEncodedString:string], dictionary, nil);
33 }
34
bda4a70 @soffes Added `SHA1Sum` and `MD5Sum` to NSDictionary and NSArray (with tests …
soffes authored
35
36 - (void)testMD5Sum {
37 NSDictionary *dictionary1 = [NSDictionary dictionaryWithObjectsAndKeys:
38 @"value1", @"key1",
39 @"value2", @"key2",
40 @"value3", @"key3",
41 @"value4", @"key4",
42 @"value5", @"key5",
43 nil];
44
a612ee3 @soffes Updated tests and removed warning
soffes authored
45 NSMutableDictionary *dictionary2 = [NSMutableDictionary dictionaryWithObjectsAndKeys:
46 @"value3", @"key3",
47 @"value4", @"key4",
48 @"value5", @"key5",
49 @"value1", @"key1",
50 nil];
51 [dictionary2 setObject:@"value2" forKey:@"key2"];
bda4a70 @soffes Added `SHA1Sum` and `MD5Sum` to NSDictionary and NSArray (with tests …
soffes authored
52
a612ee3 @soffes Updated tests and removed warning
soffes authored
53 NSString *sum1 = [dictionary1 MD5Sum];
54 NSString *sum2 = [dictionary2 MD5Sum];
55 GHAssertNotNil(sum1, nil);
56 GHAssertNotNil(sum2, nil);
57 GHAssertEqualObjects(sum1, sum2, nil);
bda4a70 @soffes Added `SHA1Sum` and `MD5Sum` to NSDictionary and NSArray (with tests …
soffes authored
58 }
59
60
61 - (void)testSHA1Sum {
62 NSDictionary *dictionary1 = [NSDictionary dictionaryWithObjectsAndKeys:
63 @"value1", @"key1",
64 @"value2", @"key2",
65 @"value3", @"key3",
66 @"value4", @"key4",
67 @"value5", @"key5",
68 nil];
69
a612ee3 @soffes Updated tests and removed warning
soffes authored
70 NSMutableDictionary *dictionary2 = [NSMutableDictionary dictionaryWithObjectsAndKeys:
71 @"value3", @"key3",
72 @"value4", @"key4",
73 @"value5", @"key5",
74 @"value1", @"key1",
75 nil];
76 [dictionary2 setObject:@"value2" forKey:@"key2"];
bda4a70 @soffes Added `SHA1Sum` and `MD5Sum` to NSDictionary and NSArray (with tests …
soffes authored
77
a612ee3 @soffes Updated tests and removed warning
soffes authored
78 NSString *sum1 = [dictionary1 SHA1Sum];
79 NSString *sum2 = [dictionary2 SHA1Sum];
80 GHAssertNotNil(sum1, nil);
81 GHAssertNotNil(sum2, nil);
82 GHAssertEqualObjects(sum1, sum2, nil);
bda4a70 @soffes Added `SHA1Sum` and `MD5Sum` to NSDictionary and NSArray (with tests …
soffes authored
83 }
84
ed20d90 @soffes Added tests for categories
soffes authored
85 @end
Something went wrong with that request. Please try again.