uTL
micro Template library
test_1w_impl.cpp
Go to the documentation of this file.
1 
20 #include <gtest/gtest.h>
21 #include <utl/com/_1wire_uart.h>
22 
29 namespace test_1w {
30  using namespace utl;
31 
32  // implementer class stub
33  class OW : public _1wire_uart_i<OW> {
34  friend _1wire_uart_i<OW>;
35  byte_t UART_RW (byte_t byte) {
36  // return the given. This also mean no-device
37  return byte;
38  }
39  void UART_BR (uint32_t br) {} // imaginary baud-rate implementation
40  };
41 
42  // fixture
43  class Test_1w_impl : public ::testing::Test {
44  protected:
45  //void SetUp() override { }
46  //void TearDown() override { }
47  OW ow;
48  };
49 
50  TEST_F(Test_1w_impl, TestConcept) {
51 // EXPECT_EQ(_1Wire_i<OW>, true);
52  }
53 
54  TEST_F(Test_1w_impl, TestConstruction) {
55  EXPECT_GT(sizeof(ow), 0UL);
56  }
57 
58  TEST_F (Test_1w_impl, TestFunctionality) {
59  byte_t b {42};
60 
61  _1wire_id_t id = ow.first(OW::Speed::STD);
62  EXPECT_EQ (id != _1wire_id_t::nullDev(), false); // as long as there is no slave Mock
63 
64  EXPECT_EQ (ow.reset(OW::Speed::STD), false); // as long as there is no slave Mock
65  //ow.match(id, OW::Speed::STD);
66  EXPECT_EQ(ow.rx_data(OW::Speed::STD), 0xFF);
67  EXPECT_EQ(ow.tx_data(b, OW::Speed::STD), 42);
68 
69  }
70 }
TEST_F(Test_1w_impl, TestConcept)
#define EXPECT_GT(val1, val2)
Definition: gtest.h:16655
STL&#39;s core language concepts.
Definition: _1wire.h:30
static constexpr const _1wire_id_t & nullDev()
Return nullDev reference.
Definition: _1wire_id.h:50
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:16643
uint8_t byte_t
8 bits wide
Definition: types.h:31
1-wire UART interface template class using CRTP Using the private virtual interface we provide the in...
Definition: _1wire_uart.h:52
A 1-wire implementation using a microprocessor&#39;s uart for bit timing.