poplarbird
unread,Mar 21, 2011, 11:53:52 PM3/21/11Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Google C++ Mocking Framework
source code:
1 #include <gmock/gmock.h>
2 #include <gtest/gtest.h>
3 using ::testing::Return;
4 class MockClass {
5 public:
6 MockClass() {}
7 MOCK_METHOD0(IntFunc, int());
8 };
9
10 TEST(DoDefaultTest, ReturnsBuiltInDefaultValueByDefault) {
11 MockClass mock;
12 EXPECT_CALL(mock, IntFunc())
13 .WillOnce(Return(1));
14 EXPECT_EQ(0, mock.IntFunc());
15 }
~
with $(GMOCK_ROOT)/src/gmock_main.o
test/demo_test --gtest_output=xml --gmock_verbose=info
Running main() from gmock_main.cc
[==========] Running 1 test from 1 test case.
[----------] Global test environment set-up.
[----------] 1 test from DoDefaultTest
[ RUN ] DoDefaultTest.ReturnsBuiltInDefaultValueByDefault
mock_abstract_class.cc:13: EXPECT_CALL(mock, IntFunc()) invoked
Stack trace:
gmake: *** [test] Segmentation Fault (core dumped)
$ dbx test/demo_test core
For information about new features see `help changes'
To remove this message, put `dbxenv suppress_startup_message 7.7' in
your .dbxrc
Reading demo_test
core file header read successfully
Reading ld.so.1
Reading libnsl.so.1
Reading libresolv.so.2
Reading libsocket.so.1
Reading libstlport.so.1
Reading librt.so.1
Reading libCrun.so.1
Reading libm.so.2
Reading libthread.so.1
Reading libc.so.1
Reading libdl.so.1
Reading libgen.so.1
Reading libm.so.1
Reading libpthread.so.1
Reading libaio.so.1
Reading libmd.so.1
Reading libc_psr.so.1
t@1 (l@1) program terminated by signal SEGV (no mapping at the fault
address)
0x00086d08: AddExpectation+0x0008: ld [%i0], %l0
(dbx) where
current thread: t@1
=>[1] testing::Sequence::AddExpectation(0x5, 0xffbfeb60, 0xffbfec9c,
0xffbfeb97, 0x1, 0xffbfeb60), at 0x86d08
[2]
testing::internal::FunctionMockerBase<int()>::AddNewExpectation(0xffbff588,
0xb3f75, 0xd, 0xffbff0b0, 0xffbff598, 0xd4928), at 0x44c44
[3]
testing::internal::MockSpec<int()>::InternalExpectedAt(0xffbff594,
0xb3f75, 0xd, 0xb3f8c, 0xb3f91, 0x0), at 0x437d4
[4]
DoDefaultTest_ReturnsBuiltInDefaultValueByDefault_Test::TestBody(0xd1fb0,
0xffbff5a8, 0xffbffa3c, 0x0, 0x0, 0xffbff588), at 0x40e34
[5] testing::Test::Run(0xd1fb0, 0xd2bb0, 0x0, 0xd1fb0, 0x0,
0xd29d8), at 0x59ad4
[6] testing::internal::TestInfoImpl::Run(0xd22f0, 0xd1f00,
0xffbffa3c, 0x0, 0xd1fb0, 0xd29d8), at 0x5a75c
[7] testing::TestCase::Run(0xd2b28, 0xd0b88, 0x0, 0xd22f0, 0x0,
0xd29d8), at 0x5b4d8
[8] testing::internal::UnitTestImpl::RunAllTests(0xd29d8, 0x0,
0xffbffa3c, 0x0, 0x0, 0xd0b88), at 0x63d68
[9] testing::UnitTest::Run(0xce018, 0xffbffa2c, 0x0, 0x0, 0x0,
0xd0570), at 0x6134c
[10] main(0x3, 0xffbffa2c, 0xffbffa3c, 0xcd400, 0xff050600, 0x0), at
0x4ce34
$ pstack core
core 'core' of 20846: test/demo_test --gtest_output=xml --
gmock_verbose=info
00086d08 __1cHtestingISequenceOAddExpectation6kMrkn0ALExpectation__v_
(5, ffbfeb60, ffbfec9c, ffbfeb97, 1, ffbfeb60) + 8
00044c44
__1cHtestingIinternalSFunctionMockerBase4CF_i_RAddNewExpectation6MpkcirknDstdMbasic_string4Ccn0DLchar_traits4Cc__n0DJallocator4Cc____rkn0DDtr1Ftuple4CvCvCvCvCvCvCvCvCvCv___rn0BQTypedExpectation4C2___
(ffbff588, b3f75, d, ffbff0b0, ffbff598, d4928) + 44c
000437d4
__1cHtestingIinternalIMockSpec4CF_i_SInternalExpectedAt6Mpkci55_rn0BQTypedExpectation4C2___
(ffbff594, b3f75, d, b3f8c, b3f91, 0) + 36c
00040e34
__1ccCDoDefaultTest_ReturnsBuiltInDefaultValueByDefault_TestITestBody6M_v_
(d1fb0, ffbff5a8, ffbffa3c, 0, 0, ffbff588) + 1cc
00059ad4 __1cHtestingETestDRun6M_v_ (d1fb0, d2bb0, 0, d1fb0, 0,
d29d8) + b4
0005a75c __1cHtestingIinternalMTestInfoImplDRun6M_v_ (d22f0, d1f00,
ffbffa3c, 0, d1fb0, d29d8) + cc
0005b4d8 __1cHtestingITestCaseDRun6M_v_ (d2b28, d0b88, 0, d22f0, 0,
d29d8) + c8
00063d68 __1cHtestingIinternalMUnitTestImplLRunAllTests6M_i_ (d29d8,
0, ffbffa3c, 0, 0, d0b88) + 398
0006134c __1cHtestingIUnitTestDRun6M_i_ (ce018, ffbffa2c, 0, 0, 0,
d0570) + 4
0004ce34 main (3, ffbffa2c, ffbffa3c, cd400, ff050600, 0) + 44
0003d208 _start (0, 0, 0, 0, 0, 0) + 108