Add unit test for IsWindowsAbsolutePath

This commit is contained in:
Daan De Meyer 2018-03-06 21:32:17 +01:00 committed by Jacob Dufault
parent 99904874ca
commit 26e50e695d

View File

@ -23,6 +23,7 @@
#include <sstream> #include <sstream>
#include <unordered_set> #include <unordered_set>
#include <vector> #include <vector>
#include <iostream>
struct CompileCommandsEntry { struct CompileCommandsEntry {
std::string directory; std::string directory;
@ -1480,6 +1481,22 @@ TEST_SUITE("Project") {
} }
} }
TEST_CASE("IsWindowsAbsolutePath works correctly") {
REQUIRE(IsWindowsAbsolutePath("C:/Users/projects/") == true);
REQUIRE(IsWindowsAbsolutePath("C:/Users/projects") == true);
REQUIRE(IsWindowsAbsolutePath("C:/Users/projects") == true);
REQUIRE(IsWindowsAbsolutePath("C:\\Users\\projects") == true);
REQUIRE(IsWindowsAbsolutePath("C:\\\\Users\\\\projects") == true);
REQUIRE(IsWindowsAbsolutePath("c:\\\\Users\\\\projects") == true);
REQUIRE(IsWindowsAbsolutePath("A:\\\\Users\\\\projects") == true);
REQUIRE(IsWindowsAbsolutePath("C:/") == false);
REQUIRE(IsWindowsAbsolutePath("../abc/test") == false);
REQUIRE(IsWindowsAbsolutePath("5:/test") == false);
REQUIRE(IsWindowsAbsolutePath("cquery/project/file.cc") == false);
REQUIRE(IsWindowsAbsolutePath("") == false);
}
TEST_CASE("Entry inference prefers same file endings") { TEST_CASE("Entry inference prefers same file endings") {
Project p; Project p;
{ {