Index: tests/OFString/OFString.m ================================================================== --- tests/OFString/OFString.m +++ tests/OFString/OFString.m @@ -17,31 +17,50 @@ /* TODO: Do real checks */ int main() { - OFString *s1 = [OFString new: "foo"]; + OFString *s1 = [OFString new: "test"]; OFString *s2 = [[OFString alloc] init: ""]; OFString *s3; OFString *s4 = [OFString new]; - [s2 append: "bar"]; + [s2 append: "123"]; s3 = [s1 clone]; [s4 setTo: [s2 cString]]; - printf("s1 = %s\n", [s1 cString]); - printf("s2 = %s\n", [s2 cString]); - printf("s3 = %s\n", [s3 cString]); - printf("s4 = %s\n", [s4 cString]); - - [s1 append: [s2 cString]]; - printf("s1 append s2 = %s\n", [s1 cString]); - printf("strlen(s1) = %zd, [s1 length] = %zd\n", - strlen([s1 cString]), [s1 length]); + if (!strcmp([s1 cString], [s3 cString])) + puts("s1 and s3 match! GOOD!"); + else { + puts("s1 and s3 don't match!"); + return 1; + } + + if (!strcmp([s2 cString], [s4 cString])) + puts("s2 and s4 match! GOOD!"); + else { + puts("s1 and s3 don't match!"); + return 1; + } + + if (!strcmp([[s1 append: [s2 cString]] cString], "test123")) + puts("s1 appended with s2 is the expected string! GOOD!"); + else { + puts("s1 appended with s2 is not the expected string!"); + return 1; + } + + if (strlen([s1 cString]) == [s1 length] && [s1 length] == 7) + puts("s1 has the expected length. GOOD!"); + else { + puts("s1 does not have the expected length!"); + return 1; + } + [s1 free]; [s2 free]; [s3 free]; [s4 free]; return 0; } Index: tests/OFWideString/OFWideString.m ================================================================== --- tests/OFWideString/OFWideString.m +++ tests/OFWideString/OFWideString.m @@ -7,41 +7,59 @@ * This file is part of libobjfw. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE included in * the packaging of this file. */ -#define _ISOC99_SOURCE #import #import "OFWideString.h" /* TODO: Do real checks */ int main() { - OFWideString *s1 = [OFWideString new: L"foo"]; + OFWideString *s1 = [OFWideString new: L"test"]; OFWideString *s2 = [[OFWideString alloc] init: L""]; OFWideString *s3; OFWideString *s4 = [OFWideString new]; - [s2 append: L"bar"]; + [s2 append: L"123"]; s3 = [s1 clone]; [s4 setTo: [s2 wcString]]; - wprintf(L"s1 = %S\n", [s1 wcString]); - wprintf(L"s2 = %S\n", [s2 wcString]); - wprintf(L"s3 = %S\n", [s3 wcString]); - wprintf(L"s4 = %S\n", [s4 wcString]); - - [s1 append: [s2 wcString]]; - wprintf(L"s1 append s2 = %S\n", [s1 wcString]); - wprintf(L"wcslen(s1) = %zd, [s1 length] = %zd\n", - wcslen([s1 wcString]), [s1 length]); + if (!wcscmp([s1 wcString], [s3 wcString])) + puts("s1 and s3 match! GOOD!"); + else { + puts("s1 and s3 don't match!"); + return 1; + } + + if (!wcscmp([s2 wcString], [s4 wcString])) + puts("s2 and s4 match! GOOD!"); + else { + puts("s1 and s3 don't match!"); + return 1; + } + + if (!wcscmp([[s1 append: [s2 wcString]] wcString], L"test123")) + puts("s1 appended with s2 is the expected string! GOOD!"); + else { + puts("s1 appended with s2 is not the expected string!"); + return 1; + } + + if (wcslen([s1 wcString]) == [s1 length] && [s1 length] == 7) + puts("s1 has the expected length. GOOD!"); + else { + puts("s1 does not have the expected length!"); + return 1; + } + [s1 free]; [s2 free]; [s3 free]; [s4 free]; return 0; }