Update mussa to build on ubuntu 10.04 with qt 4.6.2 +boost 1.40.0.1
[mussa.git] / alg / test / test_drawable.cpp
index e3afd703ed224e3e98227d5fddaa180e70da5b72..391427670985dfebdcef97a2c138795eaf514eca 100644 (file)
@@ -1,9 +1,11 @@
-#define BOOST_AUTO_TEST_MAIN
-#include <boost/test/auto_unit_test.hpp>
+#define BOOST_TEST_DYN_LINK
+#define BOOST_TEST_MODULE test_drawable
+#include <boost/test/unit_test.hpp>
 
 #include <boost/shared_ptr.hpp>
 
 #include "drawable.hpp"
+#include "seq_span.hpp"
 
 BOOST_AUTO_TEST_CASE( drawable_empty_constructors )
 {
@@ -64,4 +66,36 @@ BOOST_AUTO_TEST_CASE( drawable_copyref_constructor )
   BOOST_CHECK_EQUAL(*asp->color(), *grey);
   BOOST_CHECK_EQUAL(*bsp->color(), *grey);
   BOOST_CHECK_EQUAL(*csp->color(), *black); 
-}
\ No newline at end of file
+}
+
+void test_draw_func_null(SeqSpanRef r, float, float)
+{
+}
+
+BOOST_AUTO_TEST_CASE( drawable_null_draw_func )
+{
+  ColorRef white(new Color(1.0, 1.0, 1.0));  
+  DrawableRef asp(new Drawable(1.0,1.0,1.0,1.0, white, test_draw_func_null));
+  
+  BOOST_CHECK_EQUAL(asp->drawFunction(), test_draw_func_null);
+  
+  DrawableRef bsp(asp);
+  BOOST_CHECK_EQUAL(bsp->drawFunction(), test_draw_func_null);
+}
+
+void test_draw_func_find_drawable(SeqSpanRef ref, float l, float r)
+{
+  BOOST_REQUIRE(ref->drawable());
+  BOOST_REQUIRE_EQUAL(ref->drawable()->drawFunction(), test_draw_func_find_drawable);
+}
+
+BOOST_AUTO_TEST_CASE( test_drawable_find_drawable )
+{
+  ColorRef white(new Color(1.0, 1.0, 1.0));  
+  DrawableRef drawsp(new Drawable(1.0,1.0,1.0,1.0, white, test_draw_func_find_drawable));
+  SeqSpanRef ssp(new SeqSpan("AAAA"));
+  ssp->setDrawable(drawsp);
+     
+  BOOST_CHECK_EQUAL(drawsp->drawFunction(), test_draw_func_find_drawable);
+  ssp->drawable()->drawFunction();
+}