ads1115  0.2.0
threshold.cpp
Go to the documentation of this file.
1 // ads1115
2 #include "ads1115/threshold.hpp"
3 
4 // gtest
5 #include <gtest/gtest.h>
6 
7 // stl
8 #include <stdexcept>
9 
10 using namespace ADS1115;
11 
12 TEST(Threshold, create)
13 {
14  Threshold thresh {};
15  ASSERT_EQ(thresh.getHigh(), 32767);
16  ASSERT_EQ(thresh.getLow(), -32768);
17 
18  thresh = Threshold(-16, 16);
19  ASSERT_EQ(thresh.getHigh(), 16);
20  ASSERT_EQ(thresh.getLow(), -16);
21 
22  thresh = Threshold(16, -16);
23  ASSERT_EQ(thresh.getHigh(), -16);
24  ASSERT_EQ(thresh.getLow(), 16);
25 
26  thresh = Threshold(15, 16);
27  ASSERT_EQ(thresh.getHigh(), 16);
28  ASSERT_EQ(thresh.getLow(), 15);
29 
30  ASSERT_THROW(Threshold(16, 15), std::runtime_error);
31 }
32 
34 {
35  Threshold thresh {};
36 
37  thresh.set(-16, 16);
38  ASSERT_EQ(thresh.getHigh(), 16);
39  ASSERT_EQ(thresh.getLow(), -16);
40 
41  thresh.set(16, -16);
42  ASSERT_EQ(thresh.getHigh(), -16);
43  ASSERT_EQ(thresh.getLow(), 16);
44 
45  thresh.set(15, 16);
46  ASSERT_EQ(thresh.getHigh(), 16);
47  ASSERT_EQ(thresh.getLow(), 15);
48 
49  ASSERT_THROW(thresh.set(16, 15), std::runtime_error);
50 }
ADS1115
Definition: ads1115.hpp:16
ADS1115::Threshold
Definition: threshold.hpp:12
threshold.hpp
TEST
TEST(Threshold, create)
Definition: threshold.cpp:12
ADS1115::Threshold::set
void set(const std::int16_t low, const std::int16_t high)
Definition: threshold.cpp:16