summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/testsuite.h39
1 files changed, 18 insertions, 21 deletions
diff --git a/test/testsuite.h b/test/testsuite.h
index 806a5c229..3465d328e 100644
--- a/test/testsuite.h
+++ b/test/testsuite.h
@@ -29,7 +29,6 @@
extern size_t test_number;
-
extern void init_testsuite(const char* testname);
extern void done_testing(void) __attribute__((noreturn));
extern void success_msg(int result, const char* command);
@@ -37,7 +36,6 @@ extern void error_msg(int result, int line, const char* file, const char* comman
#else
-
size_t test_number = 0;
static int failures = 0;
@@ -45,7 +43,7 @@ void error_msg(int result, int line, const char* file, const char* command)
{
failures++;
- printf("\nFAILED TEST %d: \n\t%s\n", test_number, command);
+ printf("\nFAILED TEST %lu: \n\t%s\n", (unsigned long)test_number, command);
printf("AT LINE: %d, FILE: %s\n\n", line, file);
}
@@ -63,7 +61,7 @@ void done_testing(void)
exit(EXIT_FAILURE);
} else {
printf("All functions tested sucessfully\n");
- exit( EXIT_SUCCESS );
+ exit(EXIT_SUCCESS);
}
}
@@ -75,43 +73,42 @@ void init_testsuite(const char* testname)
atexit(done_testing);
}
-#endif
+#endif /* __NO_TESTCODE__ */
-
-#define TEST_STRING_OUTPUT( command, expected_result ) \
+#define TEST_STRING_OUTPUT(command, expected_result) \
do { \
- int result=strcmp( command, expected_result); \
+ int result = strcmp(command, expected_result); \
test_number++; \
- if ( result == expected_result ) { \
- success_msg( result, "command"); \
+ if (result == expected_result) { \
+ success_msg(result, "command"); \
} else { \
error_msg(result, __LINE__, __FILE__, command); \
}; \
} while (0)
-
-#define TEST_NUMERIC( command, expected_result ) \
+
+#define TEST_NUMERIC(command, expected_result) \
do { \
- int result=(command); \
+ int result = (command); \
test_number++; \
- if ( result == expected_result ) { \
- success_msg( result, # command); \
+ if (result == expected_result) { \
+ success_msg(result, # command); \
} else { \
error_msg(result, __LINE__, __FILE__, # command); \
}; \
} while (0)
-
+
#define TEST(command) \
do { \
- int result=(command); \
+ int result = (command); \
test_number++; \
- if ( result == 1) { \
- success_msg( result, # command); \
+ if (result == 1) { \
+ success_msg(result, # command); \
} else { \
- error_msg(result, __LINE__, __FILE__, # command ); \
+ error_msg(result, __LINE__, __FILE__, # command); \
}; \
} while (0)
-#define STR_CMD(cmd) cmd
+#define STR_CMD(cmd) cmd
#endif /* TESTSUITE_H */