summaryrefslogtreecommitdiff
path: root/klm/util/joint_sort_test.cc
diff options
context:
space:
mode:
authorredpony <redpony@ec762483-ff6d-05da-a07a-a48fb63a330f>2010-10-18 23:24:01 +0000
committerredpony <redpony@ec762483-ff6d-05da-a07a-a48fb63a330f>2010-10-18 23:24:01 +0000
commite0ef743090038ee02d656cee11debd2246624ba0 (patch)
treee5e1d32402c8dcb490c574e24c087c56d4cc172e /klm/util/joint_sort_test.cc
parent0c2514868f58bbfe422aa275e2905182cf2f57eb (diff)
kenneth's LM preliminary integration
git-svn-id: https://ws10smt.googlecode.com/svn/trunk@681 ec762483-ff6d-05da-a07a-a48fb63a330f
Diffstat (limited to 'klm/util/joint_sort_test.cc')
-rw-r--r--klm/util/joint_sort_test.cc50
1 files changed, 50 insertions, 0 deletions
diff --git a/klm/util/joint_sort_test.cc b/klm/util/joint_sort_test.cc
new file mode 100644
index 00000000..4dc85916
--- /dev/null
+++ b/klm/util/joint_sort_test.cc
@@ -0,0 +1,50 @@
+#include "util/joint_sort.hh"
+
+#define BOOST_TEST_MODULE JointSortTest
+#include <boost/test/unit_test.hpp>
+
+namespace util { namespace {
+
+BOOST_AUTO_TEST_CASE(just_flip) {
+ char keys[2];
+ int values[2];
+ keys[0] = 1; values[0] = 327;
+ keys[1] = 0; values[1] = 87897;
+ JointSort<char *, int *>(keys + 0, keys + 2, values + 0);
+ BOOST_CHECK_EQUAL(0, keys[0]);
+ BOOST_CHECK_EQUAL(87897, values[0]);
+ BOOST_CHECK_EQUAL(1, keys[1]);
+ BOOST_CHECK_EQUAL(327, values[1]);
+}
+
+BOOST_AUTO_TEST_CASE(three) {
+ char keys[3];
+ int values[3];
+ keys[0] = 1; values[0] = 327;
+ keys[1] = 2; values[1] = 87897;
+ keys[2] = 0; values[2] = 10;
+ JointSort<char *, int *>(keys + 0, keys + 3, values + 0);
+ BOOST_CHECK_EQUAL(0, keys[0]);
+ BOOST_CHECK_EQUAL(1, keys[1]);
+ BOOST_CHECK_EQUAL(2, keys[2]);
+}
+
+BOOST_AUTO_TEST_CASE(char_int) {
+ char keys[4];
+ int values[4];
+ keys[0] = 3; values[0] = 327;
+ keys[1] = 1; values[1] = 87897;
+ keys[2] = 2; values[2] = 10;
+ keys[3] = 0; values[3] = 24347;
+ JointSort<char *, int *>(keys + 0, keys + 4, values + 0);
+ BOOST_CHECK_EQUAL(0, keys[0]);
+ BOOST_CHECK_EQUAL(24347, values[0]);
+ BOOST_CHECK_EQUAL(1, keys[1]);
+ BOOST_CHECK_EQUAL(87897, values[1]);
+ BOOST_CHECK_EQUAL(2, keys[2]);
+ BOOST_CHECK_EQUAL(10, values[2]);
+ BOOST_CHECK_EQUAL(3, keys[3]);
+ BOOST_CHECK_EQUAL(327, values[3]);
+}
+
+}} // namespace anonymous util