test: move tests to TAP output

This commit is contained in:
Danny Robson 2015-04-13 16:45:56 +10:00
parent 241ad65df9
commit bbbbb675a6
40 changed files with 353 additions and 255 deletions

View File

@ -288,7 +288,7 @@ if PLATFORM_WIN32
test_hton_LDFLAGS = -lws2_32 test_hton_LDFLAGS = -lws2_32
endif endif
TEST_LOG_DRIVER = env AM_TAP_AWK='$(AWK)' $(SHELL) $(top_srcdir)/build-aux/tap-driver.sh LOG_DRIVER = env AM_TAP_AWK='$(AWK)' $(SHELL) $(top_srcdir)/build-aux/tap-driver.sh
TESTS = $(top_builddir)/test/static.test $(top_builddir)/test/json.test $(top_builddir)/test/json-schema.test TESTS = $(top_builddir)/test/json-parse $(top_builddir)/test/json-schema $(TEST_BIN)
check_PROGRAMS = $(TEST_BIN) check_PROGRAMS = $(TEST_BIN)
EXTRA_DIST += test/static.test test/json.test test/json test/json-schema EXTRA_DIST += test/json test/json-parse test/json-schema

View File

@ -110,7 +110,6 @@ AC_CONFIG_FILES([
Makefile Makefile
test/Makefile test/Makefile
]) ])
AC_CONFIG_FILES([test/json.test], [chmod a+x test/json.test]) AC_CONFIG_FILES([test/json-parse], [chmod a+x test/json-parse])
AC_CONFIG_FILES([test/json-schema.test], [chmod a+x test/json-schema.test]) AC_CONFIG_FILES([test/json-schema], [chmod a+x test/json-schema])
AC_CONFIG_FILES([test/static.test], [chmod a+x test/static.test])
AC_OUTPUT AC_OUTPUT

View File

@ -1,8 +1,15 @@
#include "aabb.hpp" #include "aabb.hpp"
#include "tap.hpp"
#include <tuple>
int int
main (int, char**) main (int, char**)
{ {
util::TAP::logger tap;
{ {
// Test contraction // Test contraction
util::AABB2f box { util::AABB2f box {
@ -12,10 +19,7 @@ main (int, char**)
box.contract (2.f); box.contract (2.f);
CHECK_EQ (box.p0.x, 3); tap.expect_eq<util::AABB2f, util::AABB2f> (box, { { 3, 3 }, { 7, 7 }}, "over contraction");
CHECK_EQ (box.p0.y, 3);
CHECK_EQ (box.p1.x, 7);
CHECK_EQ (box.p1.y, 7);
} }
{ {
@ -27,10 +31,7 @@ main (int, char**)
box.expand (2.f); box.expand (2.f);
CHECK_EQ (box.p0.x, 1); tap.expect_eq<util::AABB2f, util::AABB2f> (box, { { 1, 1 }, { 9, 9 }}, "expansion");
CHECK_EQ (box.p0.y, 1);
CHECK_EQ (box.p1.x, 9);
CHECK_EQ (box.p1.y, 9);
} }
@ -43,9 +44,6 @@ main (int, char**)
small.contract (10); small.contract (10);
CHECK_EQ (small.p0.x, 0.5f); tap.expect_eq<util::AABB2f, util::AABB2f> (small, { { 0.5f, 0.5f }, { 0.5f, 0.5f }}, "unsigned over-contract");
CHECK_EQ (small.p0.y, 0.5f);
CHECK_EQ (small.p1.x, 0.5f);
CHECK_EQ (small.p1.y, 0.5f);
} }
} }

View File

@ -1,4 +1,7 @@
#include "../backtrace.hpp" #include "backtrace.hpp"
#include "tap.hpp"
#include "stream.hpp"
#include <iostream> #include <iostream>
#include <cstdlib> #include <cstdlib>
@ -7,7 +10,11 @@ using namespace std;
int int
main (int, char **) { main (int, char **) {
cout << debug::backtrace() << endl; util::TAP::logger tap;
util::stream::null out;
out << debug::backtrace() << endl;
tap.noop ();
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }

View File

@ -1,20 +1,20 @@
#include "bezier.hpp" #include "bezier.hpp"
#include "debug.hpp" #include "tap.hpp"
#include <cstdlib> #include <cstdlib>
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
template <size_t> void test_eval (void); template <size_t> void test_eval (util::TAP::logger&);
template <size_t> void test_intersect (void); template <size_t> void test_intersect (util::TAP::logger&);
template <size_t> void test_region (void); template <size_t> void test_region (util::TAP::logger&);
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
template <> template <>
void void
test_eval<1> (void) test_eval<1> (util::TAP::logger &tap)
{ {
static const util::bezier<1> b1 ({{ 0.f, 0.f}, static const util::bezier<1> b1 ({{ 0.f, 0.f},
{100.f, 100.f}}); {100.f, 100.f}});
@ -22,19 +22,20 @@ test_eval<1> (void)
auto p0 = b1.eval(0.f); auto p0 = b1.eval(0.f);
auto p1 = b1.eval(1.f); auto p1 = b1.eval(1.f);
CHECK_EQ (p0, b1[0]); tap.expect_eq (p0, b1[0], "eval bezier-1 extrema");
CHECK_EQ (p1, b1[1]); tap.expect_eq (p1, b1[1], "eval bezier-1 extrema");
auto px = b1.eval(0.5f); auto px = b1.eval(0.5f);
auto rx = b1[0] + 0.5f * (b1[1]-b1[0]); auto rx = b1[0] + 0.5f * (b1[1]-b1[0]);
CHECK_EQ (px, rx);
tap.expect_eq (px, rx, "eval bezier-1 midpoint");
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
template <> template <>
void void
test_eval<2> (void) test_eval<2> (util::TAP::logger &tap)
{ {
static const util::bezier<2> b2 ({{ 0.f, 0.f}, static const util::bezier<2> b2 ({{ 0.f, 0.f},
{ 50.f, 50.f}, { 50.f, 50.f},
@ -43,19 +44,20 @@ test_eval<2> (void)
auto p0 = b2.eval(0.f); auto p0 = b2.eval(0.f);
auto p2 = b2.eval(1.f); auto p2 = b2.eval(1.f);
CHECK_EQ (p0, b2[0]); tap.expect_eq (p0, b2[0], "eval bezier-2 extrema");
CHECK_EQ (p2, b2[2]); tap.expect_eq (p2, b2[2], "eval bezier-2 extrema");
auto px = b2.eval(0.5f); auto px = b2.eval(0.5f);
auto rx = b2[0] + 0.5f * (b2[2]-b2[0]); auto rx = b2[0] + 0.5f * (b2[2]-b2[0]);
CHECK_EQ (px, rx);
tap.expect_eq (px, rx, "eval bezier-2 midpoint");
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
template <> template <>
void void
test_eval<3> (void) test_eval<3> (util::TAP::logger &tap)
{ {
static const util::bezier<3> b3 ({{ 0.f, 0.f }, static const util::bezier<3> b3 ({{ 0.f, 0.f },
{ 33.f, 33.f }, { 33.f, 33.f },
@ -65,46 +67,61 @@ test_eval<3> (void)
auto p0 = b3.eval (0.f); auto p0 = b3.eval (0.f);
auto p3 = b3.eval (1.f); auto p3 = b3.eval (1.f);
CHECK_EQ (p0, b3[0]); tap.expect_eq (p0, b3[0], "eval bezier-3 extrema");
CHECK_EQ (p3, b3[3]); tap.expect_eq (p3, b3[3], "eval bezier-3 extrema");
auto px = b3.eval (0.5f); auto px = b3.eval (0.5f);
auto rx = b3[0] + 0.5f * (b3[3] - b3[0]); auto rx = b3[0] + 0.5f * (b3[3] - b3[0]);
CHECK_EQ (px, rx);
tap.expect_eq (px, rx, "eval bezier-3 midpoint");
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
template <> template <>
void void
test_intersect<1> (void) test_intersect<1> (util::TAP::logger &tap)
{ {
// A line from (0,0) to (100,100) // A line from (0,0) to (100,100)
static const util::bezier<1> b1 ({{0.f, 0.f}, {100.f, 100.f}}); static const util::bezier<1> b1 ({{0.f, 0.f}, {100.f, 100.f}});
// Through the centre // Through the centre
CHECK_EQ (b1.intersections ({0.f, 100.f}, {100.f, 0.f}), 1); tap.expect_eq (b1.intersections ({0.f, 100.f}, {100.f, 0.f}),
CHECK_EQ (b1.intersections ({100.f, 0.f}, {0.f, 100.f}), 1); 1u,
"intersect bezier-1 centre");
tap.expect_eq (b1.intersections ({100.f, 0.f}, {0.f, 100.f}),
1u,
"intersect bezier-1 centre");
// Coincident with endpoints // Coincident with endpoints
CHECK_EQ (b1.intersections ({0.f, 0.f}, {1.f,0.f}), 1); tap.expect_eq (b1.intersections ({0.f, 0.f}, {1.f,0.f}),
CHECK_EQ (b1.intersections ({100.f, 100.f}, {100.f,0.f}), 1); 1u,
"intersect bezier-1 endpoints");
tap.expect_eq (b1.intersections ({100.f, 100.f}, {100.f,0.f}),
1u,
"intersect bezier-1 endpoints");
// Co-planar // Co-planar
CHECK_EQ (b1.intersections ({0.f, 0.f}, {1.f, 1.f}), 1); tap.expect_eq (b1.intersections ({0.f, 0.f}, {1.f, 1.f}),
1u,
"intersect bezier-1 co-planar");
// Underneath // Underneath
CHECK_EQ (b1.intersections ({1000.f, -10.f}, {-1000.f, -10.f}), 0); tap.expect_eq (b1.intersections ({1000.f, -10.f}, {-1000.f, -10.f}),
0u,
"intersect bezier-1 under");
// Above // Above
CHECK_EQ (b1.intersections ({1000.f, 110.f}, {-1000.f, 110.f}), 0); tap.expect_eq (b1.intersections ({1000.f, 110.f}, {-1000.f, 110.f}),
0u,
"intersect bezier-1 above");
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
template <> template <>
void void
test_intersect<2> (void) test_intersect<2> (util::TAP::logger &tap)
{ {
// A linear curve from (0,0) to (100,100) // A linear curve from (0,0) to (100,100)
static const util::bezier<2> b2 ({{ 0.0f, 0.0f}, static const util::bezier<2> b2 ({{ 0.0f, 0.0f},
@ -112,29 +129,29 @@ test_intersect<2> (void)
{100.f, 100.f}}); {100.f, 100.f}});
// Through the centre // Through the centre
CHECK_EQ (b2.intersections ({100.f, 0.f}, {0.f, 100.f}), 1); tap.expect_eq (b2.intersections ({100.f, 0.f}, {0.f, 100.f}), 1, "intersect bezier-2 centre");
CHECK_EQ (b2.intersections ({0.f, 100.f}, {100.f, 0.f}), 1); tap.expect_eq (b2.intersections ({0.f, 100.f}, {100.f, 0.f}), 1, "intersect bezier-2 centre");
// Coincident with endpoints // Coincident with endpoints
CHECK_EQ (b2.intersections ({0.f, 0.f}, {0.f,100.f}), 1); tap.expect_eq (b2.intersections ({0.f, 0.f}, {0.f,100.f}), 1, "intersect bezier-2 endpoint");
CHECK_EQ (b2.intersections ({0.f, 0.f}, {100.f,0.f}), 1); tap.expect_eq (b2.intersections ({0.f, 0.f}, {100.f,0.f}), 1, "intersect bezier-2 endpoint");
CHECK_EQ (b2.intersections ({100.f, 100.f}, {100.f,0.f}), 1); tap.expect_eq (b2.intersections ({100.f, 100.f}, {100.f,0.f}), 1, "intersect bezier-2 endpoint");
// Co-planar // Co-planar
CHECK_EQ (b2.intersections ({0.f, 0.f}, {1.f, 1.f}), 1); tap.expect_eq (b2.intersections ({0.f, 0.f}, {1.f, 1.f}), 1, "intersect bezier-2 co-planar");
// Underneath // Underneath
CHECK_EQ (b2.intersections ({1000.f, -10.f}, {-1000.f, -10.f}), 0); tap.expect_eq (b2.intersections ({1000.f, -10.f}, {-1000.f, -10.f}), 0, "intersect bezier-2 under");
// Above // Above
CHECK_EQ (b2.intersections ({1000.f, 110.f}, {-1000.f, 110.f}), 0); tap.expect_eq (b2.intersections ({1000.f, 110.f}, {-1000.f, 110.f}), 0, "intersect bezier-2 above");
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
template <> template <>
void void
test_intersect<3> (void) test_intersect<3> (util::TAP::logger &tap)
{ {
// A linear curve from (0,0) to (100,100) // A linear curve from (0,0) to (100,100)
static const util::bezier<3> b3 ({{ 0.f, 0.f }, static const util::bezier<3> b3 ({{ 0.f, 0.f },
@ -143,29 +160,28 @@ test_intersect<3> (void)
{ 100.f, 100.f }}); { 100.f, 100.f }});
// Through the centre // Through the centre
CHECK_EQ (b3.intersections ({100.f, 0.f}, {0.f, 100.f}), 1); tap.expect_eq (b3.intersections ({100.f, 0.f}, {0.f, 100.f}), 1, "intersect bezier-3 centre");
CHECK_EQ (b3.intersections ({0.f, 100.f}, {100.f, 0.f}), 1);
// Coincident with endpoints // Coincident with endpoints
CHECK_EQ (b3.intersections ({0.f, 0.f}, {0.f,100.f}), 1); tap.expect_eq (b3.intersections ({0.f, 0.f}, {0.f,100.f}), 1, "intersect bezier-3 endpoint");
CHECK_EQ (b3.intersections ({0.f, 0.f}, {100.f,0.f}), 1); tap.expect_eq (b3.intersections ({0.f, 0.f}, {100.f,0.f}), 1, "intersect bezier-3 endpoint");
CHECK_EQ (b3.intersections ({100.f, 100.f}, {100.f,0.f}), 1); tap.expect_eq (b3.intersections ({100.f, 100.f}, {100.f,0.f}), 1, "intersect bezier-3 endpoint");
// Co-planar // Co-planar
CHECK_EQ (b3.intersections ({0.f, 0.f}, {1.f, 1.f}), 1); tap.expect_eq (b3.intersections ({0.f, 0.f}, {1.f, 1.f}), 1, "intersect bezier-3 co-planar");
// Underneath // Underneath
CHECK_EQ (b3.intersections ({1000.f, -10.f}, {-1000.f, -10.f}), 0); tap.expect_eq (b3.intersections ({1000.f, -10.f}, {-1000.f, -10.f}), 0, "intersect bezier-3 under");
// Above // Above
CHECK_EQ (b3.intersections ({1000.f, 110.f}, {-1000.f, 110.f}), 0); tap.expect_eq (b3.intersections ({1000.f, 110.f}, {-1000.f, 110.f}), 0, "intersect bezier-3 above");
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
template <> template <>
void void
test_region<1> (void) test_region<1> (util::TAP::logger &tap)
{ {
util::point2f p0 { 0, 0 }, util::point2f p0 { 0, 0 },
p1 { 100, 0 }, p1 { 100, 0 },
@ -177,17 +193,17 @@ test_region<1> (void)
static const util::bezier<1> vertical ({p0, p3}); static const util::bezier<1> vertical ({p0, p3});
static const util::bezier<1> horizontal ({p0, p2}); static const util::bezier<1> horizontal ({p0, p2});
CHECK_EQ (upright.region (), util::region2f (p0, p2)); tap.expect_eq (upright.region (), util::region2f (p0, p2), "bezier-1 region");
CHECK_EQ (downleft.region (), util::region2f (p0, p2)); tap.expect_eq (downleft.region (), util::region2f (p0, p2), "bezier-1 region");
CHECK_EQ (vertical.region (), util::region2f (p0, p3)); tap.expect_eq (vertical.region (), util::region2f (p0, p3), "bezier-1 region");
CHECK_EQ (horizontal.region (), util::region2f (p0, p2)); tap.expect_eq (horizontal.region (), util::region2f (p0, p2), "bezier-1 region");
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
template <> template <>
void void
test_region<2> (void) test_region<2> (util::TAP::logger &tap)
{ {
util::point2f p0 { 0, 0 }, util::point2f p0 { 0, 0 },
p1 { 50, 50 }, p1 { 50, 50 },
@ -195,14 +211,14 @@ test_region<2> (void)
static const util::bezier<2> upright({p0, p1, p2}); static const util::bezier<2> upright({p0, p1, p2});
CHECK_EQ (upright.region (), util::region2f (p0, p2)); tap.expect_eq (upright.region (), util::region2f (p0, p2), "bezier-2 region");
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
template <> template <>
void void
test_region<3> (void) test_region<3> (util::TAP::logger &tap)
{ {
util::point2f p0 { 0, 0 }, util::point2f p0 { 0, 0 },
p1 { 33, 33 }, p1 { 33, 33 },
@ -211,7 +227,7 @@ test_region<3> (void)
static const util::bezier<3> upright({p0, p1, p2, p3}); static const util::bezier<3> upright({p0, p1, p2, p3});
CHECK_EQ (upright.region (), util::region2f (p0, p3)); tap.expect_eq (upright.region (), util::region2f (p0, p3), "bezier-3 region");
} }
@ -219,17 +235,19 @@ test_region<3> (void)
int int
main (int, char**) main (int, char**)
{ {
test_eval<1> (); util::TAP::logger tap;
test_eval<2> ();
test_eval<3> ();
test_intersect<1> (); test_eval<1> (tap);
test_intersect<2> (); test_eval<2> (tap);
test_intersect<3> (); test_eval<3> (tap);
test_region<1> (); test_intersect<1> (tap);
test_region<2> (); test_intersect<2> (tap);
test_region<3> (); test_intersect<3> (tap);
test_region<1> (tap);
test_region<2> (tap);
test_region<3> (tap);
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }

View File

@ -1,51 +1,65 @@
#include "../bitwise.hpp" #include "bitwise.hpp"
#include "tap.hpp"
//-----------------------------------------------------------------------------
static void static void
test_rotate (void) { test_rotate (util::TAP::logger &tap)
CHECK_EQ (rotatel (uint8_t (0x0F), 0), 0x0F); {
CHECK_EQ (rotatel (uint8_t (0x0F), 4), 0xF0); tap.expect_eq (rotatel (uint8_t (0x0F), 0), 0x0F);
CHECK_EQ (rotatel (uint8_t (0xF0), 4), 0x0F); tap.expect_eq (rotatel (uint8_t (0x0F), 4), 0xF0);
CHECK_EQ (rotatel (uint8_t (0x0F), 8), 0x0F); tap.expect_eq (rotatel (uint8_t (0xF0), 4), 0x0F);
tap.expect_eq (rotatel (uint8_t (0x0F), 8), 0x0F);
CHECK_EQ (rotater (uint8_t (0x0F), 0), 0x0F); tap.expect_eq (rotater (uint8_t (0x0F), 0), 0x0F);
CHECK_EQ (rotater (uint8_t (0x0F), 4), 0xF0); tap.expect_eq (rotater (uint8_t (0x0F), 4), 0xF0);
CHECK_EQ (rotater (uint8_t (0xF0), 4), 0x0F); tap.expect_eq (rotater (uint8_t (0xF0), 4), 0x0F);
CHECK_EQ (rotater (uint8_t (0x0F), 8), 0x0F); tap.expect_eq (rotater (uint8_t (0x0F), 8), 0x0F);
CHECK_EQ (rotatel (uint16_t (0xABCD), 0), 0xABCD); tap.expect_eq (rotatel (uint16_t (0xABCD), 0), 0xABCD);
CHECK_EQ (rotatel (uint16_t (0xABCD), 4), 0xBCDA); tap.expect_eq (rotatel (uint16_t (0xABCD), 4), 0xBCDA);
CHECK_EQ (rotatel (uint16_t (0xABCD), 8), 0xCDAB); tap.expect_eq (rotatel (uint16_t (0xABCD), 8), 0xCDAB);
CHECK_EQ (rotatel (uint16_t (0xABCD), 12), 0xDABC); tap.expect_eq (rotatel (uint16_t (0xABCD), 12), 0xDABC);
CHECK_EQ (rotatel (uint16_t (0xABCD), 16), 0xABCD); tap.expect_eq (rotatel (uint16_t (0xABCD), 16), 0xABCD);
CHECK_EQ (rotater (uint16_t (0xABCD), 0), 0xABCD); tap.expect_eq (rotater (uint16_t (0xABCD), 0), 0xABCD);
CHECK_EQ (rotater (uint16_t (0xABCD), 4), 0xDABC); tap.expect_eq (rotater (uint16_t (0xABCD), 4), 0xDABC);
CHECK_EQ (rotater (uint16_t (0xABCD), 8), 0xCDAB); tap.expect_eq (rotater (uint16_t (0xABCD), 8), 0xCDAB);
CHECK_EQ (rotater (uint16_t (0xABCD), 12), 0xBCDA); tap.expect_eq (rotater (uint16_t (0xABCD), 12), 0xBCDA);
CHECK_EQ (rotater (uint16_t (0xABCD), 16), 0xABCD); tap.expect_eq (rotater (uint16_t (0xABCD), 16), 0xABCD);
CHECK_EQ (rotatel (uint32_t (0x12345670), 12), 0x45670123); tap.expect_eq (rotatel (uint32_t (0x12345670), 12), 0x45670123);
CHECK_EQ (rotater (uint32_t (0x12345670), 12), 0x67012345); tap.expect_eq (rotater (uint32_t (0x12345670), 12), 0x67012345);
CHECK_EQ (rotatel (uint64_t (0x1234567890ABCDEF), 12), 0x4567890ABCDEF123); tap.expect_eq (rotatel (uint64_t (0x1234567890ABCDEF), 12), 0x4567890ABCDEF123);
CHECK_EQ (rotater (uint64_t (0x1234567890ABCDEF), 12), 0xDEF1234567890ABC); tap.expect_eq (rotater (uint64_t (0x1234567890ABCDEF), 12), 0xDEF1234567890ABC);
} }
//-----------------------------------------------------------------------------
void void
test_reverse (void) { test_reverse (util::TAP::logger &tap)
{
size_t matches = 0;
for (unsigned i = 0; i < 256; ++i) { for (unsigned i = 0; i < 256; ++i) {
auto first = reverse<uint8_t> (i); auto first = reverse<uint8_t> (i);
auto last = reverse<uint8_t> (first); auto last = reverse<uint8_t> (first);
CHECK_EQ (last, i); if (last == i)
} matches++;
} }
tap.expect_eq (matches, 256, "exhaustive 8 bit reverse");
}
//-----------------------------------------------------------------------------
int int
main (int, char**) { main (int, char**)
test_rotate (); {
test_reverse (); util::TAP::logger tap;
test_rotate (tap);
test_reverse (tap);
return 0; return 0;
} }

View File

@ -2,6 +2,7 @@
#include "hash/adler.hpp" #include "hash/adler.hpp"
#include "hash/bsdsum.hpp" #include "hash/bsdsum.hpp"
#include "types.hpp" #include "types.hpp"
#include "tap.hpp"
#include "debug.hpp" #include "debug.hpp"
#include <cstdlib> #include <cstdlib>
@ -25,9 +26,11 @@ static const struct {
int int
main (int, char**) { main (int, char**) {
util::TAP::logger tap;
for (unsigned i = 0; i < elems (TESTS); ++i) { for (unsigned i = 0; i < elems (TESTS); ++i) {
CHECK_EQ (TESTS[i].adler, adler32 (TESTS[i].data, TESTS[i].size)); tap.expect_eq (TESTS[i].adler, adler32 (TESTS[i].data, TESTS[i].size), "adler checksum");
CHECK_EQ (TESTS[i].bsd, bsdsum (TESTS[i].data, TESTS[i].size)); tap.expect_eq (TESTS[i].bsd, bsdsum (TESTS[i].data, TESTS[i].size), "bsdsum checksum");
} }
return EXIT_SUCCESS; return EXIT_SUCCESS;

View File

@ -1,53 +1,51 @@
#include "colour.hpp" #include "colour.hpp"
#include "debug.hpp" #include "tap.hpp"
int int
main (int, char**) main (int, char**)
{ {
util::TAP::logger tap;
// Simple check for symbol visibility // Simple check for symbol visibility
CHECK_EQ (util::colour4f::WHITE.r, 1.f); tap.expect_eq (util::colour4f::WHITE, util::colour4f (1), "WHITE available");
CHECK_EQ (util::colour4f::WHITE.g, 1.f);
CHECK_EQ (util::colour4f::WHITE.b, 1.f);
CHECK_EQ (util::colour4f::WHITE.a, 1.f);
// Check casting works between intergral and floating formats // Check casting works between intergral and floating formats
{ {
util::colour4f f (1); util::colour4f f (1);
util::colour<4,uint8_t> u (255); util::colour<4,uint8_t> u (255);
CHECK_EQ (f.cast<uint8_t> (), u); tap.expect_eq (f.cast<uint8_t> (), u, "cast float to u8");
CHECK_EQ (u.cast<float> (), f); tap.expect_eq (u.cast<float> (), f, "cast u8 to float");
} }
// Check lookups are working // Check lookups are working
CHECK_EQ (util::colour4f::from_html ("white"), util::colour4f::WHITE); tap.expect_eq (util::colour4f::from_html ("white"), util::colour4f::WHITE, "HTML lookup");
CHECK_EQ (util::colour4f::from_x11 ("white"), util::colour4f::WHITE); tap.expect_eq ( util::colour4f::from_x11 ("white"), util::colour4f::WHITE, "X11 lookup");
// Check HSV conversions // Check HSV conversions
{ {
// white: hue is undefined // white: hue is undefined
auto white = util::rgb_to_hsv ({1,1,1}); auto white = util::rgb_to_hsv ({1,1,1});
CHECK_EQ (white.s, 0); tap.expect (exactly_equal (white.s, 0) && exactly_equal (white.v, 1), "white hsv");
CHECK_EQ (white.v, 1);
// black: hue is undefined // black: hue is undefined
auto black = util::rgb_to_hsv ({0,0,0}); auto black = util::rgb_to_hsv ({0,0,0});
CHECK_EQ (black.s, 0); tap.expect (exactly_equal (black.s, 0) && exactly_equal (black.v, 0), "black hsv");
CHECK_EQ (black.v, 0);
struct { struct {
const char *name;
util::colour3f rgb; util::colour3f rgb;
util::colour3f hsv; util::colour3f hsv;
} TESTS[] = { } TESTS[] = {
{ { 1, 0, 0, }, { 0, 1, 1, } }, // red { "red", { 1, 0, 0, }, { 0, 1, 1, } }, // red
{ { 0, 1, 0, }, { 120, 1, 1, } }, // green { "green", { 0, 1, 0, }, { 120, 1, 1, } }, // green
{ { 0, 0, 1, }, { 240, 1, 1, } }, // blue { "blue", { 0, 0, 1, }, { 240, 1, 1, } }, // blue
{ { 0.75f, 0.25f, 0.75f }, { 300, 2/3.f, 0.75f } }, { "misc", { 0.75f, 0.25f, 0.75f }, { 300, 2/3.f, 0.75f } },
}; };
for (auto i: TESTS) { for (auto i: TESTS) {
CHECK_EQ (util::rgb_to_hsv (i.rgb), i.hsv); tap.expect_eq (util::rgb_to_hsv (i.rgb), i.hsv, i.name);
CHECK_EQ (util::hsv_to_rgb (i.hsv), i.rgb); tap.expect_eq (util::hsv_to_rgb (i.hsv), i.rgb, i.name);
} }
} }
} }

View File

@ -1,9 +1,10 @@
#include "extent.hpp" #include "extent.hpp"
#include "debug.hpp" #include "tap.hpp"
int int
main (void) main (void)
{ {
// Simple symbol visibility check util::TAP::logger tap;
util::extent2f instance; util::extent2f instance;
tap.todo ("instancing test");
} }

View File

@ -1,10 +1,10 @@
#include "fixed.hpp" #include "fixed.hpp"
#include "debug.hpp" #include "tap.hpp"
template <typename T, unsigned I, unsigned E> template <typename T, unsigned I, unsigned E>
void void
test_simple (void) test_simple (util::TAP::logger &tap)
{ {
using fixed_t = util::fixed<T,I,E>; using fixed_t = util::fixed<T,I,E>;
using integer_t = typename fixed_t::integer_t; using integer_t = typename fixed_t::integer_t;
@ -12,30 +12,35 @@ test_simple (void)
const fixed_t lo = integer_t{0}; const fixed_t lo = integer_t{0};
const fixed_t hi = integer_t{1}; const fixed_t hi = integer_t{1};
CHECK_EQ (lo, lo); std::ostringstream os;
CHECK_EQ (hi, hi); os << "fixed<" << type_to_string<T> () << ',' << I << ',' << E << '>';
CHECK_NEQ (hi, lo); tap.expect_eq (lo, lo, os.str () + " self equality");
CHECK_NEQ (lo, hi); tap.expect_eq (hi, hi, os.str () + " self equality");
CHECK_LT (lo, hi); tap.expect_neq (hi, lo, os.str () + " inequality");
CHECK_LE (lo, hi); tap.expect_neq (lo, hi, os.str () + " inequality");
CHECK_LE (lo, lo);
CHECK_GT (hi, lo); tap.expect_lt (lo, hi, os.str () + " less than");
CHECK_GE (lo, lo); tap.expect_le (lo, hi, os.str () + " less than equal");
CHECK_GE (hi, lo); tap.expect_le (lo, lo, os.str () + " less than equal");
tap.expect_gt (hi, lo, os.str () + " greater than");
tap.expect_ge (lo, lo, os.str () + " greater than equal");
tap.expect_ge (hi, lo, os.str () + " greater than equal");
} }
int int
main (void) main (void)
{ {
test_simple<signed,16,16> (); util::TAP::logger tap;
test_simple<signed,26, 6> ();
test_simple<signed,32,32> ();
test_simple<unsigned,16,16> (); test_simple<signed,16,16> (tap);
test_simple<unsigned,26, 6> (); test_simple<signed,26, 6> (tap);
test_simple<unsigned,32,32> (); test_simple<signed,32,32> (tap);
test_simple<unsigned,16,16> (tap);
test_simple<unsigned,26, 6> (tap);
test_simple<unsigned,32,32> (tap);
} }

View File

@ -1,7 +1,8 @@
#include "../float.hpp" #include "float.hpp"
#include "../debug.hpp" #include "debug.hpp"
#include "../types.hpp" #include "tap.hpp"
#include "types.hpp"
#include <limits> #include <limits>
@ -72,4 +73,7 @@ int
main (int, char **) { main (int, char **) {
test_single (); test_single ();
test_double (); test_double ();
util::TAP::logger tap;
tap.todo ("convert to TAP");
} }

View File

@ -3,6 +3,7 @@
#include "debug.hpp" #include "debug.hpp"
#include "hash/md5.hpp" #include "hash/md5.hpp"
#include "hash/sha1.hpp" #include "hash/sha1.hpp"
#include "tap.hpp"
#include "types.hpp" #include "types.hpp"
#include <cstring> #include <cstring>
@ -279,5 +280,8 @@ main (int, char**)
return EXIT_FAILURE; return EXIT_FAILURE;
} }
util::TAP::logger tap;
tap.todo ("convert to TAP");
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }

View File

@ -1,7 +1,8 @@
#include "hash/hotp.hpp" #include "hash/hotp.hpp"
#include "types.hpp"
#include "debug.hpp" #include "debug.hpp"
#include "tap.hpp"
#include "types.hpp"
using util::hash::HOTP; using util::hash::HOTP;
@ -25,4 +26,7 @@ main (int, char**)
for (size_t i = 0; i < elems (EXPECTED); ++i) for (size_t i = 0; i < elems (EXPECTED); ++i)
CHECK_EQ (EXPECTED[i], h.value ()); CHECK_EQ (EXPECTED[i], h.value ());
util::TAP::logger tap;
tap.todo ("convert to TAP");
} }

View File

@ -1,8 +1,9 @@
#include "../endian.hpp" #include "endian.hpp"
#include "../debug.hpp" #include "debug.hpp"
#include "../platform.hpp" #include "tap.hpp"
#include "platform.hpp"
#include <cstdlib> #include <cstdlib>
#if defined(PLATFORM_WIN32) #if defined(PLATFORM_WIN32)
@ -12,8 +13,6 @@
#include <netinet/in.h> #include <netinet/in.h>
#endif #endif
using namespace std;
int int
main (int, char **) { main (int, char **) {
@ -27,5 +26,6 @@ main (int, char **) {
CHECK_EQ (ntohs (u16), hton (u16)); CHECK_EQ (ntohs (u16), hton (u16));
CHECK_EQ (ntohl (u32), hton (u32)); CHECK_EQ (ntohl (u32), hton (u32));
return EXIT_SUCCESS; util::TAP::logger tap;
tap.todo ("convert to TAP");
} }

View File

@ -1,9 +1,10 @@
#include "../ip.hpp" #include "ip.hpp"
#include "../debug.hpp" #include "debug.hpp"
#include "../platform.hpp" #include "platform.hpp"
#include "../types.hpp" #include "tap.hpp"
#include "types.hpp"
#include <cstdlib> #include <cstdlib>
@ -26,5 +27,6 @@ main (int, char **) {
CHECK (parsed == data[i].ip); CHECK (parsed == data[i].ip);
} }
return EXIT_SUCCESS; util::TAP::logger tap;
tap.todo ("convert to TAP");
} }

View File

@ -1,13 +1,14 @@
#include "json/tree.hpp"
#include "../debug.hpp" #include "debug.hpp"
#include "../json/tree.hpp" #include "maths.hpp"
#include "../maths.hpp" #include "tap.hpp"
#include <memory> #include <memory>
#include <cstdlib> #include <cstdlib>
int int
main (int, char**) { main (void) {
static const char TEST_STRING[] = R"_( static const char TEST_STRING[] = R"_(
{ {
"string":"brad", "string":"brad",
@ -100,5 +101,6 @@ main (int, char**) {
CHECK (!ref["array"].is_object ()); CHECK (!ref["array"].is_object ());
CHECK (!ref["array"].is_string ()); CHECK (!ref["array"].is_string ());
return EXIT_SUCCESS; util::TAP::logger tap;
tap.skip ("convert to TAP");
} }

View File

@ -1,5 +1,7 @@
#include "../debug.hpp" #include "maths.hpp"
#include "../maths.hpp"
#include "debug.hpp"
#include "tap.hpp"
#include <cstdlib> #include <cstdlib>
#include <cmath> #include <cmath>
@ -125,5 +127,6 @@ main (int, char **) {
CHECK_EQ (log2up (8u), 3); CHECK_EQ (log2up (8u), 3);
CHECK_EQ (log2up (1u), 0); CHECK_EQ (log2up (1u), 0);
return EXIT_SUCCESS; util::TAP::logger tap;
tap.todo ("conver to TAP");
} }

View File

@ -1,6 +1,8 @@
#include "../debug.hpp" #include "maths/matrix.hpp"
#include "../maths/matrix.hpp"
#include "../maths.hpp" #include "debug.hpp"
#include "maths.hpp"
#include "tap.hpp"
#include <iostream> #include <iostream>
#include <cmath> #include <cmath>
@ -52,7 +54,7 @@ test_identity (const matrix &m) {
int int
main (int, char **) { main (void) {
for (unsigned int i = 1; i < 10; ++i) { for (unsigned int i = 1; i < 10; ++i) {
test_zeroes (matrix::zeroes (i)); test_zeroes (matrix::zeroes (i));
test_identity (matrix::identity (i)); test_identity (matrix::identity (i));
@ -129,5 +131,6 @@ main (int, char **) {
CHECK ( matrix::identity (3).is_homogeneous ()); CHECK ( matrix::identity (3).is_homogeneous ());
CHECK (invertible4.is_homogeneous ()); CHECK (invertible4.is_homogeneous ());
return EXIT_SUCCESS; util::TAP::logger tap;
tap.skip ("convert to TAP");
} }

View File

@ -1,11 +1,13 @@
#include "matrix.hpp" #include "matrix.hpp"
#include "vector.hpp"
#include "debug.hpp" #include "debug.hpp"
#include "tap.hpp"
#include "vector.hpp"
#include <cstdlib> #include <cstdlib>
int int
main (int, char **) { main (void) {
{ {
// Identity matrix-vector multiplication // Identity matrix-vector multiplication
auto v = util::vector<4,float> { 1.f, 2.f, 3.f, 4.f }; auto v = util::vector<4,float> { 1.f, 2.f, 3.f, 4.f };
@ -93,5 +95,6 @@ main (int, char **) {
CHECK_EQ (m.inverse (), r / 40.f); CHECK_EQ (m.inverse (), r / 40.f);
} }
return EXIT_SUCCESS; util::TAP::logger tap;
tap.skip ("convert to TAP");
} }

View File

@ -1,4 +1,6 @@
#include "../hash/md2.hpp" #include "hash/md2.hpp"
#include "tap.hpp"
using util::hash::MD2; using util::hash::MD2;
@ -56,5 +58,7 @@ main (int, char **) {
} }
} }
return success ? 0 : 1; util::TAP::logger tap;
tap.expect (success, "test vectors");
return tap.status ();
} }

View File

@ -1,4 +1,6 @@
#include "../hash/md4.hpp" #include "hash/md4.hpp"
#include "tap.hpp"
#include <cstring> #include <cstring>
#include <iostream> #include <iostream>
@ -64,5 +66,7 @@ main (int, char**) {
} }
} }
return success ? 0 : 1; util::TAP::logger tap;
tap.expect (success, "test vectors");
return tap.status ();
} }

View File

@ -1,4 +1,6 @@
#include "../hash/md5.hpp" #include "hash/md5.hpp"
#include "tap.hpp"
#include <iostream> #include <iostream>
#include <cstring> #include <cstring>
@ -55,5 +57,7 @@ main (int, char**) {
} }
} }
return success ? 0 : 1; util::TAP::logger tap;
tap.expect (success, "test vectors");
return tap.status ();
} }

View File

@ -1,6 +1,7 @@
#include "options.hpp" #include "options.hpp"
#include "debug.hpp" #include "debug.hpp"
#include "tap.hpp"
#include "types.hpp" #include "types.hpp"
#include <cassert> #include <cassert>
@ -271,4 +272,7 @@ main (int, char **) {
test_bytes_opt (); test_bytes_opt ();
test_insert_remove_opt (); test_insert_remove_opt ();
test_required (); test_required ();
util::TAP::logger tap;
tap.todo ("convert to TAP");
} }

View File

@ -2,6 +2,7 @@
#include "point.hpp" #include "point.hpp"
#include "debug.hpp" #include "debug.hpp"
#include "tap.hpp"
#include "types.hpp" #include "types.hpp"
using namespace util; using namespace util;
@ -55,4 +56,7 @@ main (int, char**) {
CHECK_EQ (q.z, 0); CHECK_EQ (q.z, 0);
CHECK_EQ (q.w, 1); CHECK_EQ (q.w, 1);
} }
util::TAP::logger tap;
tap.todo ("convert to TAP");
} }

View File

@ -1,6 +1,7 @@
#include "debug.hpp" #include "debug.hpp"
#include "pool.hpp" #include "pool.hpp"
#include "tap.hpp"
#include <set> #include <set>
#include <vector> #include <vector>
@ -83,4 +84,7 @@ main (int, char **) {
check_single (); check_single ();
check_unique_ptr (); check_unique_ptr ();
check_keep_value (); check_keep_value ();
util::TAP::logger tap;
tap.skip ("convert to TAP");
} }

View File

@ -1,5 +1,6 @@
#include "../random.hpp" #include "random.hpp"
#include "../debug.hpp" #include "debug.hpp"
#include "tap.hpp"
#include <iostream> #include <iostream>
#include <cmath> #include <cmath>
@ -55,5 +56,6 @@ main (int, char **) {
test_bool (); test_bool ();
test_float (); test_float ();
return EXIT_SUCCESS; util::TAP::logger tap;
tap.skip ("convert to TAP");
} }

View File

@ -1,9 +1,10 @@
#include "debug.hpp"
#include "range.hpp"
#include "tap.hpp"
#include <cstdlib> #include <cstdlib>
#include <limits> #include <limits>
#include "../debug.hpp"
#include "../range.hpp"
using namespace std; using namespace std;
using namespace util; using namespace util;
@ -49,6 +50,7 @@ main (int, char **) {
CHECK_EQ (initial_nan.max, 1.0); CHECK_EQ (initial_nan.max, 1.0);
} }
return EXIT_SUCCESS; util::TAP::logger tap;
tap.skip ("convert to TAP");
} }

View File

@ -1,7 +1,8 @@
#include "ray.hpp"
#include "plane.hpp"
#include "debug.hpp"
#include "aabb.hpp" #include "aabb.hpp"
#include "debug.hpp"
#include "plane.hpp"
#include "ray.hpp"
#include "tap.hpp"
void void
@ -33,9 +34,19 @@ test_intersect_aabb (void)
} }
void
test_intersect_sphere (void)
{
}
int int
main (void) main (void)
{ {
test_intersect_plane (); test_intersect_plane ();
test_intersect_aabb (); test_intersect_aabb ();
util::TAP::logger tap;
tap.todo ("convert to TAP");
} }

View File

@ -1,6 +1,8 @@
#include "../region.hpp" #include "region.hpp"
#include "../point.hpp"
#include "../debug.hpp" #include "debug.hpp"
#include "point.hpp"
#include "tap.hpp"
using namespace util; using namespace util;
@ -39,5 +41,6 @@ main (int, char **) {
//CHECK (region<2,intmax_t> (0, 0, 10, 10).includes (point2d (0.4, 0.01))); //CHECK (region<2,intmax_t> (0, 0, 10, 10).includes (point2d (0.4, 0.01)));
//CHECK (region<2,intmax_t> (0, 0, 10, 10).contains (point2d (0.4, 0.01))); //CHECK (region<2,intmax_t> (0, 0, 10, 10).contains (point2d (0.4, 0.01)));
return 0; util::TAP::logger tap;
tap.skip ("convert to TAP");
} }

View File

@ -1,6 +1,8 @@
#include "../debug.hpp" #include "hash/ripemd.hpp"
#include "../types.hpp"
#include "../hash/ripemd.hpp" #include "debug.hpp"
#include "tap.hpp"
#include "types.hpp"
#include <cstdlib> #include <cstdlib>
#include <cstring> #include <cstring>
@ -132,5 +134,6 @@ main(int, char**) {
}; };
CHECK (obj.digest () == MILLION); CHECK (obj.digest () == MILLION);
return EXIT_SUCCESS; util::TAP::logger tap;
tap.skip ("convert to TAP");
} }

View File

@ -1,7 +1,8 @@
#include "../hash/sha1.hpp" #include "hash/sha1.hpp"
#include "../debug.hpp" #include "debug.hpp"
#include "../types.hpp" #include "tap.hpp"
#include "types.hpp"
#include <cstdlib> #include <cstdlib>
#include <cstring> #include <cstring>
@ -68,5 +69,6 @@ main (int, char**) {
CHECK (obj.digest () == i.output); CHECK (obj.digest () == i.output);
} }
return 0; util::TAP::logger tap;
tap.skip ("convert to TAP");
} }

View File

@ -1,6 +1,7 @@
#include "../hash/sha2.hpp" #include "hash/sha2.hpp"
#include "../debug.hpp" #include "debug.hpp"
#include "tap.hpp"
#include <cstring> #include <cstring>
@ -56,5 +57,6 @@ main (int, char **) {
CHECK (obj.digest () == i.output); CHECK (obj.digest () == i.output);
} }
return 0; util::TAP::logger tap;
tap.skip ("convert to TAP");
} }

View File

@ -1,8 +1,8 @@
#include <cstdlib>
#include "signal.hpp" #include "signal.hpp"
#include "debug.hpp" #include "debug.hpp"
#include "raii.hpp" #include "raii.hpp"
#include "tap.hpp"
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@ -129,5 +129,6 @@ main (int, char **)
test_combiner (); test_combiner ();
test_disconnect (); test_disconnect ();
return EXIT_SUCCESS; util::TAP::logger tap;
tap.skip ("convert to TAP");
} }

View File

@ -1,14 +0,0 @@
#!/bin/sh
tests=($(find "@abs_top_builddir@/test/" -type f -executable | grep -v ".test$"))
echo 1..$((${#tests[@]}))
for i in ${tests[@]};
do
$i 2>/dev/null 1>&2
case $? in
0) echo "ok - $(basename $i)";;
*) echo "not ok - $(basename $i)";;
esac
done

View File

@ -1,24 +1,7 @@
/* #include "stringid.hpp"
* This file is part of libgim.
*
* libgim is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* libgim is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License
* along with libgim. If not, see <http://www.gnu.org/licenses/>.
*
* Copyright 2014 Danny Robson <danny@nerdcruft.net>
*/
#include "../stringid.hpp" #include "debug.hpp"
#include "../debug.hpp" #include "tap.hpp"
#include <cstdlib> #include <cstdlib>
#include <stdexcept> #include <stdexcept>
@ -38,5 +21,6 @@ main (int, char**) {
CHECK_EQ (id1 + 1, id2); CHECK_EQ (id1 + 1, id2);
CHECK_EQ (id1, map.find ("first")); CHECK_EQ (id1, map.find ("first"));
return EXIT_SUCCESS; util::TAP::logger tap;
tap.skip ("convert to TAP");
} }

View File

@ -1,6 +1,7 @@
#include "uri.hpp" #include "uri.hpp"
#include "debug.hpp" #include "debug.hpp"
#include "tap.hpp"
int int
main (void) main (void)
@ -41,4 +42,7 @@ main (void)
for (auto i: BAD) for (auto i: BAD)
CHECK_THROWS (util::uri::parse_error, util::uri foo (i)); CHECK_THROWS (util::uri::parse_error, util::uri foo (i));
util::TAP::logger tap;
tap.skip ("convert to TAP");
} }

View File

@ -1,6 +1,7 @@
#include "vector.hpp" #include "vector.hpp"
#include "maths.hpp" #include "maths.hpp"
#include "tap.hpp"
using util::vector; using util::vector;
using util::vector2f; using util::vector2f;
@ -64,4 +65,7 @@ int
main () main ()
{ {
test_polar (); test_polar ();
util::TAP::logger test;
test.skip ("convert to TAP");
} }

View File

@ -1,6 +1,7 @@
#include "version.hpp"
#include "../version.hpp" #include "debug.hpp"
#include "../debug.hpp" #include "tap.hpp"
#include <string> #include <string>
#include <vector> #include <vector>
@ -17,7 +18,7 @@ struct parsed_version {
int int
main (int, char **) { main () {
vector <parsed_version> tests ({ vector <parsed_version> tests ({
{ "1", { 1 } }, { "1", { 1 } },
@ -47,5 +48,6 @@ main (int, char **) {
CHECK_LE (i->parts.size (), 4); CHECK_LE (i->parts.size (), 4);
} }
return EXIT_SUCCESS; util::TAP::logger tap;
tap.skip ("convert to TAP");
} }