@@ -67,7 +67,7 @@ SmallVector<AqlValue> createArgVec(const VPackSlice slice) {
67
67
}
68
68
69
69
void expectEqSlices (const VPackSlice actualSlice,
70
- const VPackSlice expectedSlice) {
70
+ const VPackSlice expectedSlice, char const * args ) {
71
71
ASSERT_TRUE ((actualSlice.isNumber () && expectedSlice.isNumber ()) ||
72
72
(actualSlice.isArray () && expectedSlice.isArray ()));
73
73
@@ -76,16 +76,16 @@ void expectEqSlices(const VPackSlice actualSlice,
76
76
VPackValueLength expectedSize = expectedSlice.length ();
77
77
ASSERT_EQ (actualSize, expectedSize);
78
78
79
- double lhs, rhs;
80
79
for (VPackValueLength i = 0 ; i < actualSize; ++i) {
81
- lhs = actualSlice.at (i).getNumber <decltype (lhs)>();
82
- rhs = expectedSlice.at (i).getNumber <decltype (rhs)>();
83
- ASSERT_DOUBLE_EQ (lhs, rhs);
80
+ double actual = actualSlice.at (i).getNumber <double >();
81
+ double expected = expectedSlice.at (i).getNumber <double >();
82
+ EXPECT_DOUBLE_EQ (expected, actual)
83
+ << " index: " << i << " ; args: " << args;
84
84
}
85
85
} else {
86
- double lhs = actualSlice.getNumber <decltype (lhs) >();
87
- double rhs = expectedSlice.getNumber <decltype (rhs) >();
88
- ASSERT_DOUBLE_EQ (lhs, rhs) ;
86
+ double actual = actualSlice.getNumber <double >();
87
+ double expected = expectedSlice.getNumber <double >();
88
+ EXPECT_DOUBLE_EQ (expected, actual) << " args: " << args ;
89
89
}
90
90
91
91
return ;
@@ -135,7 +135,7 @@ void assertDecayFunction(char const* expected, char const* args,
135
135
auto actual_value = evaluateDecayFunction (params, node);
136
136
137
137
// check equality
138
- expectEqSlices (actual_value.slice (), expectedSlice);
138
+ expectEqSlices (actual_value.slice (), expectedSlice, args );
139
139
140
140
// destroy AqlValues
141
141
for (auto & p : params) {
@@ -174,6 +174,26 @@ TEST(GaussDecayFunctionTest, test) {
174
174
assertDecayFunction (" 1.0" , " [40, 40, 5, 5, 0.5]" , node);
175
175
assertDecayFunction (" 1.0" , " [49.987, 49.987, 0.001, 0.001, 0.2]" , node);
176
176
177
+ // expecting <decay>
178
+ assertDecayFunction (" 0.7" , " [50, 40, 5, 5, 0.7]" , node);
179
+ assertDecayFunction (" 0.7" , " [50, 40, 6, 4, 0.7]" , node);
180
+ assertDecayFunction (" 0.7" , " [50, 40, 4, 6, 0.7]" , node);
181
+ assertDecayFunction (" 0.7" , " [50, 40, 7, 3, 0.7]" , node);
182
+ assertDecayFunction (" 0.7" , " [50, 40, 3, 7, 0.7]" , node);
183
+ assertDecayFunction (" 0.7" , " [46, 40, 5, 1, 0.7]" , node);
184
+ assertDecayFunction (" 0.7" , " [46, 40, 1, 5, 0.7]" , node);
185
+ assertDecayFunction (" 0.7" , " [34, 40, 5, 1, 0.7]" , node);
186
+ assertDecayFunction (" 0.7" , " [34, 40, 1, 5, 0.7]" , node);
187
+ assertDecayFunction (" 0.5" , " [10, 0, 5, 5, 0.5]" , node);
188
+ assertDecayFunction (" 0.5" , " [-10, 0, 5, 5, 0.5]" , node);
189
+ assertDecayFunction (" 0.4" , " [-5, 0, 4, 1, 0.4]" , node);
190
+ assertDecayFunction (" 0.4" , " [5, 0, 1, 4, 0.4]" , node);
191
+ assertDecayFunction (" 0.4" , " [-5, 0, 4, 1, 0.4]" , node);
192
+ assertDecayFunction (" 0.4" , " [5, 0, 1, 4, 0.4]" , node);
193
+ assertDecayFunction (" 0.2" , " [2.5, 2.0, 0.25, 0.25, 0.2]" , node);
194
+ assertDecayFunction (" 0.2" , " [2.5, 2.0, 0.4, 0.1, 0.2]" , node);
195
+ assertDecayFunction (" 0.20000000000000023" , " [2.5, 2.0, 0.1, 0.4, 0.2]" , node);
196
+
177
197
// test range input
178
198
assertDecayFunction (
179
199
" [0.5, 0.6417129487814521, 0.7791645796604999, 0.8950250709279725, "
@@ -224,6 +244,26 @@ TEST(ExpDecayFunctionTest, test) {
224
244
assertDecayFunction (" 1.0" , " [40, 40, 5, 5, 0.5]" , node);
225
245
assertDecayFunction (" 1.0" , " [49.987, 49.987, 0.001, 0.001, 0.2]" , node);
226
246
247
+ // expecting <decay>
248
+ assertDecayFunction (" 0.7" , " [50, 40, 5, 5, 0.7]" , node);
249
+ assertDecayFunction (" 0.7" , " [50, 40, 6, 4, 0.7]" , node);
250
+ assertDecayFunction (" 0.7" , " [50, 40, 4, 6, 0.7]" , node);
251
+ assertDecayFunction (" 0.7" , " [50, 40, 7, 3, 0.7]" , node);
252
+ assertDecayFunction (" 0.7" , " [50, 40, 3, 7, 0.7]" , node);
253
+ assertDecayFunction (" 0.7" , " [46, 40, 5, 1, 0.7]" , node);
254
+ assertDecayFunction (" 0.7" , " [46, 40, 1, 5, 0.7]" , node);
255
+ assertDecayFunction (" 0.7" , " [34, 40, 5, 1, 0.7]" , node);
256
+ assertDecayFunction (" 0.7" , " [34, 40, 1, 5, 0.7]" , node);
257
+ assertDecayFunction (" 0.5" , " [10, 0, 5, 5, 0.5]" , node);
258
+ assertDecayFunction (" 0.5" , " [-10, 0, 5, 5, 0.5]" , node);
259
+ assertDecayFunction (" 0.4" , " [-5, 0, 4, 1, 0.4]" , node);
260
+ assertDecayFunction (" 0.4" , " [5, 0, 1, 4, 0.4]" , node);
261
+ assertDecayFunction (" 0.4" , " [-5, 0, 4, 1, 0.4]" , node);
262
+ assertDecayFunction (" 0.4" , " [5, 0, 1, 4, 0.4]" , node);
263
+ assertDecayFunction (" 0.2" , " [2.5, 2.0, 0.25, 0.25, 0.2]" , node);
264
+ assertDecayFunction (" 0.2" , " [2.5, 2.0, 0.4, 0.1, 0.2]" , node);
265
+ assertDecayFunction (" 0.2" , " [2.5, 2.0, 0.1, 0.4, 0.2]" , node);
266
+
227
267
// with offset=0
228
268
assertDecayFunction (" 0.8513399225207846" , " [1, 0, 10, 0, 0.2]" , node);
229
269
assertDecayFunction (" 0.7247796636776955" , " [2, 0, 10, 0, 0.2]" , node);
@@ -270,6 +310,26 @@ TEST(LinDecayFunctionTest, test) {
270
310
assertDecayFunction (" 1.0" , " [40, 40, 5, 5, 0.5]" , node);
271
311
assertDecayFunction (" 1.0" , " [49.987, 49.987, 0.001, 0.001, 0.2]" , node);
272
312
313
+ // expecting <decay>
314
+ assertDecayFunction (" 0.7" , " [50, 40, 5, 5, 0.7]" , node);
315
+ assertDecayFunction (" 0.7" , " [50, 40, 6, 4, 0.7]" , node);
316
+ assertDecayFunction (" 0.7" , " [50, 40, 4, 6, 0.7]" , node);
317
+ assertDecayFunction (" 0.7" , " [50, 40, 7, 3, 0.7]" , node);
318
+ assertDecayFunction (" 0.7" , " [50, 40, 3, 7, 0.7]" , node);
319
+ assertDecayFunction (" 0.7" , " [46, 40, 5, 1, 0.7]" , node);
320
+ assertDecayFunction (" 0.7" , " [46, 40, 1, 5, 0.7]" , node);
321
+ assertDecayFunction (" 0.7" , " [34, 40, 5, 1, 0.7]" , node);
322
+ assertDecayFunction (" 0.7" , " [34, 40, 1, 5, 0.7]" , node);
323
+ assertDecayFunction (" 0.5" , " [10, 0, 5, 5, 0.5]" , node);
324
+ assertDecayFunction (" 0.5" , " [-10, 0, 5, 5, 0.5]" , node);
325
+ assertDecayFunction (" 0.4" , " [-5, 0, 4, 1, 0.4]" , node);
326
+ assertDecayFunction (" 0.4" , " [5, 0, 1, 4, 0.4]" , node);
327
+ assertDecayFunction (" 0.4" , " [-5, 0, 4, 1, 0.4]" , node);
328
+ assertDecayFunction (" 0.4" , " [5, 0, 1, 4, 0.4]" , node);
329
+ assertDecayFunction (" 0.2" , " [2.5, 2.0, 0.25, 0.25, 0.2]" , node);
330
+ assertDecayFunction (" 0.2" , " [2.5, 2.0, 0.4, 0.1, 0.2]" , node);
331
+ assertDecayFunction (" 0.20000000000000018" , " [2.5, 2.0, 0.1, 0.4, 0.2]" , node);
332
+
273
333
// with offset=0
274
334
assertDecayFunction (" 0.92" , " [1, 0, 10, 0, 0.2]" , node);
275
335
assertDecayFunction (" 0.84" , " [2, 0, 10, 0, 0.2]" , node);
0 commit comments