From 30915027d6cdbf51c230c2fa518772d8613f4c9d Mon Sep 17 00:00:00 2001 From: Elias Kohout Date: Wed, 15 Mar 2023 16:22:52 +0100 Subject: [PATCH] Removed files for the restructuring. --- main.c | 9 ----- test_tensor.c | 91 --------------------------------------------------- test_tensor.h | 43 ------------------------ 3 files changed, 143 deletions(-) delete mode 100644 main.c delete mode 100644 test_tensor.c delete mode 100644 test_tensor.h diff --git a/main.c b/main.c deleted file mode 100644 index c163b1b..0000000 --- a/main.c +++ /dev/null @@ -1,9 +0,0 @@ -#include "tensor.h" -#include "test_tensor.h" - -int main(void) -{ - test_run_all(); - return 0; -} - diff --git a/test_tensor.c b/test_tensor.c deleted file mode 100644 index 065aafd..0000000 --- a/test_tensor.c +++ /dev/null @@ -1,91 +0,0 @@ -#include "test_tensor.h" - -void test_run_all(void) -{ - int i; - void (*test_func[NUM_TEST_FUNC])() = { - &test_tensor_is_equal, - &test_tensor_set, - &test_tensor_get, - }; - - printf("\n### Running tests... ###\n\n"); - for(i = 0; i < NUM_TEST_FUNC; i++) { - test_func[i](); - } - printf("\n### %i functions tested. ###\n\n", NUM_TEST_FUNC); -} - -void test_tensor_is_equal(void) -{ - /* Depends on tensor_cpy, tensor_is_equal, tensor_init_zero, tensor_init_rand */ - int status; - int s[4] = {2, 5, 3, 7}; - tensor t1 = tensor_new(); - tensor t2 = tensor_new(); - - tensor_init_zero(t1, 4, s); - tensor_init_one(t2, 4, s); - tensor_assert_ne(t1, t2); - - tensor_init_rand(t1, 4, s, 30); - tensor_cpy(t2, t1); - - tensor_assert_eq(t1, t2); - tensor_destroy(t1); - tensor_destroy(t2); -} - -void test_tensor_set(void) -{ - /* Depends on tensor_is_equal, tensor_init_zero, tensor_init_rand */ - int status; - int s[4] = {2, 5, 3, 7}; - int index[4] = {0, 0, 0, 0}; - tensor t1 = tensor_new(); - tensor t2 = tensor_new(); - - tensor_init_rand(t1, 4, s, 30); - tensor_init_zero(t2, 4, s); - - for (index[0] = 0; index[0] < s[0]; ++index[0]) { - for (index[1] = 0; index[1] < s[1]; ++index[1]) { - for (index[2] = 0; index[2] < s[2]; ++index[2]) { - for (index[3] = 0; index[3] < s[3]; ++index[3]) { - tensor_assert(tensor_set(t1, index, 0), "mute"); - } - } - } - } - tensor_assert_eq(t1, t2); - tensor_destroy(t1); - tensor_destroy(t2); -} - -void test_tensor_get(void) -{ - /* Depends on tensor_is_equal, tensor_set, tensor_init_zero, tensor_init_rand */ - int status; - int s[4] = {2, 5, 3, 7}; - int index[4] = {0, 0, 0, 0}; - tensor t1 = tensor_new(); - tensor t2 = tensor_new(); - - tensor_init_rand(t1, 4, s, 30); - tensor_init_zero(t2, 4, s); - - for (index[0] = 0; index[0] < s[0]; ++index[0]) { - for (index[1] = 0; index[1] < s[1]; ++index[1]) { - for (index[2] = 0; index[2] < s[2]; ++index[2]) { - for (index[3] = 0; index[3] < s[3]; ++index[3]) { - tensor_set(t2, index, tensor_get(t1, index, &status)); - tensor_assert(status, "mute"); - } - } - } - } - tensor_assert_eq(t1, t2); - tensor_destroy(t1); - tensor_destroy(t2); -} - diff --git a/test_tensor.h b/test_tensor.h deleted file mode 100644 index 10f6941..0000000 --- a/test_tensor.h +++ /dev/null @@ -1,43 +0,0 @@ -#ifndef _TEST_TENSOR_H_INCLUDED_ -#define _TEST_TENSOR_H_INCLUDED_ - -#include -#include -#include -#include "tensor.h" - -#define NUM_TEST_FUNC 3 - -#define ANSI_COLOR_GREEN "\x1b[32m" -#define ANSI_COLOR_RESET "\x1b[0m" -#define ANSI_COLOR_RED "\x1b[31m" -#define ANSI_COLOR_YELLOW "\x1b[33m" -#define ANSI_COLOR_BLUE "\x1b[34m" - -#define tensor_assert(X, msg) do{ \ - FILE* stream = stderr; \ - if (!X) { \ - fputs(ANSI_COLOR_RED "Assertion failed: " ANSI_COLOR_RESET, stream); \ - fprintf(stream, \ - "function %s, file %s, line %i. ", __func__, __FILE__, __LINE__); \ - fputs(msg, stream); \ - fputc('\n', stream); \ - } else if (strcmp(msg, "mute") != 0) { \ - fputs(ANSI_COLOR_GREEN "Assertion succeeded: " ANSI_COLOR_RESET, stream); \ - fprintf(stream, \ - "function %s, file %s, line %i. ", __func__, __FILE__, __LINE__); \ - fputc('\n', stream); \ - } \ -} while (0) - -#define tensor_assert_eq(X, Y) tensor_assert(tensor_is_equal((X), (Y)), "(tensor_assert_eq)") -#define tensor_assert_ne(X, Y) tensor_assert(!tensor_is_equal((X), (Y)), "(tensor_assert_ne)") - -void test_run_all(void); - -void test_tensor_is_equal(void); -void test_tensor_set(void); -void test_tensor_get(void); - -#endif -