xref: /openbmc/phosphor-power/test/nvtest.cpp (revision ab093328)
12f135445SMatt Spinler /**
22f135445SMatt Spinler  * Copyright © 2017 IBM Corporation
32f135445SMatt Spinler  *
42f135445SMatt Spinler  * Licensed under the Apache License, Version 2.0 (the "License");
52f135445SMatt Spinler  * you may not use this file except in compliance with the License.
62f135445SMatt Spinler  * You may obtain a copy of the License at
72f135445SMatt Spinler  *
82f135445SMatt Spinler  *     http://www.apache.org/licenses/LICENSE-2.0
92f135445SMatt Spinler  *
102f135445SMatt Spinler  * Unless required by applicable law or agreed to in writing, software
112f135445SMatt Spinler  * distributed under the License is distributed on an "AS IS" BASIS,
122f135445SMatt Spinler  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
132f135445SMatt Spinler  * See the License for the specific language governing permissions and
142f135445SMatt Spinler  * limitations under the License.
152f135445SMatt Spinler  */
162f135445SMatt Spinler #include "names_values.hpp"
172f135445SMatt Spinler 
18f0f02b9aSMatt Spinler #include <gtest/gtest.h>
19f0f02b9aSMatt Spinler 
TEST(NamesValuesTest,TestValues)202f135445SMatt Spinler TEST(NamesValuesTest, TestValues)
212f135445SMatt Spinler {
22*ab093328SLei YU     phosphor::power::util::NamesValues nv;
232f135445SMatt Spinler 
242f135445SMatt Spinler     std::string expected;
252f135445SMatt Spinler     EXPECT_EQ(nv.get(), expected); // empty
262f135445SMatt Spinler 
272f135445SMatt Spinler     nv.add("name1", 0);
282f135445SMatt Spinler     nv.add("name2", 0xC0FFEE);
292f135445SMatt Spinler     nv.add("name3", 0x12345678abcdef12);
302f135445SMatt Spinler     nv.add("name4", 0x0000000001);
312f135445SMatt Spinler 
322f135445SMatt Spinler     expected = "name1=0x0|name2=0xc0ffee|name3=0x12345678abcdef12|name4=0x1";
332f135445SMatt Spinler 
342f135445SMatt Spinler     EXPECT_EQ(nv.get(), expected);
352f135445SMatt Spinler }
36