summaryrefslogtreecommitdiff
path: root/extractor/features/sample_source_count_test.cc
blob: 63856b9d395c4f0a994cb31df802ef4f1278f3f1 (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
#include <gtest/gtest.h>

#include <cmath>
#include <memory>
#include <string>

#include "sample_source_count.h"

using namespace std;
using namespace ::testing;

namespace extractor {
namespace features {
namespace {

class SampleSourceCountTest : public Test {
 protected:
  virtual void SetUp() {
    feature = make_shared<SampleSourceCount>();
  }

  shared_ptr<SampleSourceCount> feature;
};

TEST_F(SampleSourceCountTest, TestGetName) {
  EXPECT_EQ("SampleCountF", feature->GetName());
}

TEST_F(SampleSourceCountTest, TestScore) {
  Phrase phrase;
  FeatureContext context(phrase, phrase, 0, 3, 1);
  EXPECT_EQ(log10(2), feature->Score(context));

  context = FeatureContext(phrase, phrase, 3.2, 3, 9);
  EXPECT_EQ(1.0, feature->Score(context));
}

} // namespace
} // namespace features
} // namespace extractor