8f72eabf1f
* Add filepath_t enum key * file_init writes path according to filepath_t * file_init does NOT correctly write path FILEPATH_ABSOLUTE * file_init parameters changed to include filepath_t and no longer includes "ENV" string * file_close only now frees hash_str when non null ptr * calibrate verify function updated to use correct file_init parameters
60 lines
1.0 KiB
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", FILEPATH_RELATIVE, e);
|
|
ck_assert_ptr_nonnull (f);
|
|
ck_assert_ptr_null (e);
|
|
file_close (f);
|
|
}
|
|
END_TEST
|
|
|
|
START_TEST(test_file_md5)
|
|
{
|
|
file_t *f;
|
|
exception_t *e = NULL;
|
|
f = file_init("samples/1.txt", FILEPATH_RELATIVE, e);
|
|
file_md5_gen (f, e);
|
|
ck_assert_ptr_null (e);
|
|
file_md5_str (f, e);
|
|
ck_assert_ptr_null (e);
|
|
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;
|
|
}
|