From b61202af8e935e614de353be3bb35d62a2773cce Mon Sep 17 00:00:00 2001 From: baldurk Date: Thu, 18 Feb 2021 12:32:10 +0000 Subject: [PATCH] Add tests of get_lastpathsep * This is an internal function but it's still useful to test it independently. --- renderdoc/strings/string_utils.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/renderdoc/strings/string_utils.cpp b/renderdoc/strings/string_utils.cpp index 94a3d648d..5d8f40844 100644 --- a/renderdoc/strings/string_utils.cpp +++ b/renderdoc/strings/string_utils.cpp @@ -255,6 +255,23 @@ TEST_CASE("String manipulation", "[string]") CHECK(strlower("FOOBAR") == "foobar"); }; + SECTION("get_lastpathsep") + { + CHECK(get_lastpathsep("") == -1); + CHECK(get_lastpathsep("foo") == -1); + CHECK(get_lastpathsep("foobar.blah") == -1); + CHECK(get_lastpathsep("/foo") == 0); + CHECK(get_lastpathsep("/foobar.blah") == 0); + CHECK(get_lastpathsep("foo/bar/blah/") == 12); + CHECK(get_lastpathsep("foo\\bar\\blah\\") == 12); + CHECK(get_lastpathsep("foo/bar/blah") == 7); + CHECK(get_lastpathsep("foo\\bar\\blah") == 7); + CHECK(get_lastpathsep("/foo/bar/blah/") == 13); + CHECK(get_lastpathsep("\\foo\\bar\\blah\\") == 13); + CHECK(get_lastpathsep("/foo/bar/blah") == 8); + CHECK(get_lastpathsep("\\foo\\bar\\blah") == 8); + }; + SECTION("basename") { CHECK(get_basename("") == "");