adium/adium

Add some tests NSData+Base64.

2013-06-07, Frank Dowsett
7a4731a5e936
Parents 1314884409b0
Children a47f5e0cdce7
Add some tests NSData+Base64.
--- a/Adium.xcodeproj/project.pbxproj Fri Jun 07 18:01:06 2013 -0400
+++ b/Adium.xcodeproj/project.pbxproj Fri Jun 07 21:18:33 2013 -0400
@@ -1020,6 +1020,8 @@
5A1E3A1214DCE60400724574 /* Preferences-Xtras.xib in Resources */ = {isa = PBXBuildFile; fileRef = 5A1E3A1114DCE60400724574 /* Preferences-Xtras.xib */; };
5A22D6E214834F44004E15F7 /* AIFacebookXMPPAccountView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 5A22D6E014834F44004E15F7 /* AIFacebookXMPPAccountView.xib */; };
5A27FA7E14A272330063489D /* pref-messagestyle.png in Resources */ = {isa = PBXBuildFile; fileRef = 5A27FA7A14A272330063489D /* pref-messagestyle.png */; };
+ 5A2F34451762B0CE00C612B7 /* TestNSData+Base64.m in Sources */ = {isa = PBXBuildFile; fileRef = 5A2F34441762B0CE00C612B7 /* TestNSData+Base64.m */; };
+ 5A2F34491762B1F500C612B7 /* NSData+Base64.m in Sources */ = {isa = PBXBuildFile; fileRef = 5A4B77E716FBDDC600DF398C /* NSData+Base64.m */; };
5A3B4D7916D878AC00903E40 /* NSString+STTwitter.m in Sources */ = {isa = PBXBuildFile; fileRef = 5A3B4D6C16D878AB00903E40 /* NSString+STTwitter.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
5A3B4D7A16D878AC00903E40 /* STTwitterAPIWrapper.m in Sources */ = {isa = PBXBuildFile; fileRef = 5A3B4D6E16D878AB00903E40 /* STTwitterAPIWrapper.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
5A3B4D7C16D878AC00903E40 /* STTwitterOAuth.m in Sources */ = {isa = PBXBuildFile; fileRef = 5A3B4D7216D878AB00903E40 /* STTwitterOAuth.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
@@ -3887,6 +3889,8 @@
5A1FEA601334549300C14951 /* MessageView.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; name = MessageView.xib; path = "Plugins/Dual Window Interface/MessageView.xib"; sourceTree = "<group>"; };
5A22D6E114834F44004E15F7 /* en */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xib; name = en; path = "Plugins/Purple Service/Resources/en.lproj/AIFacebookXMPPAccountView.xib"; sourceTree = "<group>"; };
5A27FA7A14A272330063489D /* pref-messagestyle.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "pref-messagestyle.png"; path = "Resources/pref-messagestyle.png"; sourceTree = "<group>"; };
+ 5A2F34431762B0CE00C612B7 /* TestNSData+Base64.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "TestNSData+Base64.h"; path = "UnitTests/TestNSData+Base64.h"; sourceTree = "<group>"; };
+ 5A2F34441762B0CE00C612B7 /* TestNSData+Base64.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "TestNSData+Base64.m"; path = "UnitTests/TestNSData+Base64.m"; sourceTree = "<group>"; };
5A3B4D6B16D878AB00903E40 /* NSString+STTwitter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "NSString+STTwitter.h"; path = "Plugins/Twitter Plugin/STTwitter/NSString+STTwitter.h"; sourceTree = "<group>"; };
5A3B4D6C16D878AB00903E40 /* NSString+STTwitter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "NSString+STTwitter.m"; path = "Plugins/Twitter Plugin/STTwitter/NSString+STTwitter.m"; sourceTree = "<group>"; };
5A3B4D6D16D878AB00903E40 /* STTwitterAPIWrapper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = STTwitterAPIWrapper.h; path = "Plugins/Twitter Plugin/STTwitter/STTwitterAPIWrapper.h"; sourceTree = "<group>"; };
@@ -5165,6 +5169,8 @@
31FA7F100D4A75D000ABE634 /* TestRichTextCoercion.m */,
634BCD1D0DDC1542005AF1C2 /* TestMutableStringAdditions.h */,
634BCD1E0DDC1542005AF1C2 /* TestMutableStringAdditions.m */,
+ 5A2F34431762B0CE00C612B7 /* TestNSData+Base64.h */,
+ 5A2F34441762B0CE00C612B7 /* TestNSData+Base64.m */,
31034EFD0C8142680003F5AA /* TestStringAdditions.h */,
31034EFE0C8142680003F5AA /* TestStringAdditions.m */,
31034F0B0C8142720003F5AA /* UTF8Snowman.txt */,
@@ -10141,6 +10147,8 @@
318EA69C0D7A659900EDB105 /* TestColorAdditions.m in Sources */,
634BCD1F0DDC1542005AF1C2 /* TestMutableStringAdditions.m in Sources */,
3107D5250F63134F0051DDD5 /* TestAttributedStringAdditions.m in Sources */,
+ 5A2F34451762B0CE00C612B7 /* TestNSData+Base64.m in Sources */,
+ 5A2F34491762B1F500C612B7 /* NSData+Base64.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
--- a/Plugins/Twitter Plugin/STTwitter/NSData+Base64.m Fri Jun 07 18:01:06 2013 -0400
+++ b/Plugins/Twitter Plugin/STTwitter/NSData+Base64.m Fri Jun 07 21:18:33 2013 -0400
@@ -101,7 +101,7 @@
size_t accumulateIndex = 0;
while (i < length)
{
- unsigned char decode = base64DecodeLookup[inputBuffer[i++]];
+ unsigned char decode = base64DecodeLookup[(int)inputBuffer[i++]];
if (decode != xx)
{
accumulated[accumulateIndex] = decode;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/UnitTests/TestNSData+Base64.h Fri Jun 07 21:18:33 2013 -0400
@@ -0,0 +1,19 @@
+/*
+ * Adium is the legal property of its developers, whose names are listed in the copyright file included
+ * with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or modify it under the terms of the GNU
+ * General Public License as published by the Free Software Foundation; either version 2 of the License,
+ * or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
+ * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+ * Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with this program; if not,
+ * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+@interface TestNSData_Base64 : SenTestCase
+
+@end
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/UnitTests/TestNSData+Base64.m Fri Jun 07 21:18:33 2013 -0400
@@ -0,0 +1,52 @@
+/*
+ * Adium is the legal property of its developers, whose names are listed in the copyright file included
+ * with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or modify it under the terms of the GNU
+ * General Public License as published by the Free Software Foundation; either version 2 of the License,
+ * or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
+ * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+ * Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with this program; if not,
+ * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#import "TestNSData+Base64.h"
+#import "NSData+Base64.h"
+
+@implementation TestNSData_Base64
+
+- (void)testBase64Encode
+{
+ NSString *decodedString = @"abcdefghijklmnopqrstuvwxyz1234567890!@#$%^&";
+ NSData *decodedData = [decodedString dataUsingEncoding:NSUTF8StringEncoding];
+ NSString *expectedEncodedString = @"YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXoxMjM0NTY3ODkwIUAjJCVeJg==";
+ NSString *actualEncodedString = [decodedData base64EncodedString];
+ STAssertTrue([expectedEncodedString isEqualToString:actualEncodedString], nil);
+
+ decodedString = @"☃";
+ decodedData = [decodedString dataUsingEncoding:NSUTF8StringEncoding];
+ expectedEncodedString = @"4piD";
+ actualEncodedString = [decodedData base64EncodedString];
+ STAssertTrue([expectedEncodedString isEqualToString:actualEncodedString], nil);
+}
+
+- (void)testBase64Decode
+{
+ NSString *encodedString = @"YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXoxMjM0NTY3ODkwIUAjJCVeJg==";
+ NSString *decodedString = @"abcdefghijklmnopqrstuvwxyz1234567890!@#$%^&";
+ NSData *encodedData = [decodedString dataUsingEncoding:NSUTF8StringEncoding];
+ NSData *decodedData = [NSData dataFromBase64String:encodedString];
+ STAssertTrue([encodedData isEqualToData:decodedData], nil);
+
+ encodedString = @"4piD";
+ decodedString = @"☃";
+ encodedData = [decodedString dataUsingEncoding:NSUTF8StringEncoding];
+ decodedData = [NSData dataFromBase64String:encodedString];
+ STAssertTrue([encodedData isEqualToData:decodedData], nil);
+}
+
+@end