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

60 lines
1.0 KiB
C

#include <check.h>
#include "../src/file_t.h"
START_TEST(test_file_init)
{
file_t *f;
exception_t *e = NULL;
f = file_init ("samples/1.txt", e, NULL);
ck_assert_ptr_ne (f, NULL);
ck_assert_ptr_eq (e, NULL);
file_close (f);
}
END_TEST
START_TEST(test_file_md5)
{
file_t *f;
exception_t *e = NULL;
f = file_init("samples/1.txt", e, NULL);
file_md5_gen (f, e);
ck_assert_ptr_eq (e, NULL);
file_md5_str (f, e);
ck_assert_ptr_eq (e, NULL);
ck_assert_str_eq (f->hash_str, "492ff087b26577237c576e7ad409064e");
file_close (f);
}
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;
}
int
main(void)
{
int number_failed;
Suite *s;
SRunner *sr;
s = file_t_suite();
sr = srunner_create(s);
srunner_run_all(sr, CK_VERBOSE);
number_failed = srunner_ntests_failed(sr);
srunner_free(sr);
return number_failed;
}