-#define BOOST_AUTO_TEST_MAIN
-#include <boost/test/auto_unit_test.hpp>
+#define BOOST_TEST_DYN_LINK
+#define BOOST_TEST_MODULE test_glsequence
+#include <boost/test/unit_test.hpp>
#include <boost/test/floating_point_comparison.hpp>
#include <boost/shared_ptr.hpp>
BOOST_AUTO_TEST_CASE ( glsequence_operator_assignment )
{
boost::shared_ptr<AnnotationColors> cm(new AnnotationColors);
- // I don't trust my operator= hack so lets make sure it works.
string s0("AAGGCCTT");
string s1("TTGGCCAA");
Sequence seq0(s0);
BOOST_CHECK( glseq0.get_sequence() == s1 );
}
+BOOST_AUTO_TEST_CASE( glsequence_copy_constructor )
+{
+ boost::shared_ptr<AnnotationColors> cm(new AnnotationColors);
+ string s0("AAAAAAGGGGGG");
+
+ GlSequenceRef glsp0(new GlSequence(s0, cm));
+ glsp0->setY(100.0);
+ BOOST_CHECK_EQUAL(glsp0->get_sequence(), s0);
+ BOOST_CHECK_EQUAL(glsp0->y(), 100.0);
+
+ GlSequenceRef glsp0ref(glsp0);
+ GlSequenceRef glsp0copy(new GlSequence(glsp0));
+ BOOST_CHECK_EQUAL(glsp0->get_sequence(), s0);
+ BOOST_CHECK_EQUAL(glsp0->y(), 100.0);
+ BOOST_CHECK_EQUAL(glsp0ref->get_sequence(), s0);
+ BOOST_CHECK_EQUAL(glsp0ref->y(), 100.0);
+ BOOST_CHECK_EQUAL(glsp0copy->get_sequence(), s0);
+ BOOST_CHECK_EQUAL(glsp0copy->y(), 100.0);
+
+ glsp0ref->setY(50.0);
+ BOOST_CHECK_EQUAL(glsp0->y(), 50.0);
+ BOOST_CHECK_EQUAL(glsp0ref->y(), 50.0);
+ BOOST_CHECK_EQUAL(glsp0copy->y(), 100.0);
+
+ glsp0copy->setY(75.0);
+ BOOST_CHECK_EQUAL(glsp0->y(), 50.0);
+ BOOST_CHECK_EQUAL(glsp0ref->y(), 50.0);
+ BOOST_CHECK_EQUAL(glsp0copy->y(), 75.0);
+}
+
BOOST_AUTO_TEST_CASE( glsequence_color )
{
boost::shared_ptr<AnnotationColors> cm(new AnnotationColors);
BOOST_CHECK_EQUAL( *(s.color()), *c );
}
+BOOST_AUTO_TEST_CASE( glsequence_find_real_sequence )
+{
+ boost::shared_ptr<AnnotationColors> cm(new AnnotationColors);
+ GlSequence s("AAAAAAAAAANNNNNANNA", cm);
+ // 0123456789012345678
+ s.add_annotations_for_defined_sequence();
+
+ BOOST_CHECK_EQUAL(s.annotations().size(), 3);
+ std::vector<SeqSpanRef> annot(s.annotations().begin(), s.annotations().end());
+ BOOST_CHECK_EQUAL(annot[0]->start(), 0);
+ BOOST_CHECK_EQUAL(annot[0]->stop(), 10);
+ BOOST_CHECK_EQUAL(annot[1]->start(), 15);
+ BOOST_CHECK_EQUAL(annot[1]->size(), 1);
+ BOOST_CHECK_EQUAL(annot[2]->start(), 18);
+ BOOST_CHECK_EQUAL(annot[2]->size(), 1);
+}
+
+void dummy_draw_func(SeqSpanRef ref, float l, float r)
+{
+}
+
+BOOST_AUTO_TEST_CASE( glsequence_set_annotation_drawfunc_by_type )
+{
+ ColorRef default_color(new Color(1.0, 0.0, 0.0));
+ boost::shared_ptr<AnnotationColors> cm(new AnnotationColors);
+ GlSequence s("AAAAGGGGNNNNTTTTCCC", cm);
+ // 0123456789012345678
+ s.add_annotation("Aname", "value", 0, 4);
+ s.add_annotation("Gname", "value", 4, 4);
+ s.add_annotation("Tname", "gene", 12, 4);
+ s.update_annotation_draw_function("gene", dummy_draw_func, default_color);
+
+ BOOST_CHECK_EQUAL(s.annotations().size(), 3);
+ std::vector<SeqSpanRef> annot(s.annotations().begin(), s.annotations().end());
+ // the two not updated annotations shouldn't have a drawable attached to them yet
+ BOOST_CHECK( not annot[0]->drawable());
+ BOOST_CHECK( not annot[1]->drawable());
+ // the annotation updated must be drawable
+ BOOST_REQUIRE(annot[2]->drawable());
+ // and it must have the right draw function
+ BOOST_CHECK_EQUAL(annot[2]->drawable()->drawFunction(), dummy_draw_func);
+ BOOST_CHECK_EQUAL(annot[2]->drawable()->color(), default_color);
+}
+
BOOST_AUTO_TEST_CASE( glsequence_renderable )
{
boost::shared_ptr<AnnotationColors> cm(new AnnotationColors);
// way fewer basepairs than viewport pixel width
BOOST_CHECK_EQUAL(s.is_sequence_renderable( 0, 10, 500), true);
- BOOST_CHECK_CLOSE((double)s.get_pixel_width(0, 100, 100), 1.0, 1e-6);
- BOOST_CHECK_CLOSE((double)s.get_pixel_width(0, 1000, 100), 10.0, 1e-6);
+ BOOST_CHECK_CLOSE((double)s.pixelWidth(0, 100, 100), 1.0, 1e-6);
+ BOOST_CHECK_CLOSE((double)s.pixelWidth(0, 1000, 100), 10.0, 1e-6);
}
BOOST_AUTO_TEST_CASE( glsequence_sequence )
BOOST_CHECK_EQUAL(seq0.use_count(), 1);
BOOST_CHECK_EQUAL(seq1.use_count(), 1);
}
-*/
\ No newline at end of file
+*/