Store Sequence sequence location in a shared_ptr class
[mussa.git] / qui / test / TestSequenceDescription.hpp
1 #ifndef _TEST_SEQUENCE_DESCRIPTION_HPP_
2 #define _TEST_SEQUENCE_DESCRIPTION_HPP_
3
4 #include <QtGui>
5 #include <QtTest/QtTest>
6
7 #include "alg/sequence.hpp"
8 #include "alg/glsequence.hpp"
9 #include "alg/annotation_colors.hpp"
10 #include "qui/seqbrowser/SequenceDescription.hpp"
11
12 #include <iostream>
13 #include <string>
14 #include <vector>
15
16 class TestSequenceDescription : public QObject
17 {
18   Q_OBJECT
19
20 private slots:
21   void testSimple() {
22     Sequence seq1(new Sequence("AAGGCCTT"));
23     seq1.set_species("foo");
24     boost::shared_ptr<AnnotationColors> cm(new AnnotationColors);
25     // this is now a copy of the original sequence... which
26     // means changes to the shared GlSequence wont do anything to Sequence
27     boost::shared_ptr<GlSequence> glseq1(new GlSequence(seq1, cm));
28
29     SequenceDescription sd(glseq1, 0);
30     QVERIFY(sd.glsequence() == glseq1);
31     QVERIFY(sd.glsequence()->get_species() == glseq1->get_species());
32     sd.setName(std::string("bar"));
33     QVERIFY(sd.glsequence()->get_species() == glseq1->get_species());
34     QVERIFY(seq1.get_species() != "bar");
35     QVERIFY(glseq1->get_species() == "bar");
36   }
37   void testDeletedPointer() {
38     SequenceDescription sd;
39
40     { 
41       boost::shared_ptr<Sequence> seq1(new Sequence("AAGGCCTT"));
42       Sequence m("AAGG");
43       seq1->find_motif(m);
44       seq1->set_species("foo");
45       boost::shared_ptr<AnnotationColors> cm(new AnnotationColors);
46       boost::shared_ptr<GlSequence> glseq1(new GlSequence(*seq1, cm));
47       sd.setGlSequence(glseq1);
48     }
49
50     QVERIFY(sd.name() == "foo");
51   }
52 };
53 #endif