I wrote a c++ class, this class uses the c function library written by a third party.
extern "C" {
#include "nats/nats.h"
}
class NatsConnection {
public:
void Connect() {
natsConnection_Connect(&natsConnection_, natsOptions_);
natsConnection_SubscribeSync(&natsSubscription_, natsConnection_,
configuration_.subject.c_str());
// some other c++ code.
}
}
The above class uses functions imported from c: natsConnection_Connect
, natsConnection_SubscribeSync
.
Now I need to write a unit test to cover some other c++ code
, I am using gtest
, I know how to mock a C++ class, but once I use the C code I don’t know how to start.
how do i write the test? Is there has a best practice?
Go to Source
Author: MengHan Yu