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
media / learning / common / feature_dictionary_unittest.cc [blame]
// Copyright 2019 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "media/learning/common/feature_dictionary.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace media {
namespace learning {
class FeatureDictionaryTest : public testing::Test {};
TEST_F(FeatureDictionaryTest, FillsInFeatures) {
FeatureDictionary dict;
const std::string feature_name_1("feature 1");
const FeatureValue feature_value_1("feature value 1");
const std::string feature_name_2("feature 2");
const FeatureValue feature_value_2("feature value 2");
const std::string feature_name_3("feature 3");
const FeatureValue feature_value_3("feature value 3");
dict.Add(feature_name_1, feature_value_1);
dict.Add(feature_name_2, feature_value_2);
dict.Add(feature_name_3, feature_value_3);
LearningTask task;
task.feature_descriptions.push_back({"some other feature"});
task.feature_descriptions.push_back({feature_name_3});
task.feature_descriptions.push_back({feature_name_1});
FeatureVector features;
features.push_back(FeatureValue(0)); // some other feature
dict.Lookup(task, &features);
EXPECT_EQ(features.size(), 3u);
EXPECT_EQ(features[0], FeatureValue(0));
EXPECT_EQ(features[1], feature_value_3);
EXPECT_EQ(features[2], feature_value_1);
}
} // namespace learning
} // namespace media