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);
#else
-
size_t test_number = 0;
static int failures = 0;
{
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);
}
exit(EXIT_FAILURE);
} else {
printf("All functions tested sucessfully\n");
- exit( EXIT_SUCCESS );
+ exit(EXIT_SUCCESS);
}
}
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 */