comparison test/automated/SDL_at.c @ 3713:a34bab848c7e gsoc2009_unit_tests

Better output. Newline handling. rwops test handles ConstMem, FP and File.
author Edgar Simo <bobbens@gmail.com>
date Sat, 20 Jun 2009 16:46:58 +0000
parents 80839fc6b8e1
children d8772964e402
comparison
equal deleted inserted replaced
3712:916469fbdc29 3713:a34bab848c7e
69 /* Display message if verbose on failed. */ 69 /* Display message if verbose on failed. */
70 failed = at_failure; 70 failed = at_failure;
71 if (verbose) { 71 if (verbose) {
72 if (at_failure > 0) { 72 if (at_failure > 0) {
73 SDL_ATprint( "%s : Failed %d out of %d testcases!\n", 73 SDL_ATprint( "%s : Failed %d out of %d testcases!\n",
74 at_suite_msg, at_failure, at_success ); 74 at_suite_msg, at_failure, at_failure+at_success );
75 } 75 }
76 else { 76 else {
77 SDL_ATprint( "%s : All tests successful (%d)\n", 77 SDL_ATprint( "%s : All tests successful (%d)\n",
78 at_suite_msg, at_success ); 78 at_suite_msg, at_success );
79 } 79 }
92 */ 92 */
93 void SDL_ATbegin( const char *testcase ) 93 void SDL_ATbegin( const char *testcase )
94 { 94 {
95 /* Do not open twice. */ 95 /* Do not open twice. */
96 if (at_test_msg) { 96 if (at_test_msg) {
97 SDL_ATprint( "AT testcase '%s' not closed before opening testcase '%s'", 97 SDL_ATprint( "AT testcase '%s' not closed before opening testcase '%s'\n",
98 at_test_msg, testcase ); 98 at_test_msg, testcase );
99 } 99 }
100 /* Must have a name. */ 100 /* Must have a name. */
101 if (testcase == NULL) { 101 if (testcase == NULL) {
102 SDL_ATprint( "AT testcase does not have a name."); 102 SDL_ATprint( "AT testcase does not have a name.\n");
103 } 103 }
104 at_test_msg = testcase; 104 at_test_msg = testcase;
105 } 105 }
106 106
107 107
110 */ 110 */
111 static void SDL_ATendWith( int success ) 111 static void SDL_ATendWith( int success )
112 { 112 {
113 /* Make sure initialized. */ 113 /* Make sure initialized. */
114 if (at_test_msg == NULL) { 114 if (at_test_msg == NULL) {
115 SDL_ATprint("Ended testcase without initializing."); 115 SDL_ATprint("Ended testcase without initializing.\n");
116 return; 116 return;
117 } 117 }
118 118
119 /* Mark as success or failure. */ 119 /* Mark as success or failure. */
120 if (success) 120 if (success)
132 */ 132 */
133 int SDL_ATassert( const char *msg, int condition ) 133 int SDL_ATassert( const char *msg, int condition )
134 { 134 {
135 /* Condition failed. */ 135 /* Condition failed. */
136 if (!condition) { 136 if (!condition) {
137 SDL_ATprint( "%s [%s] : %s", at_suite_msg, at_test_msg, msg ); 137 SDL_ATprint( "%s [%s] : %s\n", at_suite_msg, at_test_msg, msg );
138 SDL_ATendWith(0); 138 SDL_ATendWith(0);
139 } 139 }
140 return !condition; 140 return !condition;
141 } 141 }
142 142