1 // Copyright 2019 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #include "media/learning/common/feature_dictionary.h"
6 
7 #include "testing/gtest/include/gtest/gtest.h"
8 
9 namespace media {
10 namespace learning {
11 
12 class FeatureDictionaryTest : public testing::Test {};
13 
TEST_F(FeatureDictionaryTest,FillsInFeatures)14 TEST_F(FeatureDictionaryTest, FillsInFeatures) {
15   FeatureDictionary dict;
16   const std::string feature_name_1("feature 1");
17   const FeatureValue feature_value_1("feature value 1");
18 
19   const std::string feature_name_2("feature 2");
20   const FeatureValue feature_value_2("feature value 2");
21 
22   const std::string feature_name_3("feature 3");
23   const FeatureValue feature_value_3("feature value 3");
24 
25   dict.Add(feature_name_1, feature_value_1);
26   dict.Add(feature_name_2, feature_value_2);
27   dict.Add(feature_name_3, feature_value_3);
28 
29   LearningTask task;
30   task.feature_descriptions.push_back({"some other feature"});
31   task.feature_descriptions.push_back({feature_name_3});
32   task.feature_descriptions.push_back({feature_name_1});
33 
34   FeatureVector features;
35   features.push_back(FeatureValue(0));  // some other feature
36 
37   dict.Lookup(task, &features);
38   EXPECT_EQ(features.size(), 3u);
39   EXPECT_EQ(features[0], FeatureValue(0));
40   EXPECT_EQ(features[1], feature_value_3);
41   EXPECT_EQ(features[2], feature_value_1);
42 }
43 
44 }  // namespace learning
45 }  // namespace media
46