tests: path_len - fix assertions, now test should fail

Signed-off-by: Yury V. Zaytsev <yury@shurup.com>
This commit is contained in:
Yury V. Zaytsev 2024-09-11 19:34:38 +02:00
parent 07e24c0289
commit 319598df41

View File

@ -74,25 +74,30 @@ teardown (void)
static const struct test_path_length_ds static const struct test_path_length_ds
{ {
const char *input_path; const char *input_path;
const size_t expected_length; const size_t expected_length_element_encoding;
const size_t expected_length_terminal_encoding;
} test_path_length_ds[] = } test_path_length_ds[] =
{ {
{ /* 0. */ { /* 0. */
NULL, NULL,
0,
0 0
}, },
{ /* 1. */ { /* 1. */
"/", "/",
1,
1 1
}, },
{ /* 2. */ { /* 2. */
"/тестовый/путь", "/тестовый/путь",
26,
26 26
}, },
#ifdef HAVE_CHARSET #ifdef HAVE_CHARSET
{ /* 3. */ { /* 3. */
"/#enc:KOI8-R/тестовый/путь", "/#enc:KOI8-R/тестовый/путь",
38 14,
38,
}, },
#endif /* HAVE_CHARSET */ #endif /* HAVE_CHARSET */
}; };
@ -105,15 +110,19 @@ START_PARAMETRIZED_TEST (test_path_length, test_path_length_ds)
{ {
/* given */ /* given */
vfs_path_t *vpath; vfs_path_t *vpath;
size_t actual_length; char *path;
size_t actual_length_terminal_encoding, actual_length_element_encoding;
vpath = vfs_path_from_str (data->input_path); vpath = vfs_path_from_str (data->input_path);
path = vpath != NULL ? vfs_path_get_by_index (vpath, 0)->path : NULL;
/* when */ /* when */
actual_length = vfs_path_len (vpath); actual_length_terminal_encoding = vfs_path_len (vpath);
actual_length_element_encoding = path != NULL ? strlen (path) : 0;
/* then */ /* then */
ck_assert_int_eq (actual_length, data->expected_length); ck_assert_int_eq (actual_length_terminal_encoding, data->expected_length_terminal_encoding);
ck_assert_int_eq (actual_length_element_encoding, data->expected_length_element_encoding);
vfs_path_free (vpath, TRUE); vfs_path_free (vpath, TRUE);
} }