Index: Makefile ================================================================== --- Makefile +++ Makefile @@ -1,4 +1,4 @@ SUBDIRS = src tests -DISTCLEAN = autom4te.cache buildsys.mk config.log +DISTCLEAN = aclocal.m4 autom4te.cache buildsys.mk config.log config.status include buildsys.mk Index: src/OFWideString.m ================================================================== --- src/OFWideString.m +++ src/OFWideString.m @@ -102,11 +102,12 @@ return nil; } wstring = newstr; - memcpy(wstring + length, wstr, strlength); + memcpy(wstring + length * sizeof(wchar_t), wstr, + strlength * sizeof(wchar_t)); wstring[newlen] = '\0'; length = newlen; return self; Index: tests/Makefile ================================================================== --- tests/Makefile +++ tests/Makefile @@ -1,3 +1,3 @@ -SUBDIRS = OFString OFList +SUBDIRS = OFString OFList OFWideString include ../buildsys.mk ADDED tests/OFWideString/Makefile Index: tests/OFWideString/Makefile ================================================================== --- /dev/null +++ tests/OFWideString/Makefile @@ -0,0 +1,7 @@ +PROG_NOINST = ofwidestring +SRCS = OFWideString.m + +include ../../buildsys.mk + +CPPFLAGS += -I../../src +LIBS += -lobjc -L../../src -lobjfw ADDED tests/OFWideString/OFWideString.m Index: tests/OFWideString/OFWideString.m ================================================================== --- /dev/null +++ tests/OFWideString/OFWideString.m @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2008 + * Jonathan Schleifer + * + * All rights reserved. + * + * 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. + */ + +#import +#import + +#import "OFWideString.h" + +int +main() +{ + OFWideString *s1 = [OFWideString new:L"foo"]; + OFWideString *s2 = [[OFWideString alloc] init:L""]; + OFWideString *s3; + OFWideString *s4 = [OFWideString new]; + + printf("%p\n", [s2 append:L"bar"]); + 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"strlen(s1) = %zd, [s1 length] = %zd\n", + wcslen([s1 wcString]), [s1 length]); + [s1 free]; + [s2 free]; + [s3 free]; + [s4 free]; + + return 0; +}