[vector] Move test code into separate file
This commit is contained in:
parent
ee75e716c1
commit
11135150a7
|
@ -342,7 +342,19 @@ test_gsub_would_substitute_SOURCES = test-gsub-would-substitute.cc
|
|||
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)
|
||||
|
|
|
@ -492,6 +492,7 @@ if get_option('tests').enabled()
|
|||
'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
|
||||
|
|
|
@ -26,7 +26,6 @@
|
|||
|
||||
#include "hb.hh"
|
||||
#include "hb-algs.hh"
|
||||
#include "hb-set.hh"
|
||||
|
||||
|
||||
static char *
|
||||
|
@ -92,55 +91,5 @@ main (int argc, char **argv)
|
|||
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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
Loading…
Reference in New Issue