blob: dea5b1ef90f10dc449b03e18ae68df88d507142b [file] [log] [blame]
Kevin Zeng6e15a132021-04-16 00:34:17 -07001// 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
19namespace pw {
20namespace i2c {
21namespace {
22
Rob Mohr8b2ebc42021-05-22 10:34:56 -070023// Fake test initiator that's used for testing.
Kevin Zeng6e15a132021-04-16 00:34:17 -070024class 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.
43TEST(DeviceCompilationTest, CompileOk) {
Rob Mohrecbdb692021-06-10 15:03:10 -070044 constexpr Address kTestDeviceAddress = Address::SevenBit<0x3F>();
Kevin Zeng6e15a132021-04-16 00:34:17 -070045
46 TestInitiator initiator;
Rob Mohrecbdb692021-06-10 15:03:10 -070047 Device device = Device(initiator, kTestDeviceAddress);
Kevin Zeng6e15a132021-04-16 00:34:17 -070048}
49
50} // namespace
51} // namespace i2c
52} // namespace pw