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
50
|
#include <gtest/gtest.h>
#include <memory>
#include "mocks/mock_matchings_sampler.h"
#include "mocks/mock_suffix_array_sampler.h"
#include "phrase_location.h"
#include "phrase_location_sampler.h"
using namespace std;
using namespace ::testing;
namespace extractor {
namespace {
class MatchingsSamplerTest : public Test {
protected:
virtual void SetUp() {
matchings_sampler = make_shared<MockMatchingsSampler>();
suffix_array_sampler = make_shared<MockSuffixArraySampler>();
sampler = make_shared<PhraseLocationSampler>(
matchings_sampler, suffix_array_sampler);
}
shared_ptr<MockMatchingsSampler> matchings_sampler;
shared_ptr<MockSuffixArraySampler> suffix_array_sampler;
shared_ptr<PhraseLocationSampler> sampler;
};
TEST_F(MatchingsSamplerTest, TestSuffixArrayRange) {
vector<int> locations = {0, 1, 2, 3};
PhraseLocation location(0, 3), result(locations, 2);
unordered_set<int> blacklisted_sentence_ids;
EXPECT_CALL(*suffix_array_sampler, Sample(location, blacklisted_sentence_ids))
.WillOnce(Return(result));
EXPECT_EQ(result, sampler->Sample(location, blacklisted_sentence_ids));
}
TEST_F(MatchingsSamplerTest, TestMatchings) {
vector<int> locations = {0, 1, 2, 3};
PhraseLocation location(locations, 2), result(locations, 2);
unordered_set<int> blacklisted_sentence_ids;
EXPECT_CALL(*matchings_sampler, Sample(location, blacklisted_sentence_ids))
.WillOnce(Return(result));
EXPECT_EQ(result, sampler->Sample(location, blacklisted_sentence_ids));
}
}
} // namespace extractor
|