summaryrefslogtreecommitdiff
path: root/test/plugins
diff options
context:
space:
mode:
authorAndreas Stöckel <astoecke@techfak.uni-bielefeld.de>2015-02-17 00:52:25 +0100
committerAndreas Stöckel <astoecke@techfak.uni-bielefeld.de>2015-02-17 00:52:25 +0100
commit2edd0e40cd1afa9a422733b0a3b4babc064041b6 (patch)
treeb0d2635bb2266d66c5064e3476fde4588d73ea41 /test/plugins
parent4a4e2245730ead7fce354469fe626398520f12b2 (diff)
Improved behaviour of FileLocator:
* really complete path, do not return completely new path * return file directly if it already exists * only complete the extension, nothing else * also ignore .backup files created by KDE programs
Diffstat (limited to 'test/plugins')
-rw-r--r--test/plugins/filesystem/FileLocatorTest.cpp54
1 files changed, 50 insertions, 4 deletions
diff --git a/test/plugins/filesystem/FileLocatorTest.cpp b/test/plugins/filesystem/FileLocatorTest.cpp
index 361a3ca..22db926 100644
--- a/test/plugins/filesystem/FileLocatorTest.cpp
+++ b/test/plugins/filesystem/FileLocatorTest.cpp
@@ -18,6 +18,8 @@
#include <gtest/gtest.h>
+#include <set>
+
#include <plugins/filesystem/FileLocator.hpp>
#include <plugins/filesystem/SpecialPaths.hpp>
@@ -142,10 +144,11 @@ TEST(FileLocator, locate)
assert_not_located(locator, "c.txt", "", ResourceType::SCRIPT);
}
-TEST(FileLocator, locateAbsolute){
+TEST(FileLocator, locateAbsolute)
+{
FileLocator locator;
- // construct the absolute path by utilizing SpecialPaths and
- fs::path testdataDir {SpecialPaths::getDebugTestdataDir()};
+ // construct the absolute path by utilizing SpecialPaths and
+ fs::path testdataDir{SpecialPaths::getDebugTestdataDir()};
fs::path absolute = fs::canonical(testdataDir);
absolute /= "filesystem";
absolute /= "a.txt";
@@ -217,7 +220,50 @@ TEST(FileLocator, testDefaultSearchPaths)
assert_located(locator, "domain/book.osxml", "", ResourceType::UNKNOWN);
assert_located(locator, "book.osxml", "", ResourceType::DOMAIN_DESC);
assert_not_located(locator, "color.osxml", "", ResourceType::UNKNOWN);
- assert_located(locator, "typesystem/color.osxml", "", ResourceType::UNKNOWN);
+ assert_located(locator, "typesystem/color.osxml", "",
+ ResourceType::UNKNOWN);
assert_located(locator, "color.osxml", "", ResourceType::TYPESYSTEM);
}
+
+TEST(FileLocator, autocompleteIgnoreBackupFiles)
+{
+ FileLocator locator;
+ locator.addUnittestSearchPath("filesystem");
+
+ auto res = locator.autocomplete("autocomplete/a");
+ ASSERT_EQ(std::vector<std::string>{"autocomplete/a.test"}, res);
+}
+
+TEST(FileLocator, autocompleteAmbiguous)
+{
+ FileLocator locator;
+ locator.addUnittestSearchPath("filesystem");
+
+ auto res = locator.autocomplete("autocomplete/b");
+
+ std::set<std::string> resSet;
+ resSet.insert(res.begin(), res.end());
+
+ ASSERT_EQ(
+ std::set<std::string>({"autocomplete/b.test1", "autocomplete/b.test2"}),
+ resSet);
+}
+
+TEST(FileLocator, autocompleteExisting)
+{
+ FileLocator locator;
+ locator.addUnittestSearchPath("filesystem");
+
+ auto res = locator.autocomplete("autocomplete/c");
+ ASSERT_EQ(std::vector<std::string>{"autocomplete/c"}, res);
+}
+
+TEST(FileLocator, autocompleteExtensionOnly)
+{
+ FileLocator locator;
+ locator.addUnittestSearchPath("filesystem");
+
+ auto res = locator.autocomplete("autocomplete/d");
+ ASSERT_EQ(std::vector<std::string>{}, res);
+}
}