refactored PathScene into SequenceBrowserWidget
[mussa.git] / alg / test / test_glseqbrowser.cpp
diff --git a/alg/test/test_glseqbrowser.cpp b/alg/test/test_glseqbrowser.cpp
new file mode 100644 (file)
index 0000000..ba4fcae
--- /dev/null
@@ -0,0 +1,47 @@
+#include <boost/test/auto_unit_test.hpp>
+#include <boost/assign/std/vector.hpp>
+using namespace boost::assign;
+
+#include <string>
+#include <list>
+#include <vector>
+
+#include "alg/annotation_colors.hpp"
+#include "alg/glseqbrowser.hpp"
+#include "alg/sequence.hpp"
+
+using namespace std;
+
+BOOST_AUTO_TEST_CASE ( gltracks_connect )
+{
+  string s0("AAGGCCTT");
+  string s1("TTGGCCAA");
+  string s2("GATTACAA");
+  Sequence seq0(s0);
+  Sequence seq1(s1);
+  Sequence seq2(s2);
+
+  GlSeqBrowser gt;
+  gt.push_sequence(seq0);
+  gt.push_sequence(seq1);
+  gt.push_sequence(seq2);
+
+  // make up some sample data
+  vector<bool> rc;
+  rc += false, false, false;
+  vector<int> path;
+                path += 1,1,1; gt.link(path, rc, 1);
+  path.clear(); path += 1,1,3; gt.link(path, rc, 1); 
+  path.clear(); path += 2,3,3; gt.link(path, rc, 1); 
+  path.clear(); path += 3,3,3; gt.link(path, rc, 1);
+
+  BOOST_CHECK_EQUAL( gt.path_segments.size(), 2 );
+  GlSeqBrowser::segment_key p(1, 1);
+  GlSeqBrowser::pair_segment_map::iterator psm_i = gt.path_segments[0].find(p);
+  BOOST_CHECK( psm_i != gt.path_segments[0].end() );
+  BOOST_CHECK_EQUAL( psm_i->second.path_ids.size(), 2 );
+
+  gt.clear();
+  BOOST_CHECK_EQUAL( gt.path_segments.size(), 0 );
+}
+