#include #include #include #include struct HL854XTestReadWriteItem { size_t n; const char **tv; size_t tvlen; std::string writebuf; }; static std::function HL854XTestReadCb; static std::function HL854XTestWriteCb; size_t HL854XTestReadCbFunc(void *buf, size_t nbyte) { (void)buf; (void)nbyte; return 0; } size_t HL854XTestWriteCbFunc(const void *buf, size_t nbyte) { (void)buf; return nbyte; } class HL854XTest : public ::testing::Test { public: protected: virtual void SetUp() { di_drv_hl854x_init(&ctx); // The reader is default initialized as locked for the unit tests we must be able to // read synchronous. In the real world there is an async reader so we dont miss any // data. di_bsem_post(&ctx.lock.reader); di_drv_hl854x_set_read(&ctx, HL854XTestReadCbFunc); // HL854XTestReadCb = std::bind(&HL854XTest::__hl854x_read, std::placeholders::_1, std::placeholders::_2); di_drv_hl854x_set_write(&ctx, HL854XTestWriteCbFunc); // HL854XTestWriteCb = std::bind(&HL854XTest::__hl854x_write, this, std::placeholders::_1, std::placeholders::_2); } virtual void TearDown() { } private: struct di_drv_hl854x_ctx ctx; size_t __hl854x_read(void *buf, size_t nbyte) { (void)buf; (void)nbyte; return 0; } size_t __hl854x_write(void *buf, size_t nbyte) { (void)buf; return nbyte; } };