aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2018-01-18 11:39:56 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2018-01-18 11:39:56 +0200
commite3bf8b04654d4131be6ea4be670e66827b489d2e (patch)
treec8639faa5a9da99286fe58bb28e8b15b8f5e7e43 /tests
parent6734ffe0dc7fbdca5bbbf57f80aa44e1fafb6922 (diff)
Move find_sup() from path_map to prefix_map and fix
Diffstat (limited to 'tests')
-rw-r--r--tests/prefix-map/driver.cxx80
1 files changed, 59 insertions, 21 deletions
diff --git a/tests/prefix-map/driver.cxx b/tests/prefix-map/driver.cxx
index 3e165b2..2fb8a99 100644
--- a/tests/prefix-map/driver.cxx
+++ b/tests/prefix-map/driver.cxx
@@ -33,12 +33,12 @@ main ()
const pm m;
{
- auto r (m.find_prefix (""));
+ auto r (m.find_sub (""));
assert (r.first == r.second);
}
{
- auto r (m.find_prefix ("foo"));
+ auto r (m.find_sub ("foo"));
assert (r.first == r.second);
}
}
@@ -47,33 +47,33 @@ main ()
pm m {{{"foo", 1}}};
{
- auto r (m.find_prefix (""));
+ auto r (m.find_sub (""));
assert (r.first != r.second && r.first->second == 1 &&
++r.first == r.second);
}
{
- auto r (m.find_prefix ("fo"));
+ auto r (m.find_sub ("fo"));
assert (r.first == r.second);
}
{
- auto r (m.find_prefix ("fox"));
+ auto r (m.find_sub ("fox"));
assert (r.first == r.second);
}
{
- auto r (m.find_prefix ("fooo"));
+ auto r (m.find_sub ("fooo"));
assert (r.first == r.second);
}
{
- auto r (m.find_prefix ("foo.bar"));
+ auto r (m.find_sub ("foo.bar"));
assert (r.first == r.second);
}
{
- auto r (m.find_prefix ("foo"));
+ auto r (m.find_sub ("foo"));
assert (r.first != r.second && r.first->second == 1 &&
++r.first == r.second);
}
@@ -83,40 +83,40 @@ main ()
pm m {{{"foo", 1}, {"bar", 2}}};
{
- auto r (m.find_prefix (""));
+ auto r (m.find_sub (""));
assert (r.first != r.second && r.first->second == 2 &&
++r.first != r.second && r.first->second == 1 &&
++r.first == r.second);
}
{
- auto r (m.find_prefix ("fo"));
+ auto r (m.find_sub ("fo"));
assert (r.first == r.second);
}
{
- auto r (m.find_prefix ("fox"));
+ auto r (m.find_sub ("fox"));
assert (r.first == r.second);
}
{
- auto r (m.find_prefix ("fooo"));
+ auto r (m.find_sub ("fooo"));
assert (r.first == r.second);
}
{
- auto r (m.find_prefix ("foo.bar"));
+ auto r (m.find_sub ("foo.bar"));
assert (r.first == r.second);
}
{
- auto r (m.find_prefix ("foo"));
+ auto r (m.find_sub ("foo"));
assert (r.first != r.second && r.first->second == 1 &&
++r.first == r.second);
}
{
- auto r (m.find_prefix ("bar"));
+ auto r (m.find_sub ("bar"));
assert (r.first != r.second && r.first->second == 2 &&
++r.first == r.second);
}
@@ -129,38 +129,76 @@ main ()
{"xoo", 5}});
{
- auto r (m.find_prefix ("fo"));
+ auto r (m.find_sub ("fo"));
assert (r.first == r.second);
}
{
- auto r (m.find_prefix ("fox"));
+ auto r (m.find_sub ("fox"));
assert (r.first == r.second);
}
{
- auto r (m.find_prefix ("fooo"));
+ auto r (m.find_sub ("fooo"));
assert (r.first == r.second);
}
{
- auto r (m.find_prefix ("foo.bar"));
+ auto r (m.find_sub ("foo.bar"));
assert (r.first != r.second && r.first->second == 4 &&
++r.first == r.second);
}
{
- auto r (m.find_prefix ("foo.fox"));
+ auto r (m.find_sub ("foo.fox"));
assert (r.first != r.second && r.first->second == 5 &&
++r.first == r.second);
}
{
- auto r (m.find_prefix ("foo"));
+ auto r (m.find_sub ("foo"));
assert (r.first != r.second && r.first->second == 2 &&
++r.first != r.second && r.first->second == 4 &&
++r.first != r.second && r.first->second == 5 &&
++r.first == r.second);
}
}
+
+ {
+ pm m (
+ {{"foo", 1},
+ {"fooa", 2},
+ {"foo.bar", 3},
+ {"foo.baz.aaa", 4},
+ {"foo.baz.bbb", 5},
+ {"foo.baz.xxx", 6},
+ {"xoo", 7}});
+
+ auto e (m.end ());
+
+ {
+ auto i (m.find_sup ("fox"));
+ assert (i == e);
+ }
+
+ {
+ auto i (m.find_sup ("foo.baz.bbb"));
+ assert (i != e && i->second == 5);
+ }
+
+ {
+ auto i (m.find_sup ("foo.baz.ccc"));
+ assert (i != e && i->second == 1);
+ }
+
+ {
+ auto i (m.find_sup ("foo.baz"));
+ assert (i != e && i->second == 1);
+ }
+
+ {
+ auto i (m.find_sup ("xoo.bar"));
+ assert (i != e && i->second == 7);
+ }
+ }
}