Esempio n. 1
0
TEST(revert_feature, dollar_mark_onvalue) {
  fv_converter::datum data;
  common::sfv_t fv;

  fv.push_back(std::make_pair("name$do$c1@str#bin/bin", 1.0));

  revert_feature(fv, data);

  ASSERT_EQ(1u, data.string_values_.size());
  EXPECT_EQ("name", data.string_values_[0].first);
  EXPECT_EQ("do$c1", data.string_values_[0].second);
  ASSERT_EQ(0u, data.num_values_.size());
}
Esempio n. 2
0
TEST(revert_feature, trivial) {
  fv_converter::datum data;
  sfv_t fv;

  fv.push_back(std::make_pair("name$doc1@str#bin/bin", 1.0));
  fv.push_back(std::make_pair("message$hello@space#bin/bin", 1.0));
  fv.push_back(std::make_pair("age@num", 25.f));
  fv.push_back(std::make_pair("id@str$12345", 1.0));
  fv.push_back(std::make_pair("age@log", 3.0));

  revert_feature(fv, data);

  ASSERT_EQ(1u, data.string_values_.size());
  EXPECT_EQ("name", data.string_values_[0].first);
  EXPECT_EQ("doc1", data.string_values_[0].second);
  ASSERT_EQ(2u, data.num_values_.size());
  std::sort(data.num_values_.begin(), data.num_values_.end());
  EXPECT_EQ("age", data.num_values_[0].first);
  EXPECT_EQ(25.f, data.num_values_[0].second);
  EXPECT_EQ("id", data.num_values_[1].first);
  EXPECT_EQ(12345, data.num_values_[1].second);
}