Index: tests/Makefile ================================================================== --- tests/Makefile +++ tests/Makefile @@ -6,10 +6,11 @@ SRCS = OFArray.m \ OFDataArray.m \ OFDictionary.m \ OFHashes.m \ OFList.m \ + OFNumber.m \ OFObject.m \ ${OFPLUGIN_M} \ OFString.m \ OFTCPSocket.m \ ${OFTHREAD_M} \ ADDED tests/OFNumber.m Index: tests/OFNumber.m ================================================================== --- tests/OFNumber.m +++ tests/OFNumber.m @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2008 - 2009 + * Jonathan Schleifer + * + * All rights reserved. + * + * This file is part of ObjFW. 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. + */ + +#include "config.h" + +#import "OFNumber.h" +#import "OFAutoreleasePool.h" + +#import "main.h" + +static OFString *module = @"OFNumber"; + +void +number_tests() +{ + OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; + OFNumber *num; + + TEST(@"+[numberWithIntMax:]", + (num = [OFNumber numberWithIntMax: 123456789])) + + TEST(@"-[isEqual:]", + [num isEqual: [OFNumber numberWithUInt32: 123456789]]) + + TEST(@"-[hash]", [num hash] == 123456789) + + TEST(@"-[asDouble]", [num asDouble] == 123456789.L) + + TEST(@"-[decrease]", + [[num decrease] isEqual: [OFNumber numberWithInt32: 123456788]]) + + TEST(@"-[divideBy:]", + [[num divideBy: [OFNumber numberWithInt: 2]] asInt] == 61728394) + + [pool drain]; +} Index: tests/main.m ================================================================== --- tests/main.m +++ tests/main.m @@ -22,10 +22,11 @@ extern void array_tests(); extern void dataarray_tests(); extern void dictionary_tests(); extern void hashes_tests(); extern void list_tests(); +extern void number_tests(); extern void object_tests(); #ifdef OF_PLUGINS extern void plugin_tests(); #endif #ifdef OF_HAVE_PROPERTIES @@ -107,10 +108,11 @@ string_tests(); dataarray_tests(); array_tests(); dictionary_tests(); list_tests(); + number_tests(); tcpsocket_tests(); #ifdef OF_THREADS thread_tests(); #endif xmlelement_tests();