This repository has been archived on 2021-06-27. You can view files and clone it, but cannot push or open issues or pull requests.
modetw/tests/check_file_t.c

45 lines
917 B
C
Raw Permalink Normal View History

#include "check_check.h"
2021-05-15 19:18:42 +02:00
#include "../src/file_t.h"
START_TEST(test_file_init)
{
file_t *f;
exception_t *e = exception_init();
f = file_init ("samples/1.txt", FILEPATH_RELATIVE, e);
ck_assert_ptr_nonnull (f);
ck_assert (exception_null(e));
2021-05-15 19:18:42 +02:00
file_close (f);
exception_free(e);
2021-05-15 19:18:42 +02:00
}
END_TEST
START_TEST(test_file_md5)
{
file_t *f;
exception_t *e = exception_init();
f = file_init("samples/1.txt", FILEPATH_RELATIVE, e);
2021-05-15 19:18:42 +02:00
file_md5_gen (f, e);
ck_assert (exception_null(e));
2021-05-15 19:18:42 +02:00
file_md5_str (f, e);
ck_assert (exception_null(e));
2021-05-15 19:18:42 +02:00
ck_assert_str_eq (f->hash_str, "492ff087b26577237c576e7ad409064e");
file_close (f);
exception_free(e);
2021-05-15 19:18:42 +02:00
}
Suite*
file_t_suite(void)
{
Suite *s;
TCase *tc_core;
s = suite_create ("file_t");
tc_core = tcase_create ("core");
tcase_add_test(tc_core, test_file_init);
tcase_add_test(tc_core, test_file_md5);
suite_add_tcase(s, tc_core);
return s;
}