1 #define BOOST_TEST_MODULE config
2 #define BOOST_TEST_DYN_LINK
3 #include <boost/test/unit_test.hpp>
5 #include <boost/numeric/ublas/io.hpp>
7 #include "flame/util.h"
9 BOOST_AUTO_TEST_CASE(parse_table_empty)
11 std::istringstream strm;
16 BOOST_CHECK_EQUAL(tbl.table.size1(), 0);
17 BOOST_CHECK_EQUAL(tbl.table.size2(), 0);
18 BOOST_CHECK_EQUAL(tbl.colnames.size(), 0);
21 static const char table1[] = {
28 BOOST_AUTO_TEST_CASE(parse_table1)
30 std::istringstream strm(table1);
35 BOOST_CHECK_EQUAL(tbl.table.size1(), 3);
36 BOOST_CHECK_EQUAL(tbl.table.size2(), 2);
37 BOOST_CHECK_EQUAL(tbl.colnames.size(), 2);
39 BOOST_CHECK_EQUAL(tbl.colnames[
"A"], 0);
40 BOOST_CHECK_EQUAL(tbl.colnames[
"B"], 1);
42 std::ostringstream out;
45 BOOST_CHECK_EQUAL(out.str(),
"[3,2]((12,13),(14,15),(16,17))");
48 static const char table2[] = {
55 BOOST_AUTO_TEST_CASE(parse_table2)
57 std::istringstream strm(table2);
62 BOOST_CHECK_EQUAL(tbl.table.size1(), 3);
63 BOOST_CHECK_EQUAL(tbl.table.size2(), 2);
64 BOOST_CHECK_EQUAL(tbl.colnames.size(), 0);
66 std::ostringstream out;
69 BOOST_CHECK_EQUAL(out.str(),
"[3,2]((12,13),(14,15),(16,17))");
72 static const char table3[] = {
78 BOOST_AUTO_TEST_CASE(parse_table3)
80 std::istringstream strm(table3);
83 BOOST_CHECK_THROW(tbl.read(strm), std::runtime_error)
86 static const char table4[] = {
93 BOOST_AUTO_TEST_CASE(parse_table4)
95 std::istringstream strm(table4);
98 BOOST_CHECK_THROW(tbl.read(strm), std::runtime_error)
101 BOOST_AUTO_TEST_CASE(test_ndindex_iterate)
103 size_t limits[2] = {2,3};
106 BOOST_CHECK(!iter.done);
107 BOOST_CHECK_EQUAL(iter.ndim, 2);
108 BOOST_CHECK_EQUAL_COLLECTIONS(limits, limits+2, iter.limit, iter.limit+2);
110 #define CHECKME(isdone, I, J) {size_t P[2] = {I,J}; BOOST_CHECK_EQUAL(isdone, iter.done); \
111 BOOST_CHECK_EQUAL_COLLECTIONS(P, P+2, iter.index, iter.index+2); }
113 CHECKME(
false, 0, 0);
115 CHECKME(
false, 1, 0);
117 CHECKME(
false, 0, 1);
119 CHECKME(
false, 1, 1);
121 CHECKME(
false, 0, 2);
123 CHECKME(
false, 1, 2);
Helper to step through the indicies of an Nd array.