292 {
294
296 "Invalid test case, up to 3 roots allowed");
297
298 for (
size_t i = 0; i < expectedRoots.
size(); i++) {
299 double x = expectedRoots[i];
301 "Invalid test case root %zu. Roots must be in [0, 1]", i);
302
303
306 "Invalid test case root %zu. %.16f != 0", i,
y);
307
308 if (i > 0) {
310 "Invalid test case root %zu. Roots should be sorted in ascending order", i);
311 }
312 }
313
314 {
316 double roots[3] = {0, 0, 0};
319 "Wrong number of roots returned %zu != %d",
320 expectedRoots.
size(), rootCount);
321
322
323
324 std::sort(std::begin(roots), std::begin(roots) + rootCount);
325 for (int i = 0; i < rootCount; i++) {
328 "0 != %.16f at index %d", roots[i], i);
329 } else {
332 "%.16f != %.16f at index %d", expectedRoots[i], roots[i], i);
333 }
334 }
335 }
336 {
338 double roots[3] = {0, 0, 0};
341 "Wrong number of roots returned %zu != %d",
342 expectedRoots.
size(), rootCount);
343
344
345
346 std::sort(std::begin(roots), std::begin(roots) + rootCount);
347 for (int i = 0; i < rootCount; i++) {
350 "0 != %.16f at index %d", roots[i], i);
351 } else {
354 "%.16f != %.16f at index %d", expectedRoots[i], roots[i], i);
355 }
356 }
357 }
358 {
360 double roots[3] = {0, 0, 0};
363 "Wrong number of roots returned %zu != %d", expectedRoots.
size(),
364 rootCount);
365
366
367
368 std::sort(std::begin(roots), std::begin(roots) + rootCount);
369 for (int i = 0; i < rootCount; i++) {
370 double delta = std::abs(roots[i] - expectedRoots[i]);
372
373
374 delta < 0.000001,
375 "%.16f != %.16f at index %d", expectedRoots[i], roots[i], i);
376 }
377 }
378}
static int BinarySearchRootsValidT(double A, double B, double C, double D, double solution[3])
static int RootsValidT(double A, double B, double C, double D, double solution[3])