blob: 6e0fbac4b81df6e8d5b6bef327504f47c30e3d3a [file] [log] [blame]
Kevin Zeng62683b62021-03-18 12:22:08 -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_analog/analog_input.h"
15
16#include "gtest/gtest.h"
17
18namespace pw {
19namespace analog {
20namespace {
21
22constexpr int32_t kLimitsMax = 4096;
23constexpr int32_t kLimitsMin = 0;
24
Rob Mohrd15bc0a2021-05-22 10:53:42 -070025// Fake test analog input that's used for testing.
Kevin Zeng62683b62021-03-18 12:22:08 -070026class TestAnalogInput : public AnalogInput {
27 public:
28 TestAnalogInput()
29 : limits_({
30 .min = kLimitsMin,
31 .max = kLimitsMax,
32 }) {}
33
34 Result<int32_t> TryReadUntil(chrono::SystemClock::time_point) override {
35 return Status::Unimplemented();
36 }
37
38 Limits GetLimits() const override { return limits_; }
39
40 private:
41 const Limits limits_;
42};
43
44TEST(AnalogInputTest, Construction) {
45 TestAnalogInput analog_input = TestAnalogInput();
46}
47
48TEST(AnalogInputTest, GetLimits) {
49 TestAnalogInput analog_input = TestAnalogInput();
50 AnalogInput::Limits limits = analog_input.GetLimits();
51 EXPECT_EQ(limits.min, kLimitsMin);
52 EXPECT_EQ(limits.max, kLimitsMax);
53}
54
55} // namespace
56} // namespace analog
57} // namespace pw