[vector] Move test code into separate file
diff --git a/src/Makefile.am b/src/Makefile.am
index f405331..bdd7568 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -342,7 +342,19 @@
test_gsub_would_substitute_CPPFLAGS = $(HBCFLAGS) $(FREETYPE_CFLAGS)
test_gsub_would_substitute_LDADD = libharfbuzz.la $(HBLIBS) $(FREETYPE_LIBS)
-COMPILED_TESTS = test-algs test-array test-iter test-meta test-number test-ot-tag test-priority-queue test-unicode-ranges test-bimap test-repacker
+COMPILED_TESTS = \
+ test-algs \
+ test-array \
+ test-iter \
+ test-meta \
+ test-number \
+ test-ot-tag \
+ test-priority-queue \
+ test-unicode-ranges \
+ test-vector \
+ test-bimap \
+ test-repacker \
+ $(NULL)
COMPILED_TESTS_CPPFLAGS = $(HBCFLAGS) -DMAIN -UNDEBUG
COMPILED_TESTS_LDADD = libharfbuzz.la $(HBLIBS)
check_PROGRAMS += $(COMPILED_TESTS)
diff --git a/src/meson.build b/src/meson.build
index db4208f..8209fb5 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -492,6 +492,7 @@
'test-number': ['test-number.cc', 'hb-number.cc'],
'test-ot-tag': ['hb-ot-tag.cc'],
'test-unicode-ranges': ['test-unicode-ranges.cc'],
+ 'test-vector': ['test-vector.cc', 'hb-static.cc'],
'test-bimap': ['test-bimap.cc', 'hb-static.cc'],
}
foreach name, source : compiled_tests
diff --git a/src/test-algs.cc b/src/test-algs.cc
index fd69b51..f8b8ff6 100644
--- a/src/test-algs.cc
+++ b/src/test-algs.cc
@@ -26,7 +26,6 @@
#include "hb.hh"
#include "hb-algs.hh"
-#include "hb-set.hh"
static char *
@@ -92,55 +91,5 @@
assert (++hb_inc (x) == 3);
assert (x == 3);
- /* Test initializing vector from iterable. */
- {
- hb_set_t s;
-
- s.add (18);
- s.add (12);
-
- hb_vector_t<int> v (s);
-
- assert (v.length == 2);
- assert (v[0] == 12);
- assert (v[1] == 18);
- }
-
- /* Test initializing vector from iterator. */
- {
- hb_set_t s;
-
- s.add (18);
- s.add (12);
-
- hb_vector_t<int> v (hb_iter (s));
-
- assert (v.length == 2);
- assert (v[0] == 12);
- assert (v[1] == 18);
- }
-
- /* Test initializing vector from initializer list and swapping. */
- {
- hb_vector_t<int> v1 {1, 2, 3};
- hb_vector_t<int> v2 {4, 5};
- hb_swap (v1, v2);
- assert (v1.length == 2);
- assert (v1[0] == 4);
- assert (v2.length == 3);
- assert (v2[2] == 3);
- }
-
- /* Test initializing sorted-vector from initializer list and swapping. */
- {
- hb_sorted_vector_t<int> v1 {1, 2, 3};
- hb_sorted_vector_t<int> v2 {4, 5};
- hb_swap (v1, v2);
- assert (v1.length == 2);
- assert (v1[0] == 4);
- assert (v2.length == 3);
- assert (v2[2] == 3);
- }
-
return 0;
}
diff --git a/src/test-vector.cc b/src/test-vector.cc
new file mode 100644
index 0000000..80bea6b
--- /dev/null
+++ b/src/test-vector.cc
@@ -0,0 +1,85 @@
+/*
+ * Copyright © 2021 Behdad Esfahbod
+ *
+ * This is part of HarfBuzz, a text shaping library.
+ *
+ * Permission is hereby granted, without written agreement and without
+ * license or royalty fees, to use, copy, modify, and distribute this
+ * software and its documentation for any purpose, provided that the
+ * above copyright notice and the following two paragraphs appear in
+ * all copies of this software.
+ *
+ * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
+ * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
+ * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
+ * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ *
+ * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
+ * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
+ * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
+ * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+ *
+ */
+
+#include "hb.hh"
+#include "hb-vector.hh"
+#include "hb-set.hh"
+
+
+int
+main (int argc, char **argv)
+{
+ /* Test initializing vector from iterable. */
+ {
+ hb_set_t s;
+
+ s.add (18);
+ s.add (12);
+
+ hb_vector_t<int> v (s);
+
+ assert (v.length == 2);
+ assert (v[0] == 12);
+ assert (v[1] == 18);
+ }
+
+ /* Test initializing vector from iterator. */
+ {
+ hb_set_t s;
+
+ s.add (18);
+ s.add (12);
+
+ hb_vector_t<int> v (hb_iter (s));
+
+ assert (v.length == 2);
+ assert (v[0] == 12);
+ assert (v[1] == 18);
+ }
+
+ /* Test initializing vector from initializer list and swapping. */
+ {
+ hb_vector_t<int> v1 {1, 2, 3};
+ hb_vector_t<int> v2 {4, 5};
+ hb_swap (v1, v2);
+ assert (v1.length == 2);
+ assert (v1[0] == 4);
+ assert (v2.length == 3);
+ assert (v2[2] == 3);
+ }
+
+ /* Test initializing sorted-vector from initializer list and swapping. */
+ {
+ hb_sorted_vector_t<int> v1 {1, 2, 3};
+ hb_sorted_vector_t<int> v2 {4, 5};
+ hb_swap (v1, v2);
+ assert (v1.length == 2);
+ assert (v1[0] == 4);
+ assert (v2.length == 3);
+ assert (v2[2] == 3);
+ }
+
+ return 0;
+}