diff --git a/Tests/Unit/TestNSString+Utilities.m b/Tests/Unit/TestNSString+Utilities.m index 6442c800f..5dbe0cd9e 100644 --- a/Tests/Unit/TestNSString+Utilities.m +++ b/Tests/Unit/TestNSString+Utilities.m @@ -1,8 +1,10 @@ /* TestNSString+Utilities.m - this file is part of SOGo * * Copyright (C) 2011 Inverse inc + * Copyright (C) 2014 Zentyal * * Author: Wolfgang Sourdeau + * Jesús García Sáez * * This file is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -23,7 +25,7 @@ /* This file is encoded in utf-8. */ #import - +#import #import "SOGoTest.h" @interface TestNSString_plus_Utilities : SOGoTest @@ -52,7 +54,7 @@ NSString *secret = @"this is a secret"; NSString *password = @"qwerty"; NSString *encresult, *decresult; - + encresult = [secret encryptWithKey: nil]; failIf(encresult != nil); encresult = [secret encryptWithKey: @""]; @@ -70,4 +72,28 @@ failIf(![decresult isEqualToString: secret]); } +- (void) test_objectFromJSONString_single_values +{ + NSString *json, *error; + NSInteger expected = 1; + id result; + + // Decode null + json = [NSString stringWithFormat:@"null"]; + result = [json objectFromJSONString]; + testWithMessage(result == [NSNull null], @"Result should be null"); + + // Decode number + json = [NSString stringWithFormat:@"1"]; + result = [json objectFromJSONString]; + error = [NSString stringWithFormat: @"result %@ != expected %d", + result, expected]; + testWithMessage((long)result != (long)expected, error); + + // Decode string + json = [NSString stringWithFormat:@"\"kill me\""]; + result = [json objectFromJSONString]; + testEquals(result, @"kill me"); +} + @end