/*
File:        util-test.cpp
Description: This is a C++ source file containing  unit tests for util.cpp.
Rev:         0.1
Created:     01.04.26
Author:      Uwe Jakobeit
Copyright:   Binder GmbH
Purpose:     Testing utility functions
Notes:       [Any relevant details, such as dependencies, usage examples, or known issues.]
*/


#include <gtest/gtest.h>

#include <limits>

#include "util.h"

using namespace UTILITY_FUNCTIONS;

//----------- Test of utility function 'max3' ---------
// Magic numbers for simplicity ( exceptionally allowed here )

// test if param 3 is max value
TEST(UtilityTest_max3, param_3_is_max) {
    double max = max3(1.0f, 2.0f, 3.0f);
    EXPECT_DOUBLE_EQ(max, 3.0f);
}

// test if param 2 is max value
TEST(UtilityTest_max3, param_2_is_max) {
    double max = max3(1.0f, 3.0f, 2.0f);
    EXPECT_DOUBLE_EQ(max, 3.0f);
}

// test if param 1 is max value
TEST(UtilityTest_max3, param_1_is_max) {
    double max = max3( 3.0f, 1.0f, 2.0f);
    EXPECT_DOUBLE_EQ(max, 3.0f);
}

// test all params are max value
TEST(UtilityTest_max3, all_params_equal) {
    double max = max3( 3.0f, 3.0f, 3.0f);
    EXPECT_DOUBLE_EQ(max, 3.0f);
}

// test all params are zero
TEST(UtilityTest_max3, all_params_zero) {
    double max = max3( 0.0f, 0.0f, 0.0f);
    EXPECT_DOUBLE_EQ(max, 0.0f);
}

// test 2 params negatve, one is zero
TEST(UtilityTest_max3, 2_params_negative_one_is_zero) {
    double max = max3( -2.0f, -1.0f, 0.0f);
    EXPECT_DOUBLE_EQ(max, 0.0f);
}

// test 2 params negatve, one is zero
TEST(UtilityTest_max3, all_params_negative_one_is_max) {
    double max = max3( -2.0f, -1.0f, -3.0f);
    EXPECT_DOUBLE_EQ(max, -1.0f);
}


TEST(UtilityTest_max3, all_params_type_double) {
    double max = max3( std::numeric_limits<double>::max(), 0.0f, 0.0f);

    EXPECT_DOUBLE_EQ(max, std::numeric_limits<double>::max());
}



