blob: cf5e3e36caa999e7912788b6ca6cc36baceb9ff0 (
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
|
#include <gtest/gtest.h>
#include <sstream>
#include <string>
#include <vector>
#include <boost/archive/text_iarchive.hpp>
#include <boost/archive/text_oarchive.hpp>
#include "vocabulary.h"
using namespace std;
using namespace ::testing;
namespace ar = boost::archive;
namespace extractor {
namespace {
TEST(VocabularyTest, TestIndexes) {
Vocabulary vocabulary;
EXPECT_EQ(0, vocabulary.GetTerminalIndex("zero"));
EXPECT_EQ("zero", vocabulary.GetTerminalValue(0));
EXPECT_EQ(1, vocabulary.GetTerminalIndex("one"));
EXPECT_EQ("one", vocabulary.GetTerminalValue(1));
}
TEST(VocabularyTest, TestSerialization) {
Vocabulary vocabulary;
EXPECT_EQ(0, vocabulary.GetTerminalIndex("zero"));
EXPECT_EQ("zero", vocabulary.GetTerminalValue(0));
stringstream stream(ios_base::out | ios_base::in);
ar::text_oarchive output_stream(stream, ar::no_header);
output_stream << vocabulary;
Vocabulary vocabulary_copy;
ar::text_iarchive input_stream(stream, ar::no_header);
input_stream >> vocabulary_copy;
EXPECT_EQ(vocabulary, vocabulary_copy);
}
} // namespace
} // namespace extractor
|