aboutsummaryrefslogtreecommitdiffhomepage
path: root/fish_tests.cpp
diff options
context:
space:
mode:
authorGravatar ridiculousfish <corydoras@ridiculousfish.com>2012-05-13 20:19:02 -0700
committerGravatar ridiculousfish <corydoras@ridiculousfish.com>2012-05-13 20:19:02 -0700
commit129525af21d069943bb062e69a2a174e01a2c0e4 (patch)
tree012e32fbb55b3a13e211b0010066523f518c2546 /fish_tests.cpp
parentc15975113ab80241c71dc6dfa41a470b232de4ce (diff)
cd's special autosuggestion was broken, now fixed. Also, there's some tests for it now.
Diffstat (limited to 'fish_tests.cpp')
-rw-r--r--fish_tests.cpp41
1 files changed, 41 insertions, 0 deletions
diff --git a/fish_tests.cpp b/fish_tests.cpp
index 57021f4b..405abf52 100644
--- a/fish_tests.cpp
+++ b/fish_tests.cpp
@@ -579,6 +579,45 @@ static void test_path()
}
}
+/** Test is_potential_path */
+static void test_is_potential_path()
+{
+ say(L"Testing is_potential_path");
+ if (system("rm -Rf /tmp/is_potential_path_test/")) {
+ err(L"Failed to remove /tmp/is_potential_path_test/");
+ }
+
+ /* Directories */
+ if (system("mkdir -p /tmp/is_potential_path_test/alpha/")) err(L"mkdir failed");
+ if (system("mkdir -p /tmp/is_potential_path_test/beta/")) err(L"mkdir failed");
+
+ /* Files */
+ if (system("touch /tmp/is_potential_path_test/aardvark")) err(L"touch failed");
+ if (system("touch /tmp/is_potential_path_test/gamma")) err(L"touch failed");
+
+ const wcstring wd = L"/tmp/is_potential_path_test/";
+ const wcstring_list_t wds(1, wd);
+
+ wcstring tmp;
+ assert(is_potential_path(L"al", wds, true, &tmp) && tmp == L"alpha/");
+ assert(is_potential_path(L"alpha/", wds, true, &tmp) && tmp == L"alpha/");
+ assert(is_potential_path(L"aard", wds, false, &tmp) && tmp == L"aardvark");
+
+ assert(! is_potential_path(L"balpha/", wds, true, &tmp));
+ assert(! is_potential_path(L"aard", wds, true, &tmp));
+ assert(! is_potential_path(L"aarde", wds, true, &tmp));
+ assert(! is_potential_path(L"aarde", wds, false, &tmp));
+
+ assert(is_potential_path(L"/tmp/is_potential_path_test/aardvark", wds, false, &tmp) && tmp == L"/tmp/is_potential_path_test/aardvark");
+ assert(is_potential_path(L"/tmp/is_potential_path_test/al", wds, true, &tmp) && tmp == L"/tmp/is_potential_path_test/alpha/");
+ assert(is_potential_path(L"/tmp/is_potential_path_test/aardv", wds, false, &tmp) && tmp == L"/tmp/is_potential_path_test/aardvark");
+
+ assert(! is_potential_path(L"/tmp/is_potential_path_test/aardvark", wds, true, &tmp));
+ assert(! is_potential_path(L"/tmp/is_potential_path_test/al/", wds, false, &tmp));
+ assert(! is_potential_path(L"/tmp/is_potential_path_test/ar", wds, false, &tmp));
+
+}
+
/** Test the 'test' builtin */
int builtin_test( parser_t &parser, wchar_t **argv );
static bool run_test_test(int expected, wcstring_list_t &lst) {
@@ -927,6 +966,7 @@ int main( int argc, char **argv )
{
setlocale( LC_ALL, "" );
srand( time( 0 ) );
+ configure_thread_assertions_for_testing();
program_name=L"(ignore)";
@@ -951,6 +991,7 @@ int main( int argc, char **argv )
test_expand();
test_test();
test_path();
+ test_is_potential_path();
test_colors();
test_autosuggest();
history_tests_t::test_history();