Fix for x86_64 build fail
[platform/upstream/connectedhomeip.git] / third_party / pigweed / repo / pw_i2c / address_test.cc
1 // Copyright 2021 The Pigweed Authors
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License"); you may not
4 // use this file except in compliance with the License. You may obtain a copy of
5 // the License at
6 //
7 //     https://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11 // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12 // License for the specific language governing permissions and limitations under
13 // the License.
14
15 #include "pw_i2c/address.h"
16
17 #include "gtest/gtest.h"
18
19 namespace pw::i2c {
20
21 TEST(Address, SevenBitConstexpr) {
22   constexpr Address kSevenBit =
23       Address::SevenBit<Address::kMaxSevenBitAddress>();
24   EXPECT_EQ(kSevenBit.GetSevenBit(), Address::kMaxSevenBitAddress);
25 }
26
27 TEST(Address, TenBitConstexpr) {
28   constexpr Address kTenBit = Address::TenBit<Address::kMaxTenBitAddress>();
29   EXPECT_EQ(kTenBit.GetTenBit(), Address::kMaxTenBitAddress);
30 }
31
32 TEST(Address, SevenBitRuntimeChecked) {
33   const Address seven_bit(Address::kMaxSevenBitAddress);
34   EXPECT_EQ(seven_bit.GetSevenBit(), Address::kMaxSevenBitAddress);
35 }
36
37 TEST(Address, TenBitRuntimeChecked) {
38   const Address ten_bit(Address::kMaxTenBitAddress);
39   EXPECT_EQ(ten_bit.GetTenBit(), Address::kMaxTenBitAddress);
40 }
41
42 // TODO(pwbug/88): Verify assert behaviour when trying to get a 7bit address out
43 // of a 10bit address.
44
45 // TODO(pwbug/47): Add tests to ensure the constexpr constructors fail to
46 // compile with invalid addresses once no-copmile tests are set up in Pigweed.
47
48 }  // namespace pw::i2c