i have a one question. i use the following structure as fixture:
class unvalidSDPTest : public ::testing::Test{
protected:
virtual void SetUp(){
std::string Name("name");
Server=new SipServer(Name);
std::ifstream offerFile,answerFile;
offerFile.open("unvalidOfferSDP.txt");
answerFile.open("unvalidAnswerSDP.txt");
std::string offerRawSDP,answerRawSDP;
offerFile>>offerRawSDP;
answerFile>>answerRawSDP;
offerSDPSession = Server->MakeSDPSession( const_cast(offerRawSDP.c_str()) ) ;
answerSDPSession = Server->MakeSDPSession( const_cast(answerRawSDP.c_str()) ) ;
}
virtual void TearDown(){
delete Server;
}
pjmedia_sdp_session *offerSDPSession, *answerSDPSession ;
SipServer *Server;
SDPNeg Negotiator;
};
and i want to parametrize this class by file name. how make it better?
There’s many ways to do this – I’ll show you two:
Method 1: Create a base class with a virtual functions, then derive from it.
Method 2: use a traits like system and templating: