mirror of
https://github.com/weechat/weechat.git
synced 2026-06-26 12:56:37 +02:00
core: remove trailing directory separators in home directories (closes #2070)
This commit is contained in:
@@ -29,6 +29,8 @@ extern "C"
|
||||
#include <sys/time.h>
|
||||
#include "src/core/wee-dir.h"
|
||||
#include "src/core/wee-string.h"
|
||||
|
||||
extern void dir_remove_trailing_separators (char *path);
|
||||
}
|
||||
|
||||
TEST_GROUP(CoreDir)
|
||||
@@ -162,6 +164,42 @@ TEST(CoreDir, SetHomePath)
|
||||
/* TODO: write tests */
|
||||
}
|
||||
|
||||
/*
|
||||
* Tests functions:
|
||||
* dir_remove_trailing_separators
|
||||
*/
|
||||
|
||||
TEST(CoreDir, RemoveTrailingSeparators)
|
||||
{
|
||||
char path[128];
|
||||
|
||||
dir_remove_trailing_separators (NULL);
|
||||
|
||||
snprintf (path, sizeof (path), "");
|
||||
dir_remove_trailing_separators (path);
|
||||
STRCMP_EQUAL("", path);
|
||||
|
||||
snprintf (path, sizeof (path), "/");
|
||||
dir_remove_trailing_separators (path);
|
||||
STRCMP_EQUAL("/", path);
|
||||
|
||||
snprintf (path, sizeof (path), "///");
|
||||
dir_remove_trailing_separators (path);
|
||||
STRCMP_EQUAL("/", path);
|
||||
|
||||
snprintf (path, sizeof (path), "/tmp");
|
||||
dir_remove_trailing_separators (path);
|
||||
STRCMP_EQUAL("/tmp", path);
|
||||
|
||||
snprintf (path, sizeof (path), "/tmp/");
|
||||
dir_remove_trailing_separators (path);
|
||||
STRCMP_EQUAL("/tmp", path);
|
||||
|
||||
snprintf (path, sizeof (path), "/tmp///////");
|
||||
dir_remove_trailing_separators (path);
|
||||
STRCMP_EQUAL("/tmp", path);
|
||||
}
|
||||
|
||||
/*
|
||||
* Tests functions:
|
||||
* dir_create_home_temp_dir
|
||||
|
||||
Reference in New Issue
Block a user