Przeglądaj źródła

expand_filename tests for trailing slash in $HOME

Esteban Manchado Velázquez 12 lat temu
rodzic
commit
8e88377905
1 zmienionych plików z 15 dodań i 0 usunięć
  1. 15 0
      src/test/test_util.c

+ 15 - 0
src/test/test_util.c

@@ -588,6 +588,21 @@ test_util_expand_filename(void)
   /* Ideally we'd test ~anotheruser, but that's shady to test (we'd
      have to somehow inject/fake the get_user_homedir call) */
 
+  /* $HOME ending in a trailing slash */
+  setenv("HOME", "/home/itv/", 1);
+
+  str = expand_filename("~");
+  test_streq("/home/itv/", str);
+  tor_free(str);
+
+  str = expand_filename("~/");
+  test_streq("/home/itv/", str);
+  tor_free(str);
+
+  str = expand_filename("~/foo");
+  test_streq("/home/itv/foo", str);
+  tor_free(str);
+
   /* Try with empty $HOME */
 
   setenv("HOME", "", 1);