aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCamil Staps2016-08-28 19:25:33 +0200
committerCamil Staps2016-08-28 19:25:33 +0200
commitb402236707202a0341abe740974dbf22ec38fa41 (patch)
tree1dae45afa18805a5b0f2a81e30f3fb4fc3a4d079
parentMerge pull request #1 from dopefishh/master (diff)
pedantic
-rw-r--r--example.c3
-rw-r--r--minctest.c10
-rw-r--r--minctest.h14
3 files changed, 15 insertions, 12 deletions
diff --git a/example.c b/example.c
index 170b200..6bada95 100644
--- a/example.c
+++ b/example.c
@@ -30,5 +30,6 @@ int main(void) {
test_wrapup(tester);
test_exit(tester);
-}
+ return 0;
+}
diff --git a/minctest.c b/minctest.c
index 2157bd1..45fb1be 100644
--- a/minctest.c
+++ b/minctest.c
@@ -20,7 +20,7 @@
#include "minctest.h"
-// Colours for terminal output
+/* Colours for terminal output */
#define KRED "\x1B[31m"
#define KGRN "\x1B[32m"
#define RESET "\x1B[0m"
@@ -39,9 +39,10 @@ struct tester *test_initialize() {
void test_wrapup(struct tester* tester) {
struct timeval end;
+ float time, used;
gettimeofday(&end, NULL);
- float time = (end.tv_usec - tester->created.tv_usec) / 1000.0;
- float used = (tester->used) / 1000.0;
+ time = (end.tv_usec - tester->created.tv_usec) / 1000.0;
+ used = (tester->used) / 1000.0;
if (tester->failed == 0) {
printf(KGRN "\nAll tests passed (%d) [%.3fs / %.3fs]\n" RESET,
@@ -70,9 +71,10 @@ void test_start_timer(struct tester *tester) {
void test_true(struct tester *tester, bool check, const char* text) {
struct timeval end;
+ float time;
gettimeofday(&end, NULL);
tester->used += end.tv_usec - tester->start_last_test.tv_usec;
- float time = (end.tv_usec - tester->start_last_test.tv_usec) / 1000.0;
+ time = (end.tv_usec - tester->start_last_test.tv_usec) / 1000.0;
if (!check || tester->show_pass) {
puts(check ? KGRN : KRED);
diff --git a/minctest.h b/minctest.h
index 071a5af..362afad 100644
--- a/minctest.h
+++ b/minctest.h
@@ -23,12 +23,12 @@
#include <sys/time.h>
struct tester {
- uint16_t passed; // Number of passed tests
- uint16_t failed; // Number of failed tests
- bool show_pass; // Whether or not to print a message when a test passes
- struct timeval start_last_test; // Time last test was started
- struct timeval created; // Time this was created
- __suseconds_t used; // usecs used for tests
+ uint16_t passed; /* Number of passed tests */
+ uint16_t failed; /* Number of failed tests */
+ bool show_pass; /* Whether or not to print a message when a test passes */
+ struct timeval start_last_test; /* Time last test was started */
+ struct timeval created; /* Time this was created */
+ __suseconds_t used; /* usecs used for tests */
};
/**
@@ -88,4 +88,4 @@ void test_start_timer(struct tester *);
*/
void test_true(struct tester *tester, bool check, const char* text);
-#endif // MINCTEST_H
+#endif /* MINCTEST_H */