summaryrefslogtreecommitdiff
path: root/extractor/alignment_test.cc
blob: 1b8ff531480af794f70e5c3e5b72012bb6414232 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include <gtest/gtest.h>

#include <sstream>
#include <string>

#include <boost/archive/binary_iarchive.hpp>
#include <boost/archive/binary_oarchive.hpp>

#include "alignment.h"

using namespace std;
using namespace ::testing;
namespace ar = boost::archive;

namespace extractor {
namespace {

class AlignmentTest : public Test {
 protected:
  virtual void SetUp() {
    alignment = Alignment("sample_alignment.txt");
  }

  Alignment alignment;
};

TEST_F(AlignmentTest, TestGetLinks) {
  vector<pair<int, int>> expected_links = {
    make_pair(0, 0), make_pair(1, 1), make_pair(2, 2)
  };
  EXPECT_EQ(expected_links, alignment.GetLinks(0));
  expected_links = {make_pair(1, 0), make_pair(2, 1)};
  EXPECT_EQ(expected_links, alignment.GetLinks(1));
}

TEST_F(AlignmentTest, TestSerialization) {
  stringstream stream(ios_base::binary | ios_base::out | ios_base::in);
  ar::binary_oarchive output_stream(stream, ar::no_header);
  output_stream << alignment;

  Alignment alignment_copy;
  ar::binary_iarchive input_stream(stream, ar::no_header);
  input_stream >> alignment_copy;

  EXPECT_EQ(alignment, alignment_copy);
}

} // namespace
} // namespace extractor