Skip to content

Commit

Permalink
#41: Rename for backward compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
theHolgi authored and xxthunder committed Apr 13, 2024
1 parent bdbd21a commit 304d3d3
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 28 deletions.
6 changes: 3 additions & 3 deletions hammocking/templates/gmock/mockup.h.j2
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ class class_mockup {
}; /* class_mockup */

/* Version A: Create a local object that is destroyed when out of scope */
#define LOCAL_MOCK(name) class_mockup name
#define CREATE_MOCK(name) class_mockup name

/* Version B: Allocate an object that will be only explicitly deallocated */
#define CREATE_MOCK() new class_mockup
#define DESTROY_MOCK() {if(mockup_global_ptr) delete mockup_global_ptr;}
#define CREATE_PERSISTENT_MOCK() new class_mockup
#define DESTROY_PERSISTENT_MOCK() {if(mockup_global_ptr) delete mockup_global_ptr;}

#endif /* mockup{{suffix}}_h */
6 changes: 3 additions & 3 deletions tests/data/gmock_test/test_add_function_get/mockup.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ class class_mockup {
}; /* class_mockup */

/* Version A: Create a local object that is destroyed when out of scope */
#define LOCAL_MOCK(name) class_mockup name
#define CREATE_MOCK(name) class_mockup name

/* Version B: Allocate an object that will be only explicitly deallocated */
#define CREATE_MOCK() new class_mockup
#define DESTROY_MOCK() {if(mockup_global_ptr) delete mockup_global_ptr;}
#define CREATE_PERSISTENT_MOCK() new class_mockup
#define DESTROY_PERSISTENT_MOCK() {if(mockup_global_ptr) delete mockup_global_ptr;}

#endif /* mockup_h */
6 changes: 3 additions & 3 deletions tests/data/gmock_test/test_add_function_set_one_arg/mockup.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ class class_mockup {
}; /* class_mockup */

/* Version A: Create a local object that is destroyed when out of scope */
#define LOCAL_MOCK(name) class_mockup name
#define CREATE_MOCK(name) class_mockup name

/* Version B: Allocate an object that will be only explicitly deallocated */
#define CREATE_MOCK() new class_mockup
#define DESTROY_MOCK() {if(mockup_global_ptr) delete mockup_global_ptr;}
#define CREATE_PERSISTENT_MOCK() new class_mockup
#define DESTROY_PERSISTENT_MOCK() {if(mockup_global_ptr) delete mockup_global_ptr;}

#endif /* mockup_h */
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ class class_mockup {
}; /* class_mockup */

/* Version A: Create a local object that is destroyed when out of scope */
#define LOCAL_MOCK(name) class_mockup name
#define CREATE_MOCK(name) class_mockup name

/* Version B: Allocate an object that will be only explicitly deallocated */
#define CREATE_MOCK() new class_mockup
#define DESTROY_MOCK() {if(mockup_global_ptr) delete mockup_global_ptr;}
#define CREATE_PERSISTENT_MOCK() new class_mockup
#define DESTROY_PERSISTENT_MOCK() {if(mockup_global_ptr) delete mockup_global_ptr;}

#endif /* mockup_h */
6 changes: 3 additions & 3 deletions tests/data/gmock_test/test_empty_templates/mockup.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ class class_mockup {
}; /* class_mockup */

/* Version A: Create a local object that is destroyed when out of scope */
#define LOCAL_MOCK(name) class_mockup name
#define CREATE_MOCK(name) class_mockup name

/* Version B: Allocate an object that will be only explicitly deallocated */
#define CREATE_MOCK() new class_mockup
#define DESTROY_MOCK() {if(mockup_global_ptr) delete mockup_global_ptr;}
#define CREATE_PERSISTENT_MOCK() new class_mockup
#define DESTROY_PERSISTENT_MOCK() {if(mockup_global_ptr) delete mockup_global_ptr;}

#endif /* mockup_h */
6 changes: 3 additions & 3 deletions tests/data/gmock_test/test_mini_c_gmock/mockup.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ class class_mockup {
}; /* class_mockup */

/* Version A: Create a local object that is destroyed when out of scope */
#define LOCAL_MOCK(name) class_mockup name
#define CREATE_MOCK(name) class_mockup name

/* Version B: Allocate an object that will be only explicitly deallocated */
#define CREATE_MOCK() new class_mockup
#define DESTROY_MOCK() {if(mockup_global_ptr) delete mockup_global_ptr;}
#define CREATE_PERSISTENT_MOCK() new class_mockup
#define DESTROY_PERSISTENT_MOCK() {if(mockup_global_ptr) delete mockup_global_ptr;}

#endif /* mockup_h */
8 changes: 4 additions & 4 deletions tests/data/mini_c_test/b_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ TEST(b_test, TestSignalChain_1)

TEST(b_test, TestSignalChain_2)
{
LOCAL_MOCK(mymock);
CREATE_MOCK(mymock);
EXPECT_CALL(mymock, a_get_y2()).WillRepeatedly(Return(13));
EXPECT_CALL(mymock, c_set_u2(13));
b_step();
}

TEST(b_test, TestSignalChain_3)
{
LOCAL_MOCK(mymock);
CREATE_MOCK(mymock);
EXPECT_CALL(mymock, a_get_y3_and_set_u5(_)).WillRepeatedly(Return(13));
EXPECT_CALL(mymock, c_set_u3_and_u4(13, _));
b_step();
Expand All @@ -35,12 +35,12 @@ TEST(b_test, TestSignalChain_3)

class B : public Test {
void SetUp() override {
mock = CREATE_MOCK(); // Create the mock handle in the fixture
mock = CREATE_PERSISTENT_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
DESTROY_PERSISTENT_MOCK(); // Tear down the mock handle to finalize its expecations
}

protected:
Expand Down
12 changes: 6 additions & 6 deletions tests/hammocking_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,11 +326,11 @@ class class_mockup {
}; /* class_mockup */
/* Version A: Create a local object that is destroyed when out of scope */
#define LOCAL_MOCK(name) class_mockup name
#define CREATE_MOCK(name) class_mockup name
/* Version B: Allocate an object that will be only explicitly deallocated */
#define CREATE_MOCK() new class_mockup
#define DESTROY_MOCK() {if(mockup_global_ptr) delete mockup_global_ptr;}
#define CREATE_PERSISTENT_MOCK() new class_mockup
#define DESTROY_PERSISTENT_MOCK() {if(mockup_global_ptr) delete mockup_global_ptr;}
#endif /* mockup_h */
"""
Expand Down Expand Up @@ -364,11 +364,11 @@ class class_mockup {
}; /* class_mockup */
/* Version A: Create a local object that is destroyed when out of scope */
#define LOCAL_MOCK(name) class_mockup name
#define CREATE_MOCK(name) class_mockup name
/* Version B: Allocate an object that will be only explicitly deallocated */
#define CREATE_MOCK() new class_mockup
#define DESTROY_MOCK() {if(mockup_global_ptr) delete mockup_global_ptr;}
#define CREATE_PERSISTENT_MOCK() new class_mockup
#define DESTROY_PERSISTENT_MOCK() {if(mockup_global_ptr) delete mockup_global_ptr;}
#endif /* mockup_new_h */
"""
Expand Down

0 comments on commit 304d3d3

Please sign in to comment.