diff options
author | Shea Levy <shea@shealevy.com> | 2024-01-11 07:21:16 -0500 |
---|---|---|
committer | Shea Levy <shea@shealevy.com> | 2024-01-11 07:21:16 -0500 |
commit | ba48ab4b954dd1c8af388d1c5a33bbd62373c6f5 (patch) | |
tree | f17f8492bed32f78c04d9d4e9ffd2b672af85943 /src/libexpr/tests/search-path.cc | |
parent | e7c2b35827e9f4ddbec4248c5cf1ad793a2988ad (diff) | |
parent | 4dd5171652018e29bf9e496522df3be51d615a2c (diff) |
Merge branch '2.18-maintenance' into ifd-buildStore-2.18
Diffstat (limited to 'src/libexpr/tests/search-path.cc')
-rw-r--r-- | src/libexpr/tests/search-path.cc | 90 |
1 files changed, 0 insertions, 90 deletions
diff --git a/src/libexpr/tests/search-path.cc b/src/libexpr/tests/search-path.cc deleted file mode 100644 index dbe7ab95f..000000000 --- a/src/libexpr/tests/search-path.cc +++ /dev/null @@ -1,90 +0,0 @@ -#include <gtest/gtest.h> -#include <gmock/gmock.h> - -#include "search-path.hh" - -namespace nix { - -TEST(SearchPathElem, parse_justPath) { - ASSERT_EQ( - SearchPath::Elem::parse("foo"), - (SearchPath::Elem { - .prefix = SearchPath::Prefix { .s = "" }, - .path = SearchPath::Path { .s = "foo" }, - })); -} - -TEST(SearchPathElem, parse_emptyPrefix) { - ASSERT_EQ( - SearchPath::Elem::parse("=foo"), - (SearchPath::Elem { - .prefix = SearchPath::Prefix { .s = "" }, - .path = SearchPath::Path { .s = "foo" }, - })); -} - -TEST(SearchPathElem, parse_oneEq) { - ASSERT_EQ( - SearchPath::Elem::parse("foo=bar"), - (SearchPath::Elem { - .prefix = SearchPath::Prefix { .s = "foo" }, - .path = SearchPath::Path { .s = "bar" }, - })); -} - -TEST(SearchPathElem, parse_twoEqs) { - ASSERT_EQ( - SearchPath::Elem::parse("foo=bar=baz"), - (SearchPath::Elem { - .prefix = SearchPath::Prefix { .s = "foo" }, - .path = SearchPath::Path { .s = "bar=baz" }, - })); -} - - -TEST(SearchPathElem, suffixIfPotentialMatch_justPath) { - SearchPath::Prefix prefix { .s = "" }; - ASSERT_EQ(prefix.suffixIfPotentialMatch("any/thing"), std::optional { "any/thing" }); -} - -TEST(SearchPathElem, suffixIfPotentialMatch_misleadingPrefix1) { - SearchPath::Prefix prefix { .s = "foo" }; - ASSERT_EQ(prefix.suffixIfPotentialMatch("fooX"), std::nullopt); -} - -TEST(SearchPathElem, suffixIfPotentialMatch_misleadingPrefix2) { - SearchPath::Prefix prefix { .s = "foo" }; - ASSERT_EQ(prefix.suffixIfPotentialMatch("fooX/bar"), std::nullopt); -} - -TEST(SearchPathElem, suffixIfPotentialMatch_partialPrefix) { - SearchPath::Prefix prefix { .s = "fooX" }; - ASSERT_EQ(prefix.suffixIfPotentialMatch("foo"), std::nullopt); -} - -TEST(SearchPathElem, suffixIfPotentialMatch_exactPrefix) { - SearchPath::Prefix prefix { .s = "foo" }; - ASSERT_EQ(prefix.suffixIfPotentialMatch("foo"), std::optional { "" }); -} - -TEST(SearchPathElem, suffixIfPotentialMatch_multiKey) { - SearchPath::Prefix prefix { .s = "foo/bar" }; - ASSERT_EQ(prefix.suffixIfPotentialMatch("foo/bar/baz"), std::optional { "baz" }); -} - -TEST(SearchPathElem, suffixIfPotentialMatch_trailingSlash) { - SearchPath::Prefix prefix { .s = "foo" }; - ASSERT_EQ(prefix.suffixIfPotentialMatch("foo/"), std::optional { "" }); -} - -TEST(SearchPathElem, suffixIfPotentialMatch_trailingDoubleSlash) { - SearchPath::Prefix prefix { .s = "foo" }; - ASSERT_EQ(prefix.suffixIfPotentialMatch("foo//"), std::optional { "/" }); -} - -TEST(SearchPathElem, suffixIfPotentialMatch_trailingPath) { - SearchPath::Prefix prefix { .s = "foo" }; - ASSERT_EQ(prefix.suffixIfPotentialMatch("foo/bar/baz"), std::optional { "bar/baz" }); -} - -} |