diff --git a/hammocking/hammocking.py b/hammocking/hammocking.py index a5033a4..56e131e 100755 --- a/hammocking/hammocking.py +++ b/hammocking/hammocking.py @@ -15,7 +15,7 @@ from jinja2 import Environment, FileSystemLoader import logging -Config.set_library_file('libclang-14.so.1') +# Config.set_library_file('libclang-14.so.1') class Variable: def __init__(self, type: str, name: str, size: int = 0) -> None: diff --git a/pytest.ini b/pytest.ini index 313aa42..46ea658 100644 --- a/pytest.ini +++ b/pytest.ini @@ -1,3 +1,2 @@ [pytest] -env = - PIPENV_MAX_DEPTH=10 +PIPENV_MAX_DEPTH=10 diff --git a/tests/data/mini_c_test/b.c b/tests/data/mini_c_test/b.c index 4f30f79..5b8ad07 100644 --- a/tests/data/mini_c_test/b.c +++ b/tests/data/mini_c_test/b.c @@ -35,3 +35,10 @@ void b_step(void){ local_extern(2); } + +int x1 = 1; + +int get_x1(void) +{ + return x1; +} \ No newline at end of file diff --git a/tests/data/mini_c_test/b_test.cc b/tests/data/mini_c_test/b_test.cc index a5ff396..e7daead 100644 --- a/tests/data/mini_c_test/b_test.cc +++ b/tests/data/mini_c_test/b_test.cc @@ -31,28 +31,40 @@ TEST(b_test, TestSignalChain_3) b_step(); } -TEST(b_test, TestSignalChain_4) +/* Introducing a test fixture */ + +class B : public Test { + void SetUp() override { + mock = CREATE_MOCK(); // Create the mock handle in the fixture + // Now some generic reactions can be set up + ON_CALL(*mock, a_get_y5).WillByDefault(Return(13)); + } + void TearDown() override { + DESTROY_MOCK(); // Tear down the mock handle to finalize its expecations + } + +protected: + mock_ptr_t mock; +}; + +TEST_F(B, TestSignalChain_4) { - LOCAL_MOCK(mymock); a_y4 = 13; - EXPECT_CALL(mymock, c_set_u3_and_u4(_, 13)); + EXPECT_CALL(*mock, c_set_u3_and_u4(_, 13)); b_step(); } -TEST(b_test, TestSignalChain_5) +TEST_F(B, TestSignalChain_5) { - LOCAL_MOCK(mymock); - EXPECT_CALL(mymock, a_get_y5()) - .WillOnce(Return(13)); - EXPECT_CALL(mymock, c_get_y3_and_set_u5(13)); + // Makes use of a_get_y5 behavior from the fixture's setup + EXPECT_CALL(*mock, c_get_y3_and_set_u5(13)); b_step(); } -TEST(b_test, TestSignalChain_6) +TEST_F(B, TestSignalChain_6) { - LOCAL_MOCK(mymock); - EXPECT_CALL(mymock, a_get_y6(_)) + EXPECT_CALL(*mock, a_get_y6(_)) .WillOnce(SetArgPointee<0>(13)); - EXPECT_CALL(mymock, c_set_u6(13)); + EXPECT_CALL(*mock, c_set_u6(13)); b_step(); }