summaryrefslogtreecommitdiff
path: root/extractor/phrase_test.cc
diff options
context:
space:
mode:
authorPaul Baltescu <pauldb89@gmail.com>2013-03-06 17:35:49 +0000
committerPaul Baltescu <pauldb89@gmail.com>2013-03-06 17:35:49 +0000
commit3219aaf89f0c08c5ac18da6338a3df87b1e5dd3f (patch)
treec1aae95dda98600758f69eea21d24086e1ccf6c3 /extractor/phrase_test.cc
parent4a331030632d9a818f1853a5afed20b9f14e354a (diff)
Added 3 missing unit tests.
Diffstat (limited to 'extractor/phrase_test.cc')
-rw-r--r--extractor/phrase_test.cc24
1 files changed, 22 insertions, 2 deletions
diff --git a/extractor/phrase_test.cc b/extractor/phrase_test.cc
index c8176178..3ba9368a 100644
--- a/extractor/phrase_test.cc
+++ b/extractor/phrase_test.cc
@@ -17,8 +17,11 @@ class PhraseTest : public Test {
protected:
virtual void SetUp() {
shared_ptr<MockVocabulary> vocabulary = make_shared<MockVocabulary>();
- EXPECT_CALL(*vocabulary, GetTerminalValue(_))
- .WillRepeatedly(Return("word"));
+ vector<string> words = {"w1", "w2", "w3", "w4"};
+ for (size_t i = 0; i < words.size(); ++i) {
+ EXPECT_CALL(*vocabulary, GetTerminalValue(i + 1))
+ .WillRepeatedly(Return(words[i]));
+ }
shared_ptr<PhraseBuilder> phrase_builder =
make_shared<PhraseBuilder>(vocabulary);
@@ -59,5 +62,22 @@ TEST_F(PhraseTest, TestGetSymbol) {
}
}
+TEST_F(PhraseTest, TestGetNumSymbols) {
+ EXPECT_EQ(3, phrase1.GetNumSymbols());
+ EXPECT_EQ(6, phrase2.GetNumSymbols());
+}
+
+TEST_F(PhraseTest, TestGetWords) {
+ vector<string> expected_words = {"w1", "w2", "w3"};
+ EXPECT_EQ(expected_words, phrase1.GetWords());
+ expected_words = {"w1", "w2", "w3", "w4"};
+ EXPECT_EQ(expected_words, phrase2.GetWords());
+}
+
+TEST_F(PhraseTest, TestComparator) {
+ EXPECT_FALSE(phrase1 < phrase2);
+ EXPECT_TRUE(phrase2 < phrase1);
+}
+
} // namespace
} // namespace extractor