1 // Copyright (c) 2011 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 "gpu/config/gpu_util.h" 6 #include "testing/gtest/include/gtest/gtest.h" 7 8 namespace gpu { 9 10 TEST(GpuUtilTest, MergeFeatureSets) { 11 { 12 // Merge two empty sets. 13 std::set<int> src; 14 std::set<int> dst; 15 EXPECT_TRUE(dst.empty()); 16 MergeFeatureSets(&dst, src); 17 EXPECT_TRUE(dst.empty()); 18 } 19 { 20 // Merge an empty set into a set with elements. 21 std::set<int> src; 22 std::set<int> dst; 23 dst.insert(1); 24 EXPECT_EQ(1u, dst.size()); 25 MergeFeatureSets(&dst, src); 26 EXPECT_EQ(1u, dst.size()); 27 } 28 { 29 // Merge two sets where the source elements are already in the target set. 30 std::set<int> src; 31 std::set<int> dst; 32 src.insert(1); 33 dst.insert(1); 34 EXPECT_EQ(1u, dst.size()); 35 MergeFeatureSets(&dst, src); 36 EXPECT_EQ(1u, dst.size()); 37 } 38 { 39 // Merge two sets with different elements. 40 std::set<int> src; 41 std::set<int> dst; 42 src.insert(1); 43 dst.insert(2); 44 EXPECT_EQ(1u, dst.size()); 45 MergeFeatureSets(&dst, src); 46 EXPECT_EQ(2u, dst.size()); 47 } 48 } 49 50 TEST(GpuUtilTest, StringToFeatureSet) { 51 { 52 // zero feature. 53 std::set<int> features; 54 StringToFeatureSet("", &features); 55 EXPECT_EQ(0u, features.size()); 56 } 57 { 58 // One features. 59 std::set<int> features; 60 StringToFeatureSet("4", &features); 61 EXPECT_EQ(1u, features.size()); 62 } 63 { 64 // Multiple features. 65 std::set<int> features; 66 StringToFeatureSet("1,9", &features); 67 EXPECT_EQ(2u, features.size()); 68 } 69 } 70 71 } // namespace gpu 72