M Makefile => Makefile +3 -1
@@ 1,4 1,6 @@
-CFLAGS?=-Wall -Werror -fsanitize=address
+.POSIX:
+
+CFLAGS?=-ansi -Werror -Wpedantic -fsanitize=address
all: check
M README.md => README.md +2 -1
@@ 1,6 1,7 @@
# PicoTest
-[](https://choosealicense.com/licenses/agpl-3.0/)
+[](https://choosealicense.com/licenses/agpl-3.0/)
+[](https://en.wikipedia.org/wiki/ANSI_C)
[](https://builds.sr.ht/~ancarda/picotest)
PicoTest was written as a learning exercise and is not meant to be a serious
M lib/framework.h => lib/framework.h +14 -8
@@ 10,6 10,8 @@
#ifndef PICOTEST_FRAMEWORK_H
#define PICOTEST_FRAMEWORK_H
+#define _POSIX_C_SOURCE 199309L
+
#include "assertions.h"
#include "private.h"
#include <assert.h>
@@ 55,11 57,13 @@
#define IT_SHOULD(test_name, test_body) \
int it_should_##test_name() \
{ \
- char* __formatted_name = \
- __str_replace_byte(__EXPAND(test_name), '_', ' '); \
+ int __assertions_before_this_test; \
+ char* __formatted_name; \
+ \
+ __formatted_name = __str_replace_byte(__EXPAND(test_name), '_', ' '); \
printf(" it should %s:", __formatted_name); \
free(__formatted_name); \
- int __assertions_before_this_test = __assertions_attempted; \
+ __assertions_before_this_test = __assertions_attempted; \
test_body if (__assertions_before_this_test == __assertions_attempted) \
{ \
__TEST_EMPTY; \
@@ 109,13 113,15 @@
#define CONCLUDE_TESTING \
do \
{ \
+ float __runtime; \
+ float __runtime_s; \
+ float __runtime_ns; \
+ \
clock_gettime(CLOCK_MONOTONIC, &__tests_concluded); \
- float __runtime_s = \
+ __runtime_s = \
((float) __tests_concluded.tv_sec - __tests_began.tv_sec); \
- float __runtime_ns = \
- (__tests_concluded.tv_nsec - __tests_began.tv_nsec); \
- float __runtime = \
- ((__runtime_s * 1000000000) + __runtime_ns) / 1000000000; \
+ __runtime_ns = (__tests_concluded.tv_nsec - __tests_began.tv_nsec); \
+ __runtime = ((__runtime_s * 1000000000) + __runtime_ns) / 1000000000; \
puts(""); \
assert(__assertions_attempted >= __assertions_succeeded); \
assert(__assertions_attempted >= 0); \
M lib/private.h => lib/private.h +1 -1
@@ 110,7 110,7 @@ char* __str_replace_byte(const char* str, const char find, const char replace)
}
}
- // Include a null terminate byte
+ /* Include a null terminate byte */
out[i] = '\0';
return out;