| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <string> | 5 #include <string> |
| 6 #include <vector> | 6 #include <vector> |
| 7 | 7 |
| 8 #include "chrome/common/ini_parser.h" | 8 #include "chrome/common/ini_parser.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 | 10 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 std::string value; | 24 std::string value; |
| 25 }; | 25 }; |
| 26 | 26 |
| 27 class TestINIParser : public INIParser { | 27 class TestINIParser : public INIParser { |
| 28 public: | 28 public: |
| 29 explicit TestINIParser( | 29 explicit TestINIParser( |
| 30 const std::vector<TestTriplet>& expected_triplets) | 30 const std::vector<TestTriplet>& expected_triplets) |
| 31 : expected_triplets_(expected_triplets), | 31 : expected_triplets_(expected_triplets), |
| 32 pair_i_(0) { | 32 pair_i_(0) { |
| 33 } | 33 } |
| 34 virtual ~TestINIParser() {} | 34 ~TestINIParser() override {} |
| 35 | 35 |
| 36 size_t pair_i() { | 36 size_t pair_i() { |
| 37 return pair_i_; | 37 return pair_i_; |
| 38 } | 38 } |
| 39 | 39 |
| 40 private: | 40 private: |
| 41 virtual void HandleTriplet(const std::string& section, const std::string& key, | 41 void HandleTriplet(const std::string& section, |
| 42 const std::string& value) override { | 42 const std::string& key, |
| 43 const std::string& value) override { |
| 43 EXPECT_EQ(expected_triplets_[pair_i_].section, section); | 44 EXPECT_EQ(expected_triplets_[pair_i_].section, section); |
| 44 EXPECT_EQ(expected_triplets_[pair_i_].key, key); | 45 EXPECT_EQ(expected_triplets_[pair_i_].key, key); |
| 45 EXPECT_EQ(expected_triplets_[pair_i_].value, value); | 46 EXPECT_EQ(expected_triplets_[pair_i_].value, value); |
| 46 ++pair_i_; | 47 ++pair_i_; |
| 47 } | 48 } |
| 48 | 49 |
| 49 std::vector<TestTriplet> expected_triplets_; | 50 std::vector<TestTriplet> expected_triplets_; |
| 50 size_t pair_i_; | 51 size_t pair_i_; |
| 51 }; | 52 }; |
| 52 | 53 |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 EXPECT_TRUE(root.GetString("section1.key1", &value)); | 119 EXPECT_TRUE(root.GetString("section1.key1", &value)); |
| 119 EXPECT_EQ("value1", value); | 120 EXPECT_EQ("value1", value); |
| 120 EXPECT_FALSE(root.GetString("section1.key.2", &value)); | 121 EXPECT_FALSE(root.GetString("section1.key.2", &value)); |
| 121 EXPECT_TRUE(root.GetString("section1.key3", &value)); | 122 EXPECT_TRUE(root.GetString("section1.key3", &value)); |
| 122 EXPECT_EQ("va.lue3", value); | 123 EXPECT_EQ("va.lue3", value); |
| 123 EXPECT_FALSE(root.GetString("se.ction2.key.4", &value)); | 124 EXPECT_FALSE(root.GetString("se.ction2.key.4", &value)); |
| 124 EXPECT_FALSE(root.GetString("se.ction2.key5", &value)); | 125 EXPECT_FALSE(root.GetString("se.ction2.key5", &value)); |
| 125 } | 126 } |
| 126 | 127 |
| 127 } // namespace | 128 } // namespace |
| OLD | NEW |