Jeff Sharkey | 3472e52 | 2017-10-06 18:02:53 -0600 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2017 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #include <gtest/gtest.h> |
| 18 | |
| 19 | #include "../Utils.h" |
| 20 | |
| 21 | namespace android { |
| 22 | namespace vold { |
| 23 | |
Paul Crowley | 14c8c07 | 2018-09-18 13:30:21 -0700 | [diff] [blame] | 24 | class UtilsTest : public testing::Test {}; |
Jeff Sharkey | 3472e52 | 2017-10-06 18:02:53 -0600 | [diff] [blame] | 25 | |
| 26 | TEST_F(UtilsTest, FindValueTest) { |
| 27 | std::string tmp; |
| 28 | |
| 29 | ASSERT_FALSE(FindValue("", "KEY", &tmp)); |
| 30 | ASSERT_FALSE(FindValue("BADKEY=\"VALUE\"", "KEY", &tmp)); |
| 31 | |
| 32 | ASSERT_TRUE(FindValue("KEY=\"VALUE\"", "KEY", &tmp)); |
| 33 | ASSERT_EQ("VALUE", tmp); |
| 34 | |
| 35 | ASSERT_TRUE(FindValue("FOO=\"BAR\" KEY=\"VALUE VALUE\" BAR=\"BAZ\"", "KEY", &tmp)); |
| 36 | ASSERT_EQ("VALUE VALUE", tmp); |
| 37 | |
| 38 | ASSERT_TRUE(FindValue("BADKEY=\"VALUE\" KEY=\"BAZ\"", "KEY", &tmp)); |
| 39 | ASSERT_EQ("BAZ", tmp); |
| 40 | } |
| 41 | |
Paul Crowley | 14c8c07 | 2018-09-18 13:30:21 -0700 | [diff] [blame] | 42 | } // namespace vold |
| 43 | } // namespace android |