Skip to content

Commit e828ade

Browse files
apply changes to mac cases
1 parent a6d3df5 commit e828ade

File tree

2 files changed

+66
-66
lines changed

2 files changed

+66
-66
lines changed

code/tests/cases/test_ddd.m

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -20,94 +20,94 @@
2020
int id;
2121
char name[50];
2222
int processed;
23-
} Entity;
23+
} ObjcEntity;
2424

2525
typedef struct {
2626
int x;
2727
int y;
28-
} ValueObject;
28+
} ObjcValueObject;
2929

3030
typedef struct {
3131
int id;
3232
int child_count;
33-
Entity children[10];
34-
} AggregateRoot;
33+
ObjcEntity children[10];
34+
} ObjcAggregateRoot;
3535

3636
typedef struct {
37-
Entity entities[10];
37+
ObjcEntity entities[10];
3838
int count;
39-
} Repository;
39+
} ObjcRepository;
4040

4141
typedef struct {
4242
bool dummy;
43-
} Service;
43+
} ObjcService;
4444

45-
Entity create_entity(int id, const char *name) {
46-
Entity entity;
45+
ObjcEntity create_entity(int id, const char *name) {
46+
ObjcEntity entity;
4747
entity.id = id;
4848
strcpy(entity.name, name);
4949
entity.processed = 0;
5050
return entity;
5151
}
5252

53-
ValueObject create_value_object(int x, int y) {
54-
ValueObject vo;
53+
ObjcValueObject create_value_object(int x, int y) {
54+
ObjcValueObject vo;
5555
vo.x = x;
5656
vo.y = y;
5757
return vo;
5858
}
5959

60-
int value_object_equals(ValueObject vo1, ValueObject vo2) {
60+
int value_object_equals(ObjcValueObject vo1, ObjcValueObject vo2) {
6161
return (vo1.x == vo2.x && vo1.y == vo2.y);
6262
}
6363

64-
AggregateRoot create_aggregate_root(int id) {
65-
AggregateRoot ar;
64+
ObjcAggregateRoot create_aggregate_root(int id) {
65+
ObjcAggregateRoot ar;
6666
ar.id = id;
6767
ar.child_count = 0;
6868
return ar;
6969
}
7070

71-
void add_child_entity(AggregateRoot *ar, Entity entity) {
71+
void add_child_entity(ObjcAggregateRoot *ar, ObjcEntity entity) {
7272
if (ar->child_count < 10) {
7373
ar->children[ar->child_count++] = entity;
7474
}
7575
}
7676

77-
Repository create_repository(void) {
78-
Repository repo;
77+
ObjcRepository create_repository(void) {
78+
ObjcRepository repo;
7979
repo.count = 0;
8080
return repo;
8181
}
8282

83-
void repository_add(Repository *repo, Entity entity) {
83+
void repository_add(ObjcRepository *repo, ObjcEntity entity) {
8484
if (repo->count < 10) {
8585
repo->entities[repo->count++] = entity;
8686
}
8787
}
8888

89-
int repository_count(Repository *repo) {
89+
int repository_count(ObjcRepository *repo) {
9090
return repo->count;
9191
}
9292

93-
Entity repository_get(Repository *repo, int id) {
93+
ObjcEntity repository_get(ObjcRepository *repo, int id) {
9494
for (int i = 0; i < repo->count; ++i) {
9595
if (repo->entities[i].id == id) {
9696
return repo->entities[i];
9797
}
9898
}
99-
Entity empty_entity = {0};
99+
ObjcEntity empty_entity = {0};
100100
return empty_entity;
101101
}
102102

103-
Service create_service(void) {
104-
Service service;
103+
ObjcService create_service(void) {
104+
ObjcService service;
105105
service.dummy = 0;
106106
// Initialize service-specific fields
107107
return service;
108108
}
109109

110-
void service_process(Service *service, Entity *entity) {
110+
void service_process(ObjcService *service, ObjcEntity *entity) {
111111
entity->processed = 1;
112112
service->dummy = 1;
113113
}
@@ -141,26 +141,26 @@ void service_process(Service *service, Entity *entity) {
141141

142142
FOSSIL_TEST(objc_ddd_entity_creation) {
143143
// Example of creating an entity
144-
Entity entity = create_entity(42, "Sample Entity");
144+
ObjcEntity entity = create_entity(42, "Sample ObjcEntity");
145145

146146
// Test cases
147-
FOSSIL_TEST_ASSUME(entity.id == 42, "Entity ID should be 42");
148-
FOSSIL_TEST_ASSUME(strcmp(entity.name, "Sample Entity") == 0, "Entity name should be 'Sample Entity'");
147+
FOSSIL_TEST_ASSUME(entity.id == 42, "ObjcEntity ID should be 42");
148+
FOSSIL_TEST_ASSUME(strcmp(entity.name, "Sample ObjcEntity") == 0, "ObjcEntity name should be 'Sample ObjcEntity'");
149149
} // end case
150150

151151
FOSSIL_TEST(objc_ddd_value_object_equality) {
152152
// Example of value object equality
153-
ValueObject vo1 = create_value_object(10, 20);
154-
ValueObject vo2 = create_value_object(10, 20);
153+
ObjcValueObject vo1 = create_value_object(10, 20);
154+
ObjcValueObject vo2 = create_value_object(10, 20);
155155

156156
// Test cases
157157
FOSSIL_TEST_ASSUME(value_object_equals(vo1, vo2), "Value objects should be equal");
158158
} // end case
159159

160160
FOSSIL_TEST(objc_ddd_aggregate_root_behavior) {
161161
// Example of aggregate root behavior
162-
AggregateRoot ar = create_aggregate_root(1);
163-
add_child_entity(&ar, create_entity(2, "Child Entity"));
162+
ObjcAggregateRoot ar = create_aggregate_root(1);
163+
add_child_entity(&ar, create_entity(2, "Child ObjcEntity"));
164164

165165
// Test cases
166166
FOSSIL_TEST_ASSUME(ar.child_count == 1, "Aggregate root should have one child entity");
@@ -169,23 +169,23 @@ void service_process(Service *service, Entity *entity) {
169169

170170
FOSSIL_TEST(objc_ddd_repository_usage) {
171171
// Example of repository usage
172-
Repository repo = create_repository();
173-
Entity entity = create_entity(1, "Repo Entity");
172+
ObjcRepository repo = create_repository();
173+
ObjcEntity entity = create_entity(1, "Repo ObjcEntity");
174174
repository_add(&repo, entity);
175175

176176
// Test cases
177-
FOSSIL_TEST_ASSUME(repository_count(&repo) == 1, "Repository should contain one entity");
177+
FOSSIL_TEST_ASSUME(repository_count(&repo) == 1, "ObjcRepository should contain one entity");
178178
FOSSIL_TEST_ASSUME(repository_get(&repo, 1).id == 1, "Retrieved entity ID should be 1");
179179
} // end case
180180

181181
FOSSIL_TEST(objc_ddd_service_layer) {
182182
// Example of service layer usage
183-
Service service = create_service();
184-
Entity entity = create_entity(1, "Service Entity");
183+
ObjcService service = create_service();
184+
ObjcEntity entity = create_entity(1, "ObjcService ObjcEntity");
185185
service_process(&service, &entity);
186186

187187
// Test cases
188-
FOSSIL_TEST_ASSUME(entity.processed == true, "Entity should be processed by the service");
188+
FOSSIL_TEST_ASSUME(entity.processed == true, "ObjcEntity should be processed by the service");
189189
} // end case
190190

191191
// * * * * * * * * * * * * * * * * * * * * * * * *

code/tests/cases/test_ddd.mm

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -17,45 +17,45 @@
1717
#include <string>
1818

1919
// Define the necessary types and functions for the test cases
20-
class Entity {
20+
class ObjcppEntity {
2121
public:
2222
int id;
2323
std::string name;
2424
bool processed;
2525

26-
Entity(int id, const std::string &name) : id(id), name(name), processed(false) {}
26+
ObjcppEntity(int id, const std::string &name) : id(id), name(name), processed(false) {}
2727
};
2828

29-
class ValueObject {
29+
class ObjcppValueObject {
3030
public:
3131
int x, y;
3232

33-
ValueObject(int x, int y) : x(x), y(y) {}
33+
ObjcppValueObject(int x, int y) : x(x), y(y) {}
3434

35-
bool operator==(const ValueObject &other) const {
35+
bool operator==(const ObjcppValueObject &other) const {
3636
return x == other.x && y == other.y;
3737
}
3838
};
3939

40-
class AggregateRoot {
40+
class ObjcppAggregateRoot {
4141
public:
4242
int id;
43-
std::vector<Entity> children;
43+
std::vector<ObjcppEntity> children;
4444

45-
AggregateRoot(int id) : id(id) {}
45+
ObjcppAggregateRoot(int id) : id(id) {}
4646

47-
void addChild(const Entity &entity) {
47+
void addChild(const ObjcppEntity &entity) {
4848
if (children.size() < 10) {
4949
children.push_back(entity);
5050
}
5151
}
5252
};
5353

54-
class Repository {
54+
class ObjcppRepository {
5555
public:
56-
std::vector<Entity> entities;
56+
std::vector<ObjcppEntity> entities;
5757

58-
void add(const Entity &entity) {
58+
void add(const ObjcppEntity &entity) {
5959
if (entities.size() < 10) {
6060
entities.push_back(entity);
6161
}
@@ -65,19 +65,19 @@ size_t count() const {
6565
return entities.size();
6666
}
6767

68-
Entity get(int id) const {
68+
ObjcppEntity get(int id) const {
6969
for (const auto &entity : entities) {
7070
if (entity.id == id) {
7171
return entity;
7272
}
7373
}
74-
return Entity(0, "");
74+
return ObjcppEntity(0, "");
7575
}
7676
};
7777

78-
class Service {
78+
class ObjcppService {
7979
public:
80-
void process(Entity &entity) {
80+
void process(ObjcppEntity &entity) {
8181
entity.processed = true;
8282
}
8383
};
@@ -111,26 +111,26 @@ void process(Entity &entity) {
111111

112112
FOSSIL_TEST(objcpp_ddd_entity_creation) {
113113
// Example of creating an entity
114-
Entity entity(42, "Sample Entity");
114+
ObjcppEntity entity(42, "Sample ObjcppEntity");
115115

116116
// Test cases
117-
FOSSIL_TEST_ASSUME(entity.id == 42, "Entity ID should be 42");
118-
FOSSIL_TEST_ASSUME(entity.name == "Sample Entity", "Entity name should be 'Sample Entity'");
117+
FOSSIL_TEST_ASSUME(entity.id == 42, "ObjcppEntity ID should be 42");
118+
FOSSIL_TEST_ASSUME(entity.name == "Sample ObjcppEntity", "ObjcppEntity name should be 'Sample ObjcppEntity'");
119119
} // end case
120120

121121
FOSSIL_TEST(objcpp_ddd_value_object_equality) {
122122
// Example of value object equality
123-
ValueObject vo1(10, 20);
124-
ValueObject vo2(10, 20);
123+
ObjcppValueObject vo1(10, 20);
124+
ObjcppValueObject vo2(10, 20);
125125

126126
// Test cases
127127
FOSSIL_TEST_ASSUME(vo1 == vo2, "Value objects should be equal");
128128
} // end case
129129

130130
FOSSIL_TEST(objcpp_ddd_aggregate_root_behavior) {
131131
// Example of aggregate root behavior
132-
AggregateRoot ar(1);
133-
ar.addChild(Entity(2, "Child Entity"));
132+
ObjcppAggregateRoot ar(1);
133+
ar.addChild(ObjcppEntity(2, "Child ObjcppEntity"));
134134

135135
// Test cases
136136
FOSSIL_TEST_ASSUME(ar.children.size() == 1, "Aggregate root should have one child entity");
@@ -139,23 +139,23 @@ void process(Entity &entity) {
139139

140140
FOSSIL_TEST(objcpp_ddd_repository_usage) {
141141
// Example of repository usage
142-
Repository repo;
143-
Entity entity(1, "Repo Entity");
142+
ObjcppRepository repo;
143+
ObjcppEntity entity(1, "Repo ObjcppEntity");
144144
repo.add(entity);
145145

146146
// Test cases
147-
FOSSIL_TEST_ASSUME(repo.count() == 1, "Repository should contain one entity");
147+
FOSSIL_TEST_ASSUME(repo.count() == 1, "ObjcppRepository should contain one entity");
148148
FOSSIL_TEST_ASSUME(repo.get(1).id == 1, "Retrieved entity ID should be 1");
149149
} // end case
150150

151151
FOSSIL_TEST(objcpp_ddd_service_layer) {
152152
// Example of service layer usage
153-
Service service;
154-
Entity entity(1, "Service Entity");
153+
ObjcppService service;
154+
ObjcppEntity entity(1, "ObjcppService ObjcppEntity");
155155
service.process(entity);
156156

157157
// Test cases
158-
FOSSIL_TEST_ASSUME(entity.processed == true, "Entity should be processed by the service");
158+
FOSSIL_TEST_ASSUME(entity.processed == true, "ObjcppEntity should be processed by the service");
159159
} // end case
160160

161161
// * * * * * * * * * * * * * * * * * * * * * * * *

0 commit comments

Comments
 (0)