Overview
Comment: | Add new testing framework - all existing tests are going to be migrated. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
d1ddc84e0ea5894988dab1a4e49465dc |
User & Date: | js on 2009-09-13 18:26:03 |
Other Links: | manifest | tags |
Context
2009-09-14
| ||
18:37 | A few test framework improvements and migration of OFString tests. check-in: 138cb8f09a user: js tags: trunk | |
2009-09-13
| ||
18:26 | Add new testing framework - all existing tests are going to be migrated. check-in: d1ddc84e0e user: js tags: trunk | |
2009-09-11
| ||
11:41 | Fix a warning with old GCC versions. check-in: 3468abde19 user: js tags: trunk | |
Changes
Modified configure.ac from [94f9404973] to [a8d789ae2b].
︙ | ︙ | |||
201 202 203 204 205 206 207 | if test x"$cross_compiling" = x"yes"; then case "$host" in *-*-mingw*) AC_PATH_PROG(WINE, wine) if test x"$WINE" != "x"; then | | | | 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 | if test x"$cross_compiling" = x"yes"; then case "$host" in *-*-mingw*) AC_PATH_PROG(WINE, wine) if test x"$WINE" != "x"; then AC_SUBST(TESTS, "tests_new tests") AC_SUBST(TEST_LAUNCHER, "$WINE") fi ;; esac else AC_SUBST(TESTS, "tests_new tests") fi BUILDSYS_TOUCH_DEPS AC_SUBST(PACKAGE, objfw) AC_CONFIG_FILES([buildsys.mk extra.mk objfw-config]) AC_CONFIG_HEADERS(config.h) AC_OUTPUT |
Deleted tests/OFObject/Makefile version [f8940d3191].
|
| < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted tests/OFObject/OFObject.m version [e3a197e96b].
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Added tests_new/Makefile version [743b0898b3].
> > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | PROG_NOINST = tests${PROG_SUFFIX} SRCS = main.m \ object.m include ../buildsys.mk include ../extra.mk CPPFLAGS += -I../src -I.. -DSTDOUT LIBS := -L../src -lobjfw ${LIBS} .PHONY: run all: run run: ${PROG_NOINST} rm -f libobjfw.so.0 libobjfw.so.0.1 libobjfw.dll libobjfw.dylib ln -s ../src/libobjfw.so libobjfw.so.0 ln -s ../src/libobjfw.so libobjfw.so.0.1 if test -f ../src/libobjfw.dll; then \ ln ../src/libobjfw.dll libobjfw.dll; \ fi ln -s ../src/libobjfw.dylib libobjfw.dylib LD_LIBRARY_PATH=.$${LD_LIBRARY_PATH+:}$$LD_LIBRARY_PATH \ DYLD_LIBRARY_PATH=.$${DYLD_LIBRARY_PATH+:}$$DYLD_LIBRARY_PATH \ ${TEST_LAUNCHER} ./${PROG_NOINST}; EXIT=$$?; \ rm -f libobjfw.so.0 libobjfw.so.0.1 libobjfw.dll libobjfw.dylib; \ exit $$EXIT |
Added tests_new/main.h version [1a59e2e7e2].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | /* * Copyright (c) 2008 - 2009 * Jonathan Schleifer <js@webkeks.org> * * 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 "OFString.h" extern void testing(OFString*, OFString*); extern void success(OFString*, OFString*); extern void failed(OFString*, OFString*); #define TEST(test, cond) \ { \ testing(module, test); \ if (cond) \ success(module, test); \ else \ failed(module, test); \ } #define EXPECT_EXCEPTION(test, exception, code) \ { \ BOOL caught = NO; \ \ @try { \ code; \ } @catch (exception *e) { \ caught = YES; \ [e dealloc]; \ } \ \ TEST(test, caught) \ } |
Added tests_new/main.m version [abc8b39d7c].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 | /* * Copyright (c) 2008 - 2009 * Jonathan Schleifer <js@webkeks.org> * * 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. */ #include "config.h" #ifdef STDOUT #include <stdio.h> #endif #include <stdlib.h> #import <OFString.h> #import <OFAutoreleasePool.h> extern void object_tests(); static void output(OFString *str, int color) { #ifdef STDOUT switch (color) { case 0: fputs("\r\033[K\033[1;33m", stdout); break; case 1: fputs("\r\033[K\033[1;32m", stdout); break; case 2: fputs("\r\033[K\033[1;31m", stdout); break; } fputs([str cString], stdout); fputs("\033[m", stdout); #else #error No output method! #endif } void testing(OFString *module, OFString *test) { OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; OFString *str = [OFString stringWithFormat: @"[%s] %s: testing...", [module cString], [test cString]]; output(str, 0); [pool release]; } void success(OFString *module, OFString *test) { OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; OFString *str = [OFString stringWithFormat: @"[%s] %s: ok\n", [module cString], [test cString]]; output(str, 1); [pool release]; } void failed(OFString *module, OFString *test) { OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; OFString *str = [OFString stringWithFormat: @"[%s] %s: failed\n", [module cString], [test cString]]; output(str, 2); [pool release]; exit(1); } int main() { object_tests(); return 0; } |
Added tests_new/object.m version [07d7a9fb2e].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 | /* * Copyright (c) 2008 - 2009 * Jonathan Schleifer <js@webkeks.org> * * 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. */ #include "config.h" #import "OFAutoreleasePool.h" #import "OFExceptions.h" #import "main.h" static OFString *module = @"OFObject"; void object_tests() { OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; OFObject *obj = [[[OFObject alloc] init] autorelease]; void *p, *q, *r; EXPECT_EXCEPTION(@"Detect freeing of memory not allocated by object", OFMemoryNotPartOfObjectException, [obj freeMemory: NULL]) TEST(@"Allocating 4096 bytes", (p = [obj allocMemoryWithSize: 4096]) != NULL) TEST(@"Freeing memory", [obj freeMemory: p]) EXPECT_EXCEPTION(@"Detect freeing of memory twice", OFMemoryNotPartOfObjectException, [obj freeMemory: p]) TEST(@"Allocating and freeing 4096 bytes 3 times", (p = [obj allocMemoryWithSize: 4096]) != NULL && (q = [obj allocMemoryWithSize: 4096]) != NULL && (r = [obj allocMemoryWithSize: 4096]) != NULL && [obj freeMemory: p] && [obj freeMemory: q] && [obj freeMemory: r]) EXPECT_EXCEPTION(@"Detect out of memory on alloc", OFOutOfMemoryException, [obj allocMemoryWithSize: SIZE_MAX]) EXPECT_EXCEPTION(@"Detect out of memory on resize", OFOutOfMemoryException, { p = [obj allocMemoryWithSize: 1]; [obj resizeMemory: p toSize: SIZE_MAX]; }) [obj freeMemory: p]; TEST(@"Allocate when trying to resize NULL", (p = [obj resizeMemory: NULL toSize: 1024]) != NULL) [obj freeMemory: p]; EXPECT_EXCEPTION(@"Detect resizing of memory not allocated by object", OFMemoryNotPartOfObjectException, [obj resizeMemory: (void*)1 toSize: 1024]) [pool release]; } |