Added more tests
This commit is contained in:
@@ -1,13 +1,24 @@
|
||||
#include "test_tensor.h"
|
||||
#include <stdint.h>
|
||||
|
||||
void test_run_all(void)
|
||||
void test_tensor_run_all(void)
|
||||
{
|
||||
int i;
|
||||
void (*test_func[NUM_TEST_FUNC])(void) = {
|
||||
&test_tensor_is_empty,
|
||||
&test_tensor_is_equal,
|
||||
&test_tensor_check_size,
|
||||
&test_tensor_set_size,
|
||||
&test_tensor_set,
|
||||
&test_tensor_get,
|
||||
&test_tensor_init_one,
|
||||
&test_tensor_init_zero,
|
||||
&test_tensor_init_rand,
|
||||
&test_tensor_cpy,
|
||||
&test_tensor_add_inplace,
|
||||
&test_tensor_sub_inplace,
|
||||
&test_tensor_add,
|
||||
&test_tensor_sub,
|
||||
};
|
||||
|
||||
printf("\n### Running tests... ###\n\n");
|
||||
@@ -17,6 +28,19 @@ void test_run_all(void)
|
||||
printf("\n### %i functions tested. ###\n\n", NUM_TEST_FUNC);
|
||||
}
|
||||
|
||||
void test_tensor_is_empty(void)
|
||||
{
|
||||
/* Depends on tensor_init_zero */
|
||||
uint32_t s[4] = {2, 5, 3, 7};
|
||||
tensor t1 = tensor_new();
|
||||
tensor t2 = tensor_new();
|
||||
|
||||
tensor_init_zero(t2, s, 4);
|
||||
|
||||
tensor_assert(tensor_is_empty(t1), "(empty tensor not detected)");
|
||||
tensor_assert(!tensor_is_empty(t2), "(non empty tensor not detected)");
|
||||
}
|
||||
|
||||
void test_tensor_is_equal(void)
|
||||
{
|
||||
/* Depends on tensor_cpy, tensor_is_equal, tensor_init_zero, tensor_init_rand */
|
||||
@@ -35,6 +59,24 @@ void test_tensor_is_equal(void)
|
||||
tensor_destroy(t2);
|
||||
}
|
||||
|
||||
void test_tensor_check_size(void)
|
||||
{
|
||||
uint32_t size[] = {3, 2, 5, 0};
|
||||
tensor_assert(_tensor_check_size(size, 3), "(valid size declared as invalid)");
|
||||
tensor_assert(!_tensor_check_size(size, 5), "(no dimension should be 0)");
|
||||
tensor_assert(_tensor_check_size(size, 0), "(rank can be 0)");
|
||||
tensor_assert(!_tensor_check_size(size, -3), "(rank should be non negative)");
|
||||
}
|
||||
|
||||
void test_tensor_set_size(void)
|
||||
{
|
||||
uint32_t size[] = {3, 2, 7};
|
||||
tensor t = tensor_new();
|
||||
|
||||
tensor_assert(_tensor_set_size(t, size, 3), "(size should be set without error)");
|
||||
tensor_assert(t->num_elem == 3 * 2 * 7, "(wrong number of elements)");
|
||||
}
|
||||
|
||||
void test_tensor_set(void)
|
||||
{
|
||||
/* Depends on tensor_is_equal, tensor_init_zero, tensor_init_rand */
|
||||
@@ -63,7 +105,7 @@ void test_tensor_set(void)
|
||||
void test_tensor_get(void)
|
||||
{
|
||||
/* Depends on tensor_is_equal, tensor_set, tensor_init_zero, tensor_init_rand */
|
||||
uint8_t status;
|
||||
bool status;
|
||||
uint32_t s[4] = {2, 5, 3, 7};
|
||||
uint32_t index[4] = {0, 0, 0, 0};
|
||||
tensor t1 = tensor_new();
|
||||
@@ -87,3 +129,43 @@ void test_tensor_get(void)
|
||||
tensor_destroy(t2);
|
||||
}
|
||||
|
||||
void test_tensor_init_one(void)
|
||||
{
|
||||
//TODO
|
||||
}
|
||||
|
||||
void test_tensor_init_zero(void)
|
||||
{
|
||||
//TODO
|
||||
}
|
||||
|
||||
void test_tensor_init_rand(void)
|
||||
{
|
||||
//TODO
|
||||
}
|
||||
|
||||
void test_tensor_cpy(void)
|
||||
{
|
||||
//TODO
|
||||
}
|
||||
|
||||
void test_tensor_add_inplace(void)
|
||||
{
|
||||
//TODO
|
||||
}
|
||||
|
||||
void test_tensor_sub_inplace(void)
|
||||
{
|
||||
//TODO
|
||||
}
|
||||
|
||||
void test_tensor_add(void)
|
||||
{
|
||||
//TODO
|
||||
}
|
||||
|
||||
void test_tensor_sub(void)
|
||||
{
|
||||
//TODO
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user