From e61234c5f75e21901a81df08945daddca5cbfde3 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Thu, 12 May 2022 13:20:10 -0600 Subject: [PATCH] [vector] Add tests for move constructor/assignment --- src/test-vector.cc | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/test-vector.cc b/src/test-vector.cc index 521f2a171..5c0f378b5 100644 --- a/src/test-vector.cc +++ b/src/test-vector.cc @@ -61,8 +61,12 @@ main (int argc, char **argv) /* Test move constructor. */ { - hb_vector_t v {hb_vector_t {1, 2}}; - hb_vector_t V {hb_vector_t {1, 2}}; + hb_vector_t s {1, 2}; + hb_sorted_vector_t S {1, 2}; + hb_vector_t v (std::move (s)); + hb_sorted_vector_t 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 s {1, 2}; + hb_sorted_vector_t S {1, 2}; hb_vector_t v; hb_sorted_vector_t V; - v = hb_vector_t {1, 2}; - V = hb_sorted_vector_t {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); }