implement a color mapper class
[mussa.git] / alg / test / test_annotation_color.cpp
diff --git a/alg/test/test_annotation_color.cpp b/alg/test/test_annotation_color.cpp
new file mode 100644 (file)
index 0000000..af7035b
--- /dev/null
@@ -0,0 +1,40 @@
+#include <boost/test/auto_unit_test.hpp>
+
+#include "alg/annotation_colors.hpp"
+#include "alg/color.hpp"
+
+BOOST_AUTO_TEST_CASE( simple_annot_colors )
+{
+  Color black(0.0, 0.0, 0.0);
+  Color white(1.0, 1.0, 1.0);
+  Color red(1.0, 0.0, 0.0);
+
+  AnnotationColors ac;
+
+  ac.setColor(white);
+  BOOST_CHECK_EQUAL( ac.color(), white);
+
+  ac.appendTypeColor("bleem", black);
+  BOOST_CHECK_EQUAL( ac.typeColor("bleem"), black );
+  // FIXME: it'd be nice if something like this worked?
+  //BOOST_CHECK_RAISES( ac.typeColor("not found"), not_found );
+  ac.appendInstanceColor("bleem", "a", red);
+  BOOST_CHECK_EQUAL( ac.instanceColor("bleem", "a"), red);
+  BOOST_CHECK_EQUAL( ac.lookup("bleem", "a"), red );
+  BOOST_CHECK_EQUAL( ac.lookup("bleem", "foo"), black );
+  BOOST_CHECK_EQUAL( ac.lookup("venchent", "a"), white );
+
+  annot a;
+  a.start = 30;
+  a.end = 45;
+  a.type = "bleem";
+  a.name = "a";
+  
+  BOOST_CHECK_EQUAL( ac.lookup(a), red );
+  a.name = "b";
+  BOOST_CHECK_EQUAL( ac.lookup(a), black );
+  a.type = "venchent";
+  BOOST_CHECK_EQUAL( ac.lookup(a), white );
+}
+