From 26e50e695d7d90a9cc06fc03e55c271454c452f3 Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Tue, 6 Mar 2018 21:32:17 +0100 Subject: [PATCH] Add unit test for IsWindowsAbsolutePath --- src/project.cc | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/project.cc b/src/project.cc index 646ac36e..5ff75420 100644 --- a/src/project.cc +++ b/src/project.cc @@ -23,6 +23,7 @@ #include #include #include +#include struct CompileCommandsEntry { 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") { Project p; {