@@ -19,13 +19,11 @@ SCENARIO("Test factories", "[factory]") {
19
19
GIVEN (" A factory with default usage" ) {
20
20
TFactory<Producible> factory;
21
21
22
- WHEN (" Default-constructed" ) {
23
- REQUIRE (factory.IsUnique == false );
24
- REQUIRE (factory.GetReusable () == nullptr );
25
- REQUIRE (not factory.GetHashmap ());
26
- REQUIRE (factory.IsEmpty ());
27
- REQUIRE (factory.GetType () == MetaOf<Producible>());
28
- }
22
+ REQUIRE (factory.IsUnique == false );
23
+ REQUIRE (factory.GetReusable () == nullptr );
24
+ REQUIRE (not factory.GetHashmap ());
25
+ REQUIRE (factory.IsEmpty ());
26
+ REQUIRE (factory.GetType () == MetaOf<Producible>());
29
27
30
28
WHEN (" Two default elements produced" ) {
31
29
const auto descriptor = Construct::From<Producible>();
@@ -39,7 +37,7 @@ SCENARIO("Test factories", "[factory]") {
39
37
REQUIRE (creator.IsDone ());
40
38
REQUIRE (out1.GetCount () == 1 );
41
39
REQUIRE (out1.IsExact <Producible*>());
42
- REQUIRE (out1.As <Producible*>()->Reference (0 ) == 2 );
40
+ REQUIRE (out1.As <Producible*>()->Reference (0 ) == 3 );
43
41
REQUIRE (out1.IsSparse ());
44
42
45
43
creator.Undo ();
@@ -49,7 +47,7 @@ SCENARIO("Test factories", "[factory]") {
49
47
auto out2 = creator.GetOutput ();
50
48
REQUIRE (out2.GetCount () == 1 );
51
49
REQUIRE (out2.IsExact <Producible*>());
52
- REQUIRE (out2.As <Producible*>()->Reference (0 ) == 2 );
50
+ REQUIRE (out2.As <Producible*>()->Reference (0 ) == 3 );
53
51
REQUIRE (out2.IsSparse ());
54
52
55
53
REQUIRE (factory.GetReusable () == factory.GetFrames ()[0 ].GetRaw () + 2 );
@@ -75,13 +73,11 @@ SCENARIO("Test factories", "[factory]") {
75
73
GIVEN (" A factory with unique usage" ) {
76
74
TFactoryUnique<Producible> factory;
77
75
78
- WHEN (" Default-constructed" ) {
79
- REQUIRE (factory.IsUnique == true );
80
- REQUIRE (factory.GetReusable () == nullptr );
81
- REQUIRE (not factory.GetHashmap ());
82
- REQUIRE (factory.IsEmpty ());
83
- REQUIRE (factory.GetType () == MetaOf<Producible>());
84
- }
76
+ REQUIRE (factory.IsUnique == true );
77
+ REQUIRE (factory.GetReusable () == nullptr );
78
+ REQUIRE (not factory.GetHashmap ());
79
+ REQUIRE (factory.IsEmpty ());
80
+ REQUIRE (factory.GetType () == MetaOf<Producible>());
85
81
86
82
WHEN (" Two default elements produced" ) {
87
83
const auto descriptor = Construct::From<Producible>();
@@ -100,7 +96,7 @@ SCENARIO("Test factories", "[factory]") {
100
96
REQUIRE (creator.IsDone ());
101
97
REQUIRE (out1.GetCount () == 1 );
102
98
REQUIRE (out1.IsExact <Producible*>());
103
- REQUIRE (out1.As <Producible*>()->Reference (0 ) == 3 );
99
+ REQUIRE (out1.As <Producible*>()->Reference (0 ) == 4 );
104
100
REQUIRE (out1.IsSparse ());
105
101
REQUIRE (out1 == out2);
106
102
@@ -117,24 +113,26 @@ SCENARIO("Test factories", "[factory]") {
117
113
118
114
prototype.Reference (-1 );
119
115
}
120
-
116
+
121
117
WHEN (" Two elements produced via descriptors" ) {
122
118
TMany<Producer> context;
123
119
context.New (1 );
124
120
125
121
const auto descriptor = Construct::From<Producible>(
126
- Traits::Parent (&context[0 ]));
122
+ Traits::Parent (&context[0 ]),
123
+ " test" _text
124
+ );
127
125
Verbs::Create creator {&descriptor};
128
126
const Producible prototype {&producer, descriptor.GetDescriptor ()};
129
127
130
128
factory.Create (&producer, creator);
131
129
auto out1 = creator.GetOutput ();
132
- REQUIRE (out1.As <Producible*>()->Reference (0 ) == 2 );
130
+ REQUIRE (out1.As <Producible*>()->Reference (0 ) == 3 );
133
131
134
132
creator.Undo ();
135
133
factory.Create (&producer, creator);
136
134
auto out2 = creator.GetOutput ();
137
- REQUIRE (out2.As <Producible*>()->Reference (0 ) == 3 );
135
+ REQUIRE (out2.As <Producible*>()->Reference (0 ) == 4 );
138
136
139
137
// Parent traits shouldn't participate in hashing
140
138
const auto hash = descriptor.GetDescriptor ().GetHash ();
@@ -144,7 +142,7 @@ SCENARIO("Test factories", "[factory]") {
144
142
REQUIRE (creator.IsDone ());
145
143
REQUIRE (out1.GetCount () == 1 );
146
144
REQUIRE (out1.IsExact <Producible*>());
147
- REQUIRE (out1.As <Producible*>()->Reference (0 ) == 3 );
145
+ REQUIRE (out1.As <Producible*>()->Reference (0 ) == 4 );
148
146
REQUIRE (out1.IsSparse ());
149
147
REQUIRE (out1 == out2);
150
148
0 commit comments