diff options
-rw-r--r-- | Makefile | 4 | ||||
-rw-r--r-- | README.md | 2 | ||||
-rw-r--r-- | example.c | 4 | ||||
-rw-r--r-- | minctest.c (renamed from cstest.c) | 16 | ||||
-rw-r--r-- | minctest.h (renamed from cstest.h) | 30 |
5 files changed, 28 insertions, 28 deletions
@@ -1,7 +1,7 @@ CC=gcc CFLAGS=-O3 -DEPS=cstest.h -OBJS=example.o cstest.o +DEPS=minctest.h +OBJS=example.o minctest.o %.o: %.c $(DEPS) $(CC) -c -o $@ $< $(CFLAGS) @@ -1,4 +1,4 @@ -# CSTest +# MinCTest Minimalistic C unit test framework. @@ -16,10 +16,10 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include <stddef.h> -#include "cstest.h" +#include "minctest.h" int main(void) { - cstester* tester = test_initialize(); + tester* tester = test_initialize(); tester->show_pass = false; test_true(tester, 1 == 1, "1 = 1"); @@ -1,5 +1,5 @@ /** - * CSTest - Minimalistic C unit test framework + * MinCTest - Minimalistic C unit test framework * Copyright (C) 2015 Camil Staps * This program is free software: you can redistribute it and/or modify @@ -18,15 +18,15 @@ #include <stdio.h> #include <malloc.h> #include <stdlib.h> -#include "cstest.h" +#include "minctest.h" // Colours for terminal output #define KRED "\x1B[31m" #define KGRN "\x1B[32m" #define RESET "\x1B[0m" -cstester* test_initialize(void) { - cstester* test = malloc(sizeof(cstester)); +tester* test_initialize(void) { + tester* test = malloc(sizeof(tester)); if (test == NULL) return NULL; test->passed = 0; test->failed = 0; @@ -34,7 +34,7 @@ cstester* test_initialize(void) { return test; } -void test_wrapup(cstester* tester) { +void test_wrapup(tester* tester) { if (tester->failed == 0) { printf(KGRN "\nAll tests passed (%d)\n" RESET, tester->passed); } else { @@ -43,17 +43,17 @@ void test_wrapup(cstester* tester) { } } -void test_destroy(cstester* tester) { +void test_destroy(tester* tester) { free(tester); } -void test_exit(cstester* tester) { +void test_exit(tester* tester) { bool all_passed = tester->failed == 0; test_destroy(tester); exit(all_passed ? 0 : -1); } -void test_true(cstester* tester, bool check, const char* text) { +void test_true(tester* tester, bool check, const char* text) { if (!check || tester->show_pass) { printf(check ? KGRN : KRED); printf(check ? "Test passed" : "Test failed"); @@ -1,5 +1,5 @@ /** - * CSTest - Minimalistic C unit test framework + * MinCTest - Minimalistic C unit test framework * Copyright (C) 2015 Camil Staps * This program is free software: you can redistribute it and/or modify @@ -22,17 +22,17 @@ typedef struct { 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 -} cstester; +} tester; /** * Initialize a tester struct * - * This allocates a cstester on the heap. Don't forget to call test_destroy to + * This allocates a tester on the heap. Don't forget to call test_destroy to * free that memory. * * @return a struct on the heap for use in the other test_* functions */ -cstester* test_initialize(void); +tester* test_initialize(void); /** * Show summarised data about the tester @@ -40,39 +40,39 @@ cstester* test_initialize(void); * Shows a green message when all tests passed, otherwise a red message that * some failed. Shows passed/failed counts as well. * - * @param cstester* a pointer to a cstester from test_initialize + * @param tester* a pointer to a tester from test_initialize */ -void test_wrapup(cstester*); +void test_wrapup(tester*); /** - * Destroy a cstester struct + * Destroy a tester struct * * Essentially frees the memory that was allocated for the struct. * - * @param cstester* a pointer to a cstester from test_initialize + * @param tester* a pointer to a tester from test_initialize */ -void test_destroy(cstester*); +void test_destroy(tester*); /** * Exit the program with an appropriate return value * * Returns -1 if one or more tests failed, 0 otherwise. Exits the program. * - * @param cstester* a pointer to a cstester from test_initialize + * @param tester* a pointer to a tester from test_initialize * @return don't expect this to return */ -void test_exit(cstester*); +void test_exit(tester*); /** * Test for truth on a bool * * Outputs a red message for failure, and a green one for passing if - * cstester->show_pass is true. Adds this test to the summarised data in the - * cstester. + * tester->show_pass is true. Adds this test to the summarised data in the + * tester. * - * @param cstester* a pointer to a cstester from test_initialize + * @param tester* a pointer to a tester from test_initialize * @param check the boolean that should be true * @param test a custom message to show */ -void test_true(cstester* tester, bool check, const char* text); +void test_true(tester* tester, bool check, const char* text); |