From 558a4bf56187597c69155e6049eed5d3bd92cccf Mon Sep 17 00:00:00 2001 From: leo Date: Thu, 9 Feb 2023 22:04:47 +0100 Subject: [PATCH] cec2020: add benchFunctions_test.go --- bench/cec2020/benchFunctions_test.go | 50 ++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 bench/cec2020/benchFunctions_test.go diff --git a/bench/cec2020/benchFunctions_test.go b/bench/cec2020/benchFunctions_test.go new file mode 100644 index 0000000..2f474e5 --- /dev/null +++ b/bench/cec2020/benchFunctions_test.go @@ -0,0 +1,50 @@ +// Copyright 2023 wanderer +// SPDX-License-Identifier: GPL-3.0-or-later + +package cec2020 + +import "testing" + +func TestComposition1(t *testing.T) { + in := []float64{-9.2, 10, .7, 3, -80.2843} + want := 7248.007126969505 + + got := Composition1(in) + + if got != want { + t.Errorf("unexpected result from Composition1, want: %f, got: %v", want, got) + } +} + +func TestComposition2(t *testing.T) { + in := []float64{-9.2, 10, .7, 3, -80.2843} + want := 2.0384259701506793e+08 + + got := Composition2(in) + + if got != want { + t.Errorf("unexpected result from Composition2, want: %f, got: %v", want, got) + } +} + +func TestComposition3(t *testing.T) { + in := []float64{-9.2, 10, .7, 3, -80.2843} + want := 8.699499674241544e+07 + + got := Composition3(in) + + if got != want { + t.Errorf("unexpected result from Composition3, want: %f, got: %v", want, got) + } +} + +func TestGriewank(t *testing.T) { + in := []float64{-9.2, 10, .7, 3, -80.2843} + want := 2.6599247066225002 + + got := Griewank(in) + + if got != want { + t.Errorf("unexpected result from Griewank, want: %f, got: %v", want, got) + } +}