| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "base/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 |
| 11 namespace base { | |
| 12 | |
| 13 namespace { | 11 namespace { |
| 14 | 12 |
| 15 struct TestTriplet { | 13 struct TestTriplet { |
| 16 TestTriplet(const std::string& section, | 14 TestTriplet(const std::string& section, |
| 17 const std::string& key, | 15 const std::string& key, |
| 18 const std::string& value) | 16 const std::string& value) |
| 19 : section(section), | 17 : section(section), |
| 20 key(key), | 18 key(key), |
| 21 value(value) { | 19 value(value) { |
| 22 } | 20 } |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 | 106 |
| 109 test_parser.Parse( | 107 test_parser.Parse( |
| 110 "[section1]\n" | 108 "[section1]\n" |
| 111 "key1=value1\n" | 109 "key1=value1\n" |
| 112 "key.2=value2\n" | 110 "key.2=value2\n" |
| 113 "key3=va.lue3\n" | 111 "key3=va.lue3\n" |
| 114 "[se.ction2]\n" | 112 "[se.ction2]\n" |
| 115 "key.4=value4\n" | 113 "key.4=value4\n" |
| 116 "key5=value5\n"); | 114 "key5=value5\n"); |
| 117 | 115 |
| 118 const DictionaryValue& root = test_parser.root(); | 116 const base::DictionaryValue& root = test_parser.root(); |
| 119 std::string value; | 117 std::string value; |
| 120 EXPECT_TRUE(root.GetString("section1.key1", &value)); | 118 EXPECT_TRUE(root.GetString("section1.key1", &value)); |
| 121 EXPECT_EQ("value1", value); | 119 EXPECT_EQ("value1", value); |
| 122 EXPECT_FALSE(root.GetString("section1.key.2", &value)); | 120 EXPECT_FALSE(root.GetString("section1.key.2", &value)); |
| 123 EXPECT_TRUE(root.GetString("section1.key3", &value)); | 121 EXPECT_TRUE(root.GetString("section1.key3", &value)); |
| 124 EXPECT_EQ("va.lue3", value); | 122 EXPECT_EQ("va.lue3", value); |
| 125 EXPECT_FALSE(root.GetString("se.ction2.key.4", &value)); | 123 EXPECT_FALSE(root.GetString("se.ction2.key.4", &value)); |
| 126 EXPECT_FALSE(root.GetString("se.ction2.key5", &value)); | 124 EXPECT_FALSE(root.GetString("se.ction2.key5", &value)); |
| 127 } | 125 } |
| 128 | 126 |
| 129 } // namespace | 127 } // namespace |
| 130 | |
| 131 } // namespace base | |
| OLD | NEW |