Skip to content

Commit c13951b

Browse files
revert to classic function stubs
1 parent 6156a3e commit c13951b

File tree

1 file changed

+26
-26
lines changed

1 file changed

+26
-26
lines changed

code/tests/cases/test_ddd.c

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -46,56 +46,55 @@ FOSSIL_MOCK_STRUCT(Service) {
4646
bool dummy;
4747
} Service;
4848

49-
50-
FOSSIL_MOCK_FUNC(Entity, create_entity, int id, const char *name) {
49+
Entity create_entity(int id, const char *name) {
5150
Entity entity;
5251
entity.id = id;
5352
strcpy(entity.name, name);
5453
entity.processed = 0;
5554
return entity;
5655
}
5756

58-
FOSSIL_MOCK_FUNC(ValueObject, create_value_object, int x, int y) {
57+
ValueObject create_value_object(int x, int y) {
5958
ValueObject vo;
6059
vo.x = x;
6160
vo.y = y;
6261
return vo;
6362
}
6463

65-
FOSSIL_MOCK_FUNC(int, value_object_equals, ValueObject vo1, ValueObject vo2) {
64+
int value_object_equals(ValueObject vo1, ValueObject vo2) {
6665
return (vo1.x == vo2.x && vo1.y == vo2.y);
6766
}
6867

69-
FOSSIL_MOCK_FUNC(AggregateRoot, create_aggregate_root, int id) {
68+
AggregateRoot create_aggregate_root(int id) {
7069
AggregateRoot ar;
7170
ar.id = id;
7271
ar.child_count = 0;
7372
return ar;
7473
}
7574

76-
FOSSIL_MOCK_FUNC(void, add_child_entity, AggregateRoot *ar, Entity entity) {
75+
void add_child_entity(AggregateRoot *ar, Entity entity) {
7776
if (ar->child_count < 10) {
7877
ar->children[ar->child_count++] = entity;
7978
}
8079
}
8180

82-
FOSSIL_MOCK_FUNC(Repository, create_repository, void) {
81+
Repository create_repository(void) {
8382
Repository repo;
8483
repo.count = 0;
8584
return repo;
8685
}
8786

88-
FOSSIL_MOCK_FUNC(void, repository_add, Repository *repo, Entity entity) {
87+
void repository_add(Repository *repo, Entity entity) {
8988
if (repo->count < 10) {
9089
repo->entities[repo->count++] = entity;
9190
}
9291
}
9392

94-
FOSSIL_MOCK_FUNC(int, repository_count, Repository *repo) {
93+
int repository_count(Repository *repo) {
9594
return repo->count;
9695
}
9796

98-
FOSSIL_MOCK_FUNC(Entity, repository_get, Repository *repo, int id) {
97+
Entity repository_get(Repository *repo, int id) {
9998
for (int i = 0; i < repo->count; ++i) {
10099
if (repo->entities[i].id == id) {
101100
return repo->entities[i];
@@ -105,14 +104,14 @@ FOSSIL_MOCK_FUNC(Entity, repository_get, Repository *repo, int id) {
105104
return empty_entity;
106105
}
107106

108-
FOSSIL_MOCK_FUNC(Service, create_service, void) {
107+
Service create_service(void) {
109108
Service service;
110109
service.dummy = 0;
111110
// Initialize service-specific fields
112111
return service;
113112
}
114113

115-
FOSSIL_MOCK_FUNC(void, service_process, Service *service, Entity *entity) {
114+
void service_process(Service *service, Entity *entity) {
116115
entity->processed = 1;
117116
service->dummy = 1;
118117
}
@@ -146,25 +145,26 @@ FOSSIL_TEARDOWN(c_ddd_suite) {
146145

147146
FOSSIL_TEST_CASE(c_ddd_entity_creation) {
148147
// Example of creating an entity
149-
Entity entity = fossil_mockup_create_entity(42, "Sample Entity");
148+
Entity entity = create_entity(42, "Sample Entity");
150149

151150
// Test cases
152151
FOSSIL_TEST_ASSUME(entity.id == 42, "Entity ID should be 42");
152+
FOSSIL_TEST_ASSUME(strcmp(entity.name, "Sample Entity") == 0, "Entity name should be 'Sample Entity'");
153153
} // end case
154154

155155
FOSSIL_TEST_CASE(c_ddd_value_object_equality) {
156156
// Example of value object equality
157-
ValueObject vo1 = fossil_mockup_create_value_object(10, 20);
158-
ValueObject vo2 = fossil_mockup_create_value_object(10, 20);
157+
ValueObject vo1 = create_value_object(10, 20);
158+
ValueObject vo2 = create_value_object(10, 20);
159159

160160
// Test cases
161-
FOSSIL_TEST_ASSUME(fossil_mockup_value_object_equals(vo1, vo2), "Value objects should be equal");
161+
FOSSIL_TEST_ASSUME(value_object_equals(vo1, vo2), "Value objects should be equal");
162162
} // end case
163163

164164
FOSSIL_TEST_CASE(c_ddd_aggregate_root_behavior) {
165165
// Example of aggregate root behavior
166-
AggregateRoot ar = fossil_mockup_create_aggregate_root(1);
167-
fossil_mockup_add_child_entity(&ar, fossil_mockup_create_entity(2, "Child Entity"));
166+
AggregateRoot ar = create_aggregate_root(1);
167+
add_child_entity(&ar, create_entity(2, "Child Entity"));
168168

169169
// Test cases
170170
FOSSIL_TEST_ASSUME(ar.child_count == 1, "Aggregate root should have one child entity");
@@ -173,20 +173,20 @@ FOSSIL_TEST_CASE(c_ddd_aggregate_root_behavior) {
173173

174174
FOSSIL_TEST_CASE(c_ddd_repository_usage) {
175175
// Example of repository usage
176-
Repository repo = fossil_mockup_create_repository();
177-
Entity entity = fossil_mockup_create_entity(1, "Repo Entity");
178-
fossil_mockup_repository_add(&repo, entity);
176+
Repository repo = create_repository();
177+
Entity entity = create_entity(1, "Repo Entity");
178+
repository_add(&repo, entity);
179179

180180
// Test cases
181-
FOSSIL_TEST_ASSUME(fossil_mockup_repository_count(&repo) == 1, "Repository should contain one entity");
182-
FOSSIL_TEST_ASSUME(fossil_mockup_repository_get(&repo, 1).id == 1, "Retrieved entity ID should be 1");
181+
FOSSIL_TEST_ASSUME(repository_count(&repo) == 1, "Repository should contain one entity");
182+
FOSSIL_TEST_ASSUME(repository_get(&repo, 1).id == 1, "Retrieved entity ID should be 1");
183183
} // end case
184184

185185
FOSSIL_TEST_CASE(c_ddd_service_layer) {
186186
// Example of service layer usage
187-
Service service = fossil_mockup_create_service();
188-
Entity entity = fossil_mockup_create_entity(1, "Service Entity");
189-
fossil_mockup_service_process(&service, &entity);
187+
Service service = create_service();
188+
Entity entity = create_entity(1, "Service Entity");
189+
service_process(&service, &entity);
190190

191191
// Test cases
192192
FOSSIL_TEST_ASSUME(entity.processed == true, "Entity should be processed by the service");

0 commit comments

Comments
 (0)