MCPcopy Create free account
hub / github.com/containers/bubblewrap / test_has_path_prefix

Function test_has_path_prefix

tests/test-utils.c:163–201  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

161}
162
163static void
164test_has_path_prefix (void)
165{
166 static const struct
167 {
168 const char *str;
169 const char *prefix;
170 bool expected;
171 } tests[] =
172 {
173 { "/run/host/usr", "/run/host", true },
174 { "/run/host/usr", "/run/host/", true },
175 { "/run/host", "/run/host", true },
176 { "////run///host////usr", "//run//host", true },
177 { "////run///host////usr", "//run//host////", true },
178 { "/run/hostage", "/run/host", false },
179 /* Any number of leading slashes is ignored, even zero */
180 { "foo/bar", "/foo", true },
181 { "/foo/bar", "foo", true },
182 };
183 size_t i;
184
185 for (i = 0; i < N_ELEMENTS (tests); i++)
186 {
187 const char *str = tests[i].str;
188 const char *prefix = tests[i].prefix;
189 bool expected = tests[i].expected;
190
191 if (expected)
192 g_test_message ("%s should have path prefix %s", str, prefix);
193 else
194 g_test_message ("%s should not have path prefix %s", str, prefix);
195
196 if (expected)
197 g_assert_true (has_path_prefix (str, prefix));
198 else
199 g_assert_false (has_path_prefix (str, prefix));
200 }
201}
202
203static void
204test_string_builder (void)

Callers 1

mainFunction · 0.85

Calls 1

has_path_prefixFunction · 0.85

Tested by

no test coverage detected