#include <catch2/catch.hpp>
#include <iostream>

#include "../utils.hpp"
#include "utils_test.hpp"

#define print(x) PRINT_VAR(x);
#define printvec(x) PRINT_VEC(x);
#define printstr(x) PRINT_STR(x);

TEST_CASE( "Test case 1", "[test1]" )
{
    std::cout.precision(16);

    SECTION( "Check almost equal" ) {
        CHECK(check_almost_equal(1.00, 1.01, 0.1));
        CHECK(check_almost_equal(1.00, 3.01, 0.01));
        CHECK(check_almost_equal(1.00, 1.01, 0.001));
        REQUIRE(true);
    }

    SECTION( "Check almost equal on vectors" ) {
        unsigned int N = 5;
        std::vector<double> v1(N), v2(N);
        for (size_t i = 0; i < N; i++) {
            v1[i] = double(i);
            v2[i] = v1[i] + 0.0001;
        }

        CHECK(check_almost_equalV(v1, v2, 0.001));
        CHECK(check_almost_equalV(v1, v2, 0.0001));
        CHECK(check_almost_equalV(v1, v2, 0.00001));
    }
}
