diff options
author | Håvard Pettersen <havardpe@yahooinc.com> | 2022-05-25 14:54:09 +0000 |
---|---|---|
committer | Håvard Pettersen <havardpe@yahooinc.com> | 2022-05-25 14:55:00 +0000 |
commit | 4f657a53503ef52c57de618087ebc6f8a22d0130 (patch) | |
tree | 29993d615dde4c9a22837e920bd9e491c7da01e4 /eval/src/tests | |
parent | 5912287f8d1cb92e484d7f7578dbe18900fd8147 (diff) |
fix undefined behavior in eval unit tests
Diffstat (limited to 'eval/src/tests')
-rw-r--r-- | eval/src/tests/eval/compile_cache/compile_cache_test.cpp | 4 | ||||
-rw-r--r-- | eval/src/tests/eval/compiled_function/compiled_function_test.cpp | 2 | ||||
-rw-r--r-- | eval/src/tests/eval/gbdt/gbdt_test.cpp | 2 |
3 files changed, 4 insertions, 4 deletions
diff --git a/eval/src/tests/eval/compile_cache/compile_cache_test.cpp b/eval/src/tests/eval/compile_cache/compile_cache_test.cpp index c9d56de897c..2688dc7b4f5 100644 --- a/eval/src/tests/eval/compile_cache/compile_cache_test.cpp +++ b/eval/src/tests/eval/compile_cache/compile_cache_test.cpp @@ -270,9 +270,9 @@ struct CompileCheck : test::EvalSpec::EvalTest { for (const Entry &entry: list) { auto fun = entry.fun->get().get_function(); if (std::isnan(entry.expect)) { - EXPECT_TRUE(std::isnan(fun(&entry.params[0]))); + EXPECT_TRUE(std::isnan(fun(entry.params.data()))); } else { - EXPECT_EQUAL(fun(&entry.params[0]), entry.expect); + EXPECT_EQUAL(fun(entry.params.data()), entry.expect); } } } diff --git a/eval/src/tests/eval/compiled_function/compiled_function_test.cpp b/eval/src/tests/eval/compiled_function/compiled_function_test.cpp index 45e0c6d08fc..1d612826ab2 100644 --- a/eval/src/tests/eval/compiled_function/compiled_function_test.cpp +++ b/eval/src/tests/eval/compiled_function/compiled_function_test.cpp @@ -108,7 +108,7 @@ struct MyEvalTest : test::EvalSpec::EvalTest { CompiledFunction cfun(*function, PassParams::ARRAY); auto fun = cfun.get_function(); ASSERT_EQUAL(cfun.num_params(), param_values.size()); - double result = fun(¶m_values[0]); + double result = fun(param_values.data()); if (is_same(expected_result, result)) { print_pass && fprintf(stderr, "verifying: %s -> %g ... PASS\n", as_string(param_names, param_values, expression).c_str(), diff --git a/eval/src/tests/eval/gbdt/gbdt_test.cpp b/eval/src/tests/eval/gbdt/gbdt_test.cpp index 09d4a081ac4..582bb484f0e 100644 --- a/eval/src/tests/eval/gbdt/gbdt_test.cpp +++ b/eval/src/tests/eval/gbdt/gbdt_test.cpp @@ -188,7 +188,7 @@ struct DummyForest2 : public Forest { size_t num_trees; explicit DummyForest2(size_t num_trees_in) : num_trees(num_trees_in) {} static double eval(const Forest *forest, const double *) { - const DummyForest1 &self = *((const DummyForest1 *)forest); + const DummyForest2 &self = *((const DummyForest2 *)forest); return double(self.num_trees); } static Optimize::Result optimize(const ForestStats &stats, |