summaryrefslogtreecommitdiff
path: root/tests/unit
diff options
context:
space:
mode:
Diffstat (limited to 'tests/unit')
-rw-r--r--tests/unit/core/test-core-string.cpp20
-rw-r--r--tests/unit/plugins/test-plugin-api-info.cpp10
2 files changed, 28 insertions, 2 deletions
diff --git a/tests/unit/core/test-core-string.cpp b/tests/unit/core/test-core-string.cpp
index 2d6552a31..580fc64ce 100644
--- a/tests/unit/core/test-core-string.cpp
+++ b/tests/unit/core/test-core-string.cpp
@@ -962,7 +962,8 @@ TEST(CoreString, EvalPathHome)
{
char *home, *result;
int length_home, length_weechat_config_dir, length_weechat_data_dir;
- int length_weechat_cache_dir, length_weechat_runtime_dir;
+ int length_weechat_state_dir, length_weechat_cache_dir;
+ int length_weechat_runtime_dir;
struct t_hashtable *extra_vars, *options;
home = getenv ("HOME");
@@ -971,6 +972,7 @@ TEST(CoreString, EvalPathHome)
length_weechat_config_dir = strlen (weechat_config_dir);
length_weechat_data_dir = strlen (weechat_data_dir);
+ length_weechat_state_dir = strlen (weechat_state_dir);
length_weechat_cache_dir = strlen (weechat_cache_dir);
length_weechat_runtime_dir = strlen (weechat_runtime_dir);
@@ -1014,6 +1016,14 @@ TEST(CoreString, EvalPathHome)
STRCMP_EQUAL(result + length_weechat_data_dir, "/test");
free (result);
+ /* "%h" with forced state dir */
+ hashtable_set (options, "directory", "state");
+ result = string_eval_path_home ("%h/test", NULL, NULL, options);
+ CHECK(strncmp (result, weechat_state_dir, length_weechat_state_dir) == 0);
+ LONGS_EQUAL(length_weechat_state_dir + 5, strlen (result));
+ STRCMP_EQUAL(result + length_weechat_state_dir, "/test");
+ free (result);
+
/* "%h" with forced cache dir */
hashtable_set (options, "directory", "cache");
result = string_eval_path_home ("%h/test", NULL, NULL, options);
@@ -1048,6 +1058,14 @@ TEST(CoreString, EvalPathHome)
STRCMP_EQUAL(result + length_weechat_data_dir, "/path");
free (result);
+ /* state dir */
+ result = string_eval_path_home ("${weechat_state_dir}/path",
+ NULL, NULL, NULL);
+ CHECK(strncmp (result, weechat_state_dir, length_weechat_state_dir) == 0);
+ LONGS_EQUAL(length_weechat_state_dir + 5, strlen (result));
+ STRCMP_EQUAL(result + length_weechat_state_dir, "/path");
+ free (result);
+
/* cache dir */
result = string_eval_path_home ("${weechat_cache_dir}/path",
NULL, NULL, NULL);
diff --git a/tests/unit/plugins/test-plugin-api-info.cpp b/tests/unit/plugins/test-plugin-api-info.cpp
index 07a31f9b0..a58c14f4d 100644
--- a/tests/unit/plugins/test-plugin-api-info.cpp
+++ b/tests/unit/plugins/test-plugin-api-info.cpp
@@ -164,8 +164,9 @@ TEST(PluginApiInfo, AbsolutePath)
* plugin_api_info_absolute_path
* plugin_api_info_weechat_config_dir_cb
* plugin_api_info_weechat_data_dir_cb
+ * plugin_api_info_weechat_state_dir_cb
* plugin_api_info_weechat_cache_dir_cb
- * plugin_api_info_weechat_cache_dir_cb
+ * plugin_api_info_weechat_runtime_dir_cb
*/
TEST(PluginApiInfo, WeechatDir)
@@ -186,6 +187,13 @@ TEST(PluginApiInfo, WeechatDir)
CHECK(strstr (str, "/tmp_weechat_test"));
free (str);
+ str = hook_info_get (NULL, "weechat_state_dir", NULL);
+ CHECK(str);
+ CHECK(str[0] == '/');
+ CHECK(strlen (str) > 1);
+ CHECK(strstr (str, "/tmp_weechat_test"));
+ free (str);
+
str = hook_info_get (NULL, "weechat_cache_dir", NULL);
CHECK(str);
CHECK(str[0] == '/');