aboutsummaryrefslogtreecommitdiff
path: root/cstest.c
diff options
context:
space:
mode:
authorCamil Staps2015-12-02 22:23:32 +0100
committerCamil Staps2015-12-02 22:23:32 +0100
commit2eec4c98cc47835ff410676a00c7e1796ff2da54 (patch)
tree2eab519f2fcdd27b2ede172534cf6161624f15ab /cstest.c
parentFirst version (diff)
Rename CSTest to MinCTest; is more to-the-point
Diffstat (limited to 'cstest.c')
-rw-r--r--cstest.c67
1 files changed, 0 insertions, 67 deletions
diff --git a/cstest.c b/cstest.c
deleted file mode 100644
index 1b2a3ef..0000000
--- a/cstest.c
+++ /dev/null
@@ -1,67 +0,0 @@
-/**
- * CSTest - Minimalistic C unit test framework
- * Copyright (C) 2015 Camil Staps
-
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-#include <stdio.h>
-#include <malloc.h>
-#include <stdlib.h>
-#include "cstest.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));
- if (test == NULL) return NULL;
- test->passed = 0;
- test->failed = 0;
- test->show_pass = true;
- return test;
-}
-
-void test_wrapup(cstester* tester) {
- if (tester->failed == 0) {
- printf(KGRN "\nAll tests passed (%d)\n" RESET, tester->passed);
- } else {
- printf(KRED "\n%d test%s failed" RESET " (%d passed)\n",
- tester->failed, tester->failed > 1 ? "s" : "", tester->passed);
- }
-}
-
-void test_destroy(cstester* tester) {
- free(tester);
-}
-
-void test_exit(cstester* 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) {
- if (!check || tester->show_pass) {
- printf(check ? KGRN : KRED);
- printf(check ? "Test passed" : "Test failed");
- if (text != NULL)
- printf(": %s", text);
- printf("\n" RESET);
- }
-
- *(check ? &tester->passed : &tester->failed) += 1;
-}
-