Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

file 85 lines (69 sloc) 2.445 kb
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
//
// DictionaryCategoryTest.m
// SSToolkit
//
// Created by Sam Soffes on 4/14/11.
// Copyright 2011 Sam Soffes. All rights reserved.
//

#import <SSToolkit/NSDictionary+SSToolkitAdditions.h>

@interface DictionaryCategoryTest : GHTestCase
@end

@implementation DictionaryCategoryTest

- (void)testURLEncoding {
NSDictionary *dictionary = [NSDictionary dictionaryWithObjectsAndKeys:
@"value1", @"key1",
@"value2", @"key2",
nil];

NSString *string = [dictionary stringWithFormEncodedComponents];
GHAssertEqualObjects([NSDictionary dictionaryWithFormEncodedString:string], dictionary, nil);

// Go nuts
dictionary = [NSDictionary dictionaryWithObjectsAndKeys:
@"£™¢£∞¢§∞¶•§ª¶º!@#$%^&*()", @"œ∑´∞®†¥¨ˆø",
@"ÎÍÏ˝ÓÔÒژ¯", @"ç√≈∫˜µ≤∆˚¬˙©",
nil];

string = [dictionary stringWithFormEncodedComponents];
GHAssertEqualObjects([NSDictionary dictionaryWithFormEncodedString:string], dictionary, nil);
}


- (void)testMD5Sum {
NSDictionary *dictionary1 = [NSDictionary dictionaryWithObjectsAndKeys:
@"value1", @"key1",
@"value2", @"key2",
@"value3", @"key3",
@"value4", @"key4",
@"value5", @"key5",
nil];

NSMutableDictionary *dictionary2 = [NSMutableDictionary dictionaryWithObjectsAndKeys:
@"value3", @"key3",
@"value4", @"key4",
@"value5", @"key5",
@"value1", @"key1",
nil];
[dictionary2 setObject:@"value2" forKey:@"key2"];

NSString *sum1 = [dictionary1 MD5Sum];
NSString *sum2 = [dictionary2 MD5Sum];
GHAssertNotNil(sum1, nil);
GHAssertNotNil(sum2, nil);
GHAssertEqualObjects(sum1, sum2, nil);
}


- (void)testSHA1Sum {
NSDictionary *dictionary1 = [NSDictionary dictionaryWithObjectsAndKeys:
@"value1", @"key1",
@"value2", @"key2",
@"value3", @"key3",
@"value4", @"key4",
@"value5", @"key5",
nil];

NSMutableDictionary *dictionary2 = [NSMutableDictionary dictionaryWithObjectsAndKeys:
@"value3", @"key3",
@"value4", @"key4",
@"value5", @"key5",
@"value1", @"key1",
nil];
[dictionary2 setObject:@"value2" forKey:@"key2"];

NSString *sum1 = [dictionary1 SHA1Sum];
NSString *sum2 = [dictionary2 SHA1Sum];
GHAssertNotNil(sum1, nil);
GHAssertNotNil(sum2, nil);
GHAssertEqualObjects(sum1, sum2, nil);
}

@end
Something went wrong with that request. Please try again.