test_1w_impl.cpp
Go to the documentation of this file.
#include <gtest/gtest.h>
#include <utl/com/_1wire_uart.h>
namespace test_1w {
using namespace utl;
// implementer class stub
class OW : public _1wire_uart_i<OW> {
friend _1wire_uart_i<OW>;
byte_t UART_RW (byte_t byte) {
// return the given. This also mean no-device
return byte;
}
void UART_BR (uint32_t br) {} // imaginary baud-rate implementation
};
// fixture
class Test_1w_impl : public ::testing::Test {
protected:
//void SetUp() override { }
//void TearDown() override { }
OW ow;
};
TEST_F(Test_1w_impl, TestConcept) {
// EXPECT_EQ(_1Wire_i<OW>, true);
}
TEST_F(Test_1w_impl, TestConstruction) {
EXPECT_GT(sizeof(ow), 0UL);
}
TEST_F (Test_1w_impl, TestFunctionality) {
byte_t b {42};
_1wire_id_t id = ow.first(OW::Speed::STD);
EXPECT_EQ (id != _1wire_id_t::nullDev(), false); // as long as there is no slave Mock
EXPECT_EQ (ow.reset(OW::Speed::STD), false); // as long as there is no slave Mock
//ow.match(id, OW::Speed::STD);
EXPECT_EQ(ow.rx_data(OW::Speed::STD), 0xFF);
EXPECT_EQ(ow.tx_data(b, OW::Speed::STD), 42);
}
}
test_1w::TEST_F
TEST_F(Test_1w_impl, TestConcept)
Definition: test_1w_impl.cpp:50
test_1w::OW
Definition: test_1w_impl.cpp:33
test_1w::Test_1w_impl
Definition: test_1w_impl.cpp:43
gtest.h
utl::_1wire_id_t
Definition: _1wire_id.h:32
EXPECT_GT
#define EXPECT_GT(val1, val2)
Definition: gtest.h:16655
utl
STL&#39;s core language concepts.
Definition: _1wire.h:30
utl::_1wire_id_t::nullDev
static constexpr const _1wire_id_t & nullDev()
Return nullDev reference.
Definition: _1wire_id.h:50
testing::Test
Definition: gtest.h:15014
test_1w::Test_1w_impl::ow
OW ow
Definition: test_1w_impl.cpp:47
EXPECT_EQ
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:16643
utl::byte_t
uint8_t byte_t
8 bits wide
Definition: types.h:31
utl::_1wire_uart_i
1-wire UART interface template class using CRTP Using the private virtual interface we provide the in...
Definition: _1wire_uart.h:52
_1wire_uart.h
A 1-wire implementation using a microprocessor&#39;s uart for bit timing.
test_1w
Definition: test_1w_impl.cpp:29