|
|
|
@ -374,6 +374,140 @@ static void test_iso_2_fileid()
|
|
|
|
|
free(file);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void test_iso_r_id()
|
|
|
|
|
{
|
|
|
|
|
char *file;
|
|
|
|
|
|
|
|
|
|
/* force dot */
|
|
|
|
|
file = iso_r_id("file1", 30, 0, 1);
|
|
|
|
|
CU_ASSERT_STRING_EQUAL(file, "FILE1.");
|
|
|
|
|
free(file);
|
|
|
|
|
|
|
|
|
|
/* and not */
|
|
|
|
|
file = iso_r_id("file1", 30, 0, 0);
|
|
|
|
|
CU_ASSERT_STRING_EQUAL(file, "FILE1");
|
|
|
|
|
free(file);
|
|
|
|
|
|
|
|
|
|
/* allow lowercase */
|
|
|
|
|
file = iso_r_id("file1", 30, 1, 0);
|
|
|
|
|
CU_ASSERT_STRING_EQUAL(file, "file1");
|
|
|
|
|
free(file);
|
|
|
|
|
file = iso_r_id("file1", 30, 2, 0);
|
|
|
|
|
CU_ASSERT_STRING_EQUAL(file, "file1");
|
|
|
|
|
free(file);
|
|
|
|
|
|
|
|
|
|
/* force d-char and dot */
|
|
|
|
|
file = iso_r_id("fILe1", 30, 0, 1);
|
|
|
|
|
CU_ASSERT_STRING_EQUAL(file, "FILE1.");
|
|
|
|
|
free(file);
|
|
|
|
|
/* force d-char but not dot */
|
|
|
|
|
file = iso_r_id("fILe1", 30, 0, 0);
|
|
|
|
|
CU_ASSERT_STRING_EQUAL(file, "FILE1");
|
|
|
|
|
free(file);
|
|
|
|
|
/* allow lower case but force dot */
|
|
|
|
|
file = iso_r_id("fILe1", 30, 1, 1);
|
|
|
|
|
CU_ASSERT_STRING_EQUAL(file, "fILe1.");
|
|
|
|
|
free(file);
|
|
|
|
|
|
|
|
|
|
file = iso_r_id("FILE1", 30, 0, 1);
|
|
|
|
|
CU_ASSERT_STRING_EQUAL(file, "FILE1.");
|
|
|
|
|
free(file);
|
|
|
|
|
file = iso_r_id(".EXT", 30, 0, 1);
|
|
|
|
|
CU_ASSERT_STRING_EQUAL(file, ".EXT");
|
|
|
|
|
free(file);
|
|
|
|
|
file = iso_r_id(".EXT", 30, 1, 0);
|
|
|
|
|
CU_ASSERT_STRING_EQUAL(file, ".EXT");
|
|
|
|
|
free(file);
|
|
|
|
|
|
|
|
|
|
file = iso_r_id("file.ext", 30, 0, 1);
|
|
|
|
|
CU_ASSERT_STRING_EQUAL(file, "FILE.EXT");
|
|
|
|
|
free(file);
|
|
|
|
|
|
|
|
|
|
/* not force dot is the same in this case */
|
|
|
|
|
file = iso_r_id("fiLE.ext", 30, 0, 0);
|
|
|
|
|
CU_ASSERT_STRING_EQUAL(file, "FILE.EXT");
|
|
|
|
|
free(file);
|
|
|
|
|
file = iso_r_id("fiLE.ext", 30, 2, 0);
|
|
|
|
|
CU_ASSERT_STRING_EQUAL(file, "fiLE.ext");
|
|
|
|
|
free(file);
|
|
|
|
|
|
|
|
|
|
file = iso_r_id("file.EXt", 30, 0, 1);
|
|
|
|
|
CU_ASSERT_STRING_EQUAL(file, "FILE.EXT");
|
|
|
|
|
free(file);
|
|
|
|
|
file = iso_r_id("FILE.EXT", 30, 0, 1);
|
|
|
|
|
CU_ASSERT_STRING_EQUAL(file, "FILE.EXT");
|
|
|
|
|
free(file);
|
|
|
|
|
|
|
|
|
|
file = iso_r_id("31 characters filename.extensio", 30, 0, 1);
|
|
|
|
|
CU_ASSERT_STRING_EQUAL(file, "31_CHARACTERS_FILENAME.EXTENSIO");
|
|
|
|
|
free(file);
|
|
|
|
|
file = iso_r_id("32 characters filename.extension", 30, 0, 1);
|
|
|
|
|
CU_ASSERT_STRING_EQUAL(file, "32_CHARACTERS_FILENAME.EXTENSIO");
|
|
|
|
|
free(file);
|
|
|
|
|
|
|
|
|
|
/* allow lowercase */
|
|
|
|
|
file = iso_r_id("31 characters filename.extensio", 30, 1, 1);
|
|
|
|
|
CU_ASSERT_STRING_EQUAL(file, "31_characters_filename.extensio");
|
|
|
|
|
free(file);
|
|
|
|
|
|
|
|
|
|
/* and all characters */
|
|
|
|
|
file = iso_r_id("31 characters filename.extensio", 30, 2, 1);
|
|
|
|
|
CU_ASSERT_STRING_EQUAL(file, "31 characters filename.extensio");
|
|
|
|
|
free(file);
|
|
|
|
|
|
|
|
|
|
file = iso_r_id("more than 30 characters filename.extension", 30, 0, 0);
|
|
|
|
|
CU_ASSERT_STRING_EQUAL(file, "MORE_THAN_30_CHARACTERS_FIL.EXT");
|
|
|
|
|
|
|
|
|
|
/* incrementing the size... */
|
|
|
|
|
file = iso_r_id("more than 30 characters filename.extension", 35, 0, 0);
|
|
|
|
|
CU_ASSERT_STRING_EQUAL(file, "MORE_THAN_30_CHARACTERS_FILENAME.EXT");
|
|
|
|
|
file = iso_r_id("more than 30 characters filename.extension", 36, 0, 0);
|
|
|
|
|
CU_ASSERT_STRING_EQUAL(file, "MORE_THAN_30_CHARACTERS_FILENAME.EXTE");
|
|
|
|
|
|
|
|
|
|
free(file);
|
|
|
|
|
file = iso_r_id("file.bigext", 30, 1, 0);
|
|
|
|
|
CU_ASSERT_STRING_EQUAL(file, "file.bigext");
|
|
|
|
|
free(file);
|
|
|
|
|
file = iso_r_id(".bigext", 30, 0, 0);
|
|
|
|
|
CU_ASSERT_STRING_EQUAL(file, ".BIGEXT");
|
|
|
|
|
|
|
|
|
|
/* "strange" characters */
|
|
|
|
|
file = iso_r_id("file<:a.ext", 30, 0, 0);
|
|
|
|
|
CU_ASSERT_STRING_EQUAL(file, "FILE__A.EXT");
|
|
|
|
|
free(file);
|
|
|
|
|
file = iso_r_id("file<:a.ext", 30, 1, 0);
|
|
|
|
|
CU_ASSERT_STRING_EQUAL(file, "file__a.ext");
|
|
|
|
|
free(file);
|
|
|
|
|
file = iso_r_id("file<:a.ext", 30, 2, 0);
|
|
|
|
|
CU_ASSERT_STRING_EQUAL(file, "file<:a.ext");
|
|
|
|
|
free(file);
|
|
|
|
|
|
|
|
|
|
/* multiple dots */
|
|
|
|
|
file = iso_r_id("fi.le.a.ext", 30, 0, 0);
|
|
|
|
|
CU_ASSERT_STRING_EQUAL(file, "FI_LE_A.EXT");
|
|
|
|
|
free(file);
|
|
|
|
|
file = iso_r_id("fi.le.a.ext", 30, 1, 0);
|
|
|
|
|
CU_ASSERT_STRING_EQUAL(file, "fi_le_a.ext");
|
|
|
|
|
free(file);
|
|
|
|
|
file = iso_r_id("fi.le.a.ext", 30, 2, 0);
|
|
|
|
|
CU_ASSERT_STRING_EQUAL(file, "fi.le.a.ext");
|
|
|
|
|
|
|
|
|
|
file = iso_r_id("file.<:a", 30, 0, 0);
|
|
|
|
|
CU_ASSERT_STRING_EQUAL(file, "FILE.__A");
|
|
|
|
|
free(file);
|
|
|
|
|
file = iso_r_id("file<:a.--a", 30, 0, 0);
|
|
|
|
|
CU_ASSERT_STRING_EQUAL(file, "FILE__A.__A");
|
|
|
|
|
free(file);
|
|
|
|
|
|
|
|
|
|
file = iso_r_id(".file.bigext", 30, 0, 0);
|
|
|
|
|
CU_ASSERT_STRING_EQUAL(file, "_FILE.BIGEXT");
|
|
|
|
|
free(file);
|
|
|
|
|
|
|
|
|
|
file = iso_r_id(".file.bigext", 30, 2, 0);
|
|
|
|
|
CU_ASSERT_STRING_EQUAL(file, ".file.bigext");
|
|
|
|
|
free(file);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void test_iso_rbtree_insert()
|
|
|
|
|
{
|
|
|
|
|
int res;
|
|
|
|
@ -509,6 +643,7 @@ void add_util_suite()
|
|
|
|
|
CU_add_test(pSuite, "iso_2_dirid()", test_iso_2_dirid);
|
|
|
|
|
CU_add_test(pSuite, "iso_1_fileid()", test_iso_1_fileid);
|
|
|
|
|
CU_add_test(pSuite, "iso_2_fileid()", test_iso_2_fileid);
|
|
|
|
|
CU_add_test(pSuite, "iso_r_id()", test_iso_r_id);
|
|
|
|
|
CU_add_test(pSuite, "iso_rbtree_insert()", test_iso_rbtree_insert);
|
|
|
|
|
CU_add_test(pSuite, "iso_htable_put/get()", test_iso_htable_put_get);
|
|
|
|
|
}
|
|
|
|
|