1
0
mirror of https://github.com/weechat/weechat.git synced 2026-07-08 10:43:13 +02:00

core: move directory/file functions from wee-util.c to wee-dir.c (issue #1285)

This commit is contained in:
Sébastien Helleu
2021-04-18 21:23:14 +02:00
parent 9eecad496d
commit 269576eea2
19 changed files with 715 additions and 607 deletions
-83
View File
@@ -222,89 +222,6 @@ TEST(CoreUtil, ParseDelay)
LONGS_EQUAL(123 * 1000 * 60 * 60, util_parse_delay ("123h", 1000));
}
/*
* Tests functions:
* util_mkdir_home
* util_mkdir
* util_mkdir_parents
*/
TEST(CoreUtil, Mkdir)
{
/* TODO: write tests */
}
/*
* Tests functions:
* util_exec_on_files
*/
TEST(CoreUtil, ExecOnFiles)
{
/* TODO: write tests */
}
/*
* Tests functions:
* util_search_full_lib_name
*/
TEST(CoreUtil, LibName)
{
/* TODO: write tests */
}
/*
* Tests functions:
* util_file_get_content
*/
TEST(CoreUtil, FileGetContent)
{
char *path, *content, *content_read;
const char *content_small = "line 1\nline 2\nend";
int length, i;
FILE *f;
/* file not found */
POINTERS_EQUAL(NULL, util_file_get_content (NULL));
POINTERS_EQUAL(NULL, util_file_get_content (""));
POINTERS_EQUAL(NULL, util_file_get_content ("/tmp/does/not/exist.xyz"));
path = string_eval_path_home ("%h/test_file.txt", NULL, NULL, NULL);
/* small file */
length = strlen (content_small);
f = fopen (path, "wb");
CHECK(f);
LONGS_EQUAL(length, fwrite (content_small, 1, length, f));
fclose (f);
content_read = util_file_get_content (path);
STRCMP_EQUAL(content_small, content_read);
free (content_read);
unlink (path);
/* bigger file: 26 lines of 5000 bytes */
length = 26 * 5001;
content = (char *)malloc (length + 1);
CHECK(content);
for (i = 0; i < 26; i++)
{
memset (content + (i * 5001), 'a' + i, 5000);
content[(i * 5001) + 5000] = '\n';
}
content[26 * 5001] = '\0';
f = fopen (path, "wb");
CHECK(f);
LONGS_EQUAL(length, fwrite (content, 1, length, f));
fclose (f);
content_read = util_file_get_content (path);
STRCMP_EQUAL(content, content_read);
free (content_read);
unlink (path);
free (content);
}
/*
* Tests functions:
* util_version_number