Kevin Zeng | 6e15a13 | 2021-04-16 00:34:17 -0700 | [diff] [blame] | 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 | #include "pw_i2c/device.h" |
| 15 | |
| 16 | #include "gtest/gtest.h" |
| 17 | #include "pw_bytes/byte_builder.h" |
| 18 | |
| 19 | namespace pw { |
| 20 | namespace i2c { |
| 21 | namespace { |
| 22 | |
Rob Mohr | 8b2ebc4 | 2021-05-22 10:34:56 -0700 | [diff] [blame] | 23 | // Fake test initiator that's used for testing. |
Kevin Zeng | 6e15a13 | 2021-04-16 00:34:17 -0700 | [diff] [blame] | 24 | class TestInitiator : public Initiator { |
| 25 | public: |
| 26 | explicit TestInitiator() {} |
| 27 | |
| 28 | private: |
| 29 | Status DoWriteReadFor(Address, |
| 30 | ConstByteSpan, |
| 31 | ByteSpan, |
| 32 | chrono::SystemClock::duration) override { |
| 33 | // Empty implementation. |
| 34 | return OkStatus(); |
| 35 | } |
| 36 | |
| 37 | ByteBuffer<10> write_buffer_; |
| 38 | ByteBuffer<10> read_buffer_; |
| 39 | }; |
| 40 | |
| 41 | // This test just checks to make sure the Device object compiles. |
| 42 | // TODO(b/185609270): Full test coverage. |
| 43 | TEST(DeviceCompilationTest, CompileOk) { |
Rob Mohr | ecbdb69 | 2021-06-10 15:03:10 -0700 | [diff] [blame] | 44 | constexpr Address kTestDeviceAddress = Address::SevenBit<0x3F>(); |
Kevin Zeng | 6e15a13 | 2021-04-16 00:34:17 -0700 | [diff] [blame] | 45 | |
| 46 | TestInitiator initiator; |
Rob Mohr | ecbdb69 | 2021-06-10 15:03:10 -0700 | [diff] [blame] | 47 | Device device = Device(initiator, kTestDeviceAddress); |
Kevin Zeng | 6e15a13 | 2021-04-16 00:34:17 -0700 | [diff] [blame] | 48 | } |
| 49 | |
| 50 | } // namespace |
| 51 | } // namespace i2c |
| 52 | } // namespace pw |