c++ - How to test shared libraries with Google Test Framework -


originally posted in googletestframework forum.

i've started playing google c++ test framework , have worked through samples. i'm working linux, eclipse, , linux gcc tool chain. i've installed c/c++ unit test plugin in eclipse.

i have shared library project i'm trying write tests have hit problem can't figure out. test shared library project, i've built separate executable project , put tests in project.

i've added necessary include paths , libraries builds when try run tests out of executable project, links classes under test, test output not show me meaningful. here's example.

this test class, file called challengeresponsepackettest.cpp in executable project (challengeresponsepacket class shared library project).

test(challengeresponsepackettest, shouldserializepacket) {     const unsigned char salt[] = {0x01, 0x02, 0x03};     const char username[] = "daver";     unsigned char buffer[100];      challengeresponsepacket packet;     packet.setsaltvalue(salt, sizeof(salt));     packet.setcompressiontype(0);     packet.setencryptiontype(0);     packet.setusername(username);     int size = packet.serialize(buffer, sizeof(buffer));      expect_eq(12, size);     expect_eq(5, buffer[0]); } 

and output i'm getting:

[----------] 1 test challengeresponsepackettest [ run      ] challengeresponsepackettest.shouldserializepacket gtest_test: ../src/challengeresponsepacket.cpp:34: virtual int tnp::challengeresponsepacket::serialize(unsigned char*, size_t) const: assertion `_clienthashlength > 0' failed. aborted 

as can imagine, c/c++ unit test plugin has no clue this.

is there reason i'm not getting usual pretty google test framework output?

i guess question have if best way use test framework test shared library code?

thanks,

thanks bret,

that pointed me in right direction. turned out there being thrown (or failing) in code. can't sure because rewrote code , problem went away. had similar problem plugin failed no error running test on command line resulted in seg fault error message.

i've been doing java long time , have come c++. guess i'm used more forgiving tools.

cheers, dave.


Comments