1 // Copyright 2015 The Chromium OS 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 "shill/net/nl80211_attribute.h" 6 7 #include <gmock/gmock.h> 8 #include <gtest/gtest.h> 9 10 #include "shill/net/byte_string.h" 11 12 using testing::Test; 13 14 namespace shill { 15 16 class Nl80211AttributeTest : public Test { 17 }; 18 TEST_F(Nl80211AttributeTest,RegInitiatorDecode)19TEST_F(Nl80211AttributeTest, RegInitiatorDecode) { 20 Nl80211AttributeRegInitiator empty_attribute; 21 EXPECT_FALSE(empty_attribute.InitFromValue(ByteString())); 22 23 const uint8_t kU8Value = 123; 24 ByteString u8_value(&kU8Value, 1); 25 Nl80211AttributeRegInitiator u8_attribute; 26 EXPECT_TRUE(u8_attribute.InitFromValue(u8_value)); 27 uint32_t value_from_u8_attribute; 28 EXPECT_TRUE(u8_attribute.GetU32Value(&value_from_u8_attribute)); 29 EXPECT_EQ(kU8Value, value_from_u8_attribute); 30 31 const uint32_t kU32Value = 123456790U; 32 ByteString u32_value = ByteString::CreateFromCPUUInt32(kU32Value); 33 Nl80211AttributeRegInitiator u32_attribute; 34 EXPECT_TRUE(u32_attribute.InitFromValue(u32_value)); 35 uint32_t value_from_u32_attribute; 36 EXPECT_TRUE(u32_attribute.GetU32Value(&value_from_u32_attribute)); 37 EXPECT_EQ(kU32Value, value_from_u32_attribute); 38 } 39 40 } // namespace shill 41