Differences From Artifact [67d2f603dc]:
- File
tests/TestsAppDelegate.m
— part of check-in
[085bfc12a0]
at
2013-04-27 01:26:35
on branch trunk
— Add OFStdIOStream.
This is used for of_std{in,out,err} now instead of OFFile. (user: js, size: 3690) [annotate] [blame] [check-ins using]
To Artifact [949d72dfbf]:
- File
tests/TestsAppDelegate.m
— part of check-in
[2713b481a1]
at
2013-04-27 02:22:43
on branch trunk
— Initial Wii port.
Threads and sockets still missing. (user: js, size: 5629) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
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 | #include "config.h" #include <stdlib.h> #import "OFString.h" #import "OFStdIOStream.h" #import "OFAutoreleasePool.h" #import "TestsAppDelegate.h" #ifdef _PSP # include <pspmoduleinfo.h> # include <pspkernel.h> # include <pspdebug.h> PSP_MODULE_INFO("ObjFW Tests", 0, 0, 0); #endif int main(int argc, char *argv[]) { #ifdef OF_OBJFW_RUNTIME atexit(objc_exit); #endif /* We need deterministic hashes for tests */ of_hash_seed = 0; return of_application_main(&argc, &argv, [TestsAppDelegate class]); } @implementation TestsAppDelegate - (void)outputString: (OFString*)str withColor: (int)color { #if defined(_PSP) | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 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 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 | #include "config.h" #include <stdlib.h> #import "OFString.h" #import "OFStdIOStream.h" #import "OFFile.h" #import "OFAutoreleasePool.h" #import "TestsAppDelegate.h" #ifdef _PSP # include <pspmoduleinfo.h> # include <pspkernel.h> # include <pspdebug.h> PSP_MODULE_INFO("ObjFW Tests", 0, 0, 0); #endif #ifdef __wii__ # define BOOL OGC_BOOL # include <gccore.h> # include <wiiuse/wpad.h> # undef BOOL #endif enum { NO_COLOR, RED, GREEN, YELLOW }; int main(int argc, char *argv[]) { #ifdef OF_OBJFW_RUNTIME atexit(objc_exit); #endif /* We need deterministic hashes for tests */ of_hash_seed = 0; #ifdef __wii__ GXRModeObj *rmode; void *xfb; VIDEO_Init(); WPAD_Init(); rmode = VIDEO_GetPreferredMode(NULL); xfb = MEM_K0_TO_K1(SYS_AllocateFramebuffer(rmode)); VIDEO_Configure(rmode); VIDEO_SetNextFramebuffer(xfb); VIDEO_SetBlack(FALSE); VIDEO_Flush(); VIDEO_WaitVSync(); if (rmode->viTVMode & VI_NON_INTERLACE) VIDEO_WaitVSync(); CON_InitEx(rmode, 10, 20, rmode->fbWidth - 10, rmode->xfbHeight - 20); VIDEO_ClearFrameBuffer(rmode, xfb, COLOR_BLACK); @try { return of_application_main(&argc, &argv, [TestsAppDelegate class]); } @catch (id e) { TestsAppDelegate *delegate = [[OFApplication sharedApplication] delegate]; OFString *string = [OFString stringWithFormat: @"\nRuntime error: Unhandled exception:\n%@\n", e]; [delegate outputString: string withColor: RED]; [delegate outputString: @"Press home button to exit!\n" withColor: NO_COLOR]; for (;;) { WPAD_ScanPads(); if (WPAD_ButtonsDown(0) & WPAD_BUTTON_HOME) [OFApplication terminateWithStatus: 1]; VIDEO_WaitVSync(); } } #else return of_application_main(&argc, &argv, [TestsAppDelegate class]); #endif } @implementation TestsAppDelegate - (void)outputString: (OFString*)str withColor: (int)color { #if defined(_PSP) |
︙ | ︙ | |||
68 69 70 71 72 73 74 | break; } pspDebugScreenSetXY(0, y); pspDebugScreenPrintData([str UTF8String], [str UTF8StringLength]); #elif defined(STDOUT) switch (color) { | > > > > > > | | | | | | | | | > > > > > > > > > > > > > > > > | 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 | break; } pspDebugScreenSetXY(0, y); pspDebugScreenPrintData([str UTF8String], [str UTF8StringLength]); #elif defined(STDOUT) switch (color) { case NO_COLOR: [of_stdout writeString: @"\r\033[K"]; # ifdef __wii__ [of_stdout writeString: @"\033[37m"]; # endif break; case RED: [of_stdout writeString: @"\r\033[K\033[31;1m"]; break; case GREEN: [of_stdout writeString: @"\r\033[K\033[32;1m"]; break; case YELLOW: [of_stdout writeString: @"\r\033[K\033[33;1m"]; break; } [of_stdout writeString: str]; [of_stdout writeString: @"\033[m"]; #else # error No output method! #endif } - (void)outputTesting: (OFString*)test inModule: (OFString*)module { OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; [self outputString: [OFString stringWithFormat: @"[%@] %@: testing...", module, test] withColor: YELLOW]; [pool release]; } - (void)outputSuccess: (OFString*)test inModule: (OFString*)module { OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; [self outputString: [OFString stringWithFormat: @"[%@] %@: ok\n", module, test] withColor: GREEN]; [pool release]; } - (void)outputFailure: (OFString*)test inModule: (OFString*)module { OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; [self outputString: [OFString stringWithFormat: @"[%@] %@: failed\n", module, test] withColor: RED]; [pool release]; #ifdef __wii__ [self outputString: @"Press A to continue!\n" withColor: NO_COLOR]; for (;;) { WPAD_ScanPads(); if (WPAD_ButtonsDown(0) & WPAD_BUTTON_A) return; VIDEO_WaitVSync(); } #endif } - (void)applicationDidFinishLaunching { #ifdef _PSP pspDebugScreenInit(); #endif #ifdef __wii__ [OFFile changeToDirectoryAtPath: @"/objfw-tests"]; #endif [self objectTests]; #ifdef OF_HAVE_BLOCKS [self blockTests]; #endif [self MD5HashTests]; [self SHA1HashTests]; |
︙ | ︙ | |||
160 161 162 163 164 165 166 | [self pluginTests]; #endif [self forwardingTests]; #ifdef OF_HAVE_PROPERTIES [self propertiesTests]; #endif | > > > > > > > | | > > > > > > | 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 | [self pluginTests]; #endif [self forwardingTests]; #ifdef OF_HAVE_PROPERTIES [self propertiesTests]; #endif #ifdef __wii__ [self outputString: @"Press home button to exit!\n" withColor: NO_COLOR]; for (;;) { WPAD_ScanPads(); if (WPAD_ButtonsDown(0) & WPAD_BUTTON_HOME) [OFApplication terminateWithStatus: _fails]; VIDEO_WaitVSync(); } #else [OFApplication terminateWithStatus: _fails]; #endif } @end |