#ifndef TEST_H
#define TEST_H

#include "utils/Logger.h"
#include "utils/StringBuffer.h"

class Test final {
    static constexpr const char* RED = "\033[0;31m";
    static constexpr const char* GREEN = "\033[0;32m";
    static constexpr const char* RESET = "\033[0m";

    int tests;
    int successTests;
    const char* name;

public:
    Test(const char* name);
    void finalize();

    template<typename T>
    void checkEqual(const T& wanted, const T& actual, const char* text) {
        if(wanted == actual) {
            tests++;
            successTests++;
        } else {
            tests++;
            LOG_ERROR(StringBuffer<256>(name)
                          .append(" Test ")
                          .append(tests)
                          .append(": ")
                          .append(text)
                          .append(" - expected '")
                          .append(wanted)
                          .append("' got '")
                          .append(actual)
                          .append("'"));
        }
    }

    void checkFloat(float wanted, float actual, float error, const char* text);
};

#endif