[vector] Add tests for move constructor/assignment

This commit is contained in:
Behdad Esfahbod 2022-05-12 13:20:10 -06:00
parent 7fa580bc4f
commit e61234c5f7
1 changed files with 13 additions and 4 deletions

View File

@ -61,8 +61,12 @@ main (int argc, char **argv)
/* Test move constructor. */
{
hb_vector_t<int> v {hb_vector_t<int> {1, 2}};
hb_vector_t<int> V {hb_vector_t<int> {1, 2}};
hb_vector_t<int> s {1, 2};
hb_sorted_vector_t<int> S {1, 2};
hb_vector_t<int> v (std::move (s));
hb_sorted_vector_t<int> V (std::move (S));
assert (s.length == 0);
assert (S.length == 0);
assert (v.length == 2);
assert (v[0] == 1);
assert (v[1] == 2);
@ -70,11 +74,16 @@ main (int argc, char **argv)
/* Test move assignment. */
{
hb_vector_t<int> s {1, 2};
hb_sorted_vector_t<int> S {1, 2};
hb_vector_t<int> v;
hb_sorted_vector_t<int> V;
v = hb_vector_t<int> {1, 2};
V = hb_sorted_vector_t<int> {1, 2};
v = std::move (s);
V = std::move (S);
assert (s.length == 0);
assert (S.length == 0);
assert (v.length == 2);
assert (V.length == 2);
assert (v[0] == 1);
assert (v[1] == 2);
}