ads1115  0.2.0
All Classes Namespaces Files Functions Variables Enumerations Enumerator Macros
threshold.cpp File Reference
#include "ads1115/threshold.hpp"
#include <gtest/gtest.h>
#include <stdexcept>
Include dependency graph for threshold.cpp:

Go to the source code of this file.

Functions

 TEST (Threshold, create)
 
 TEST (Threshold, set)
 

Function Documentation

◆ TEST() [1/2]

TEST ( Threshold  ,
create   
)

Definition at line 12 of file threshold.cpp.

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 }

◆ TEST() [2/2]

TEST ( Threshold  ,
set   
)

Definition at line 33 of file threshold.cpp.

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 }

References ADS1115::Threshold::set().

Here is the call graph for this function:
ADS1115::Threshold
Definition: threshold.hpp:12
ADS1115::Threshold::set
void set(const std::int16_t low, const std::int16_t high)
Definition: threshold.cpp:16