@@ -34,6 +34,62 @@ TEST(URITemplate_match, empty_template_non_empty_uri) {
3434 EXPECT_EQ (captures.size (), 0 );
3535}
3636
37+ TEST (URITemplate_match, empty_template_root_uri) {
38+ const sourcemeta::core::URITemplate uri_template{" " };
39+
40+ std::vector<std::pair<std::string, std::string>> captures;
41+ const auto result = uri_template.match (
42+ " /" , ' /' ,
43+ [&captures](const std::string_view name, const std::string_view value) {
44+ captures.emplace_back (name, value);
45+ });
46+
47+ EXPECT_FALSE (result);
48+ EXPECT_EQ (captures.size (), 0 );
49+ }
50+
51+ TEST (URITemplate_match, root_template_matches_root) {
52+ const sourcemeta::core::URITemplate uri_template{" /" };
53+
54+ std::vector<std::pair<std::string, std::string>> captures;
55+ const auto result = uri_template.match (
56+ " /" , ' /' ,
57+ [&captures](const std::string_view name, const std::string_view value) {
58+ captures.emplace_back (name, value);
59+ });
60+
61+ EXPECT_TRUE (result);
62+ EXPECT_EQ (captures.size (), 0 );
63+ }
64+
65+ TEST (URITemplate_match, root_template_no_match_empty) {
66+ const sourcemeta::core::URITemplate uri_template{" /" };
67+
68+ std::vector<std::pair<std::string, std::string>> captures;
69+ const auto result = uri_template.match (
70+ " " , ' /' ,
71+ [&captures](const std::string_view name, const std::string_view value) {
72+ captures.emplace_back (name, value);
73+ });
74+
75+ EXPECT_FALSE (result);
76+ EXPECT_EQ (captures.size (), 0 );
77+ }
78+
79+ TEST (URITemplate_match, root_template_no_match_path) {
80+ const sourcemeta::core::URITemplate uri_template{" /" };
81+
82+ std::vector<std::pair<std::string, std::string>> captures;
83+ const auto result = uri_template.match (
84+ " /foo" , ' /' ,
85+ [&captures](const std::string_view name, const std::string_view value) {
86+ captures.emplace_back (name, value);
87+ });
88+
89+ EXPECT_FALSE (result);
90+ EXPECT_EQ (captures.size (), 0 );
91+ }
92+
3793TEST (URITemplate_match, literal_only_match) {
3894 const sourcemeta::core::URITemplate uri_template{" /users/list" };
3995
0 commit comments