1 // Copyright 2023 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 "public/pw_uart/uart_non_blocking.h"
16
17 #include <cstdint>
18
19 #include "gtest/gtest.h"
20 #include "pw_bytes/span.h"
21 #include "pw_function/function.h"
22 #include "pw_status/status.h"
23 #include "pw_status/status_with_size.h"
24
25 namespace pw::uart {
26 namespace {
27
28 class UartNonBlockingStub : public UartNonBlocking {
29 public:
UartNonBlockingStub()30 UartNonBlockingStub() {}
31 ~UartNonBlockingStub() override = default;
32
33 private:
DoEnable(bool)34 Status DoEnable(bool) override { return OkStatus(); }
DoSetBaudRate(uint32_t)35 Status DoSetBaudRate(uint32_t) override { return OkStatus(); }
DoRead(ByteSpan,size_t,Function<void (Status,ConstByteSpan buffer)> &&)36 Status DoRead(ByteSpan,
37 size_t,
38 Function<void(Status, ConstByteSpan buffer)>&&) override {
39 return OkStatus();
40 }
DoCancelRead()41 bool DoCancelRead() override { return true; }
DoWrite(ConstByteSpan,Function<void (StatusWithSize status)> &&)42 Status DoWrite(ConstByteSpan,
43 Function<void(StatusWithSize status)>&&) override {
44 return OkStatus();
45 }
DoCancelWrite()46 bool DoCancelWrite() override { return true; }
DoConservativeReadAvailable()47 size_t DoConservativeReadAvailable() override { return 0; }
DoClearPendingReceiveBytes()48 Status DoClearPendingReceiveBytes() override { return OkStatus(); }
49 };
50
51 class UartNonBlockingTest : public ::testing::Test {
52 public:
UartNonBlockingTest()53 UartNonBlockingTest() : stub_() {}
54
55 private:
56 UartNonBlockingStub stub_;
57 };
58
TEST_F(UartNonBlockingTest,CompilationSucceeds)59 TEST_F(UartNonBlockingTest, CompilationSucceeds) { EXPECT_TRUE(true); }
60
61 } // namespace
62 } // namespace pw::uart
63