Last active
August 29, 2015 13:56
-
-
Save veader/9102508 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)testShouldDecodeBase64EncodedString { | |
NSString *encodedString = @"ZEdWemRBPT0="; | |
NSString *decodedString = [[NSString stringWithBase64EncodedString:encodedString] base64DecodedString]; | |
NSString *properResult = @"test"; | |
XCTAssert([properResult isEqualToString:decodedString], @"Unable to decode base64 encoded string"); | |
} | |
- (void)testShouldWorkWithoutCategoryToDecodeUTF8String { | |
NSString *encodedString = @"dTA0QTA6INKgINKhINKiINKjINKkINKlINKmINKnINKoINKpINKqINKrINKsINKtINKuINKvINKwINKxINKyINKzINK0INK1INK2INK3INK4INK5INK6INK7INK8INK9INK+INK/"; | |
NSData *encodedData = [[NSData alloc] initWithBase64Encoding:encodedString]; | |
NSString *decodedString = [[NSString alloc] initWithData:encodedData encoding:NSUTF8StringEncoding]; | |
NSString *properResult = @"u04A0: Ҡ ҡ Ң ң Ҥ ҥ Ҧ ҧ Ҩ ҩ Ҫ ҫ Ҭ ҭ Ү ү Ұ ұ Ҳ ҳ Ҵ ҵ Ҷ ҷ Ҹ ҹ Һ һ Ҽ ҽ Ҿ ҿ"; | |
XCTAssert([properResult isEqualToString:decodedString], @"Unable to decode base64 encoded UTF8 string"); | |
} | |
- (void)testShouldDecodeBase64EncodedUTF8String { | |
NSString *encodedString = @"dTA0QTA6INKgINKhINKiINKjINKkINKlINKmINKnINKoINKpINKqINKrINKsINKtINKuINKvINKwINKxINKyINKzINK0INK1INK2INK3INK4INK5INK6INK7INK8INK9INK+INK/"; | |
NSString *decodedString = [[NSString stringWithBase64EncodedString:encodedString] base64DecodedString]; | |
NSString *properResult = @"u04A0: Ҡ ҡ Ң ң Ҥ ҥ Ҧ ҧ Ҩ ҩ Ҫ ҫ Ҭ ҭ Ү ү Ұ ұ Ҳ ҳ Ҵ ҵ Ҷ ҷ Ҹ ҹ Һ һ Ҽ ҽ Ҿ ҿ"; | |
XCTAssert([properResult isEqualToString:decodedString], @"Unable to decode base64 encoded UTF8 string"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment