#ifndef TYPES_TEST_HXX
#define TYPES_TEST_HXX

#include "libbinom/include/binom_impl/types.hxx"
#include "test/tester.hxx"

using namespace binom;

void testTypesConversions() {
  RAIIPerfomanceTest test_perf("Type conversion test: ");
  SEPARATOR
  TEST_ANNOUNCE(Test types conversions)
  GRP(
    LOG("Variable type to variable type class")
    GRP(
      TEST(toTypeClass(VarType::null) == VarTypeClass::null)
      TEST(toTypeClass(VarType::boolean) == VarTypeClass::number)
      TEST(toTypeClass(VarType::ui8) == VarTypeClass::number)
      TEST(toTypeClass(VarType::si8) == VarTypeClass::number)
      TEST(toTypeClass(VarType::ui16) == VarTypeClass::number)
      TEST(toTypeClass(VarType::si16) == VarTypeClass::number)
      TEST(toTypeClass(VarType::ui32) == VarTypeClass::number)
      TEST(toTypeClass(VarType::si32) == VarTypeClass::number)
      TEST(toTypeClass(VarType::f32) == VarTypeClass::number)
      TEST(toTypeClass(VarType::ui64) == VarTypeClass::number)
      TEST(toTypeClass(VarType::si64) == VarTypeClass::number)
      TEST(toTypeClass(VarType::f64) == VarTypeClass::number)
      TEST(toTypeClass(VarType::ui8_array) == VarTypeClass::buffer_array)
      TEST(toTypeClass(VarType::si8_array) == VarTypeClass::buffer_array)
      TEST(toTypeClass(VarType::ui16_array) == VarTypeClass::buffer_array)
      TEST(toTypeClass(VarType::si16_array) == VarTypeClass::buffer_array)
      TEST(toTypeClass(VarType::ui32_array) == VarTypeClass::buffer_array)
      TEST(toTypeClass(VarType::si32_array) == VarTypeClass::buffer_array)
      TEST(toTypeClass(VarType::f32_array) == VarTypeClass::buffer_array)
      TEST(toTypeClass(VarType::ui64_array) == VarTypeClass::buffer_array)
      TEST(toTypeClass(VarType::si64_array) == VarTypeClass::buffer_array)
      TEST(toTypeClass(VarType::f64_array) == VarTypeClass::buffer_array)
      TEST(toTypeClass(VarType::array) == VarTypeClass::array)
      TEST(toTypeClass(VarType::map) == VarTypeClass::map)
      TEST(toTypeClass(VarType::separator) == VarTypeClass::invalid_type)
      TEST(toTypeClass(VarType::invalid_type) == VarTypeClass::invalid_type)
    )
    LOG("Variable type bit width")
    GRP(
      TEST(toBitWidth(VarType::boolean) == VarBitWidth::byte)
      TEST(toBitWidth(VarType::ui8) == VarBitWidth::byte)
      TEST(toBitWidth(VarType::si8) == VarBitWidth::byte)
      TEST(toBitWidth(VarType::ui8_array) == VarBitWidth::byte)
      TEST(toBitWidth(VarType::si8_array) == VarBitWidth::byte)
      TEST(toBitWidth(VarType::ui16) == VarBitWidth::word)
      TEST(toBitWidth(VarType::si16) == VarBitWidth::word)
      TEST(toBitWidth(VarType::ui16_array) == VarBitWidth::word)
      TEST(toBitWidth(VarType::si16_array) == VarBitWidth::word)
      TEST(toBitWidth(VarType::ui32) == VarBitWidth::dword)
      TEST(toBitWidth(VarType::si32) == VarBitWidth::dword)
      TEST(toBitWidth(VarType::f32) == VarBitWidth::dword)
      TEST(toBitWidth(VarType::ui32_array) == VarBitWidth::dword)
      TEST(toBitWidth(VarType::si32_array) == VarBitWidth::dword)
      TEST(toBitWidth(VarType::f32_array) == VarBitWidth::dword)
      TEST(toBitWidth(VarType::ui64) == VarBitWidth::qword)
      TEST(toBitWidth(VarType::si64) == VarBitWidth::qword)
      TEST(toBitWidth(VarType::f64) == VarBitWidth::qword)
      TEST(toBitWidth(VarType::ui64_array) == VarBitWidth::qword)
      TEST(toBitWidth(VarType::si64_array) == VarBitWidth::qword)
      TEST(toBitWidth(VarType::f64_array) == VarBitWidth::qword)
    )
    LOG("Value type bit width")
    GRP(
      TEST(toBitWidth(ValType::boolean) == VarBitWidth::byte)
      TEST(toBitWidth(ValType::ui8) == VarBitWidth::byte)
      TEST(toBitWidth(ValType::si8) == VarBitWidth::byte)
      TEST(toBitWidth(ValType::ui16) == VarBitWidth::word)
      TEST(toBitWidth(ValType::si16) == VarBitWidth::word)
      TEST(toBitWidth(ValType::ui32) == VarBitWidth::dword)
      TEST(toBitWidth(ValType::si32) == VarBitWidth::dword)
      TEST(toBitWidth(ValType::f32) == VarBitWidth::dword)
      TEST(toBitWidth(ValType::ui64) == VarBitWidth::qword)
      TEST(toBitWidth(ValType::si64) == VarBitWidth::qword)
      TEST(toBitWidth(ValType::f64) == VarBitWidth::qword)
    )
    LOG("Variable type to number type")
    GRP(
      TEST(toNumberType(VarType::boolean) == VarNumberType::unsigned_integer)
      TEST(toNumberType(VarType::ui8) == VarNumberType::unsigned_integer)
      TEST(toNumberType(VarType::si8) == VarNumberType::signed_integer)
      TEST(toNumberType(VarType::ui8_array) == VarNumberType::unsigned_integer)
      TEST(toNumberType(VarType::si8_array) == VarNumberType::signed_integer)
      TEST(toNumberType(VarType::ui16) == VarNumberType::unsigned_integer)
      TEST(toNumberType(VarType::si16) == VarNumberType::signed_integer)
      TEST(toNumberType(VarType::ui16_array) == VarNumberType::unsigned_integer)
      TEST(toNumberType(VarType::si16_array) == VarNumberType::signed_integer)
      TEST(toNumberType(VarType::ui32) == VarNumberType::unsigned_integer)
      TEST(toNumberType(VarType::si32) == VarNumberType::signed_integer)
      TEST(toNumberType(VarType::f32) == VarNumberType::float_point)
      TEST(toNumberType(VarType::ui32_array) == VarNumberType::unsigned_integer)
      TEST(toNumberType(VarType::si32_array) == VarNumberType::signed_integer)
      TEST(toNumberType(VarType::f32_array) == VarNumberType::float_point)
      TEST(toNumberType(VarType::ui64) == VarNumberType::unsigned_integer)
      TEST(toNumberType(VarType::si64) == VarNumberType::signed_integer)
      TEST(toNumberType(VarType::f64) == VarNumberType::float_point)
      TEST(toNumberType(VarType::ui64_array) == VarNumberType::unsigned_integer)
      TEST(toNumberType(VarType::si64_array) == VarNumberType::signed_integer)
      TEST(toNumberType(VarType::f64_array) == VarNumberType::float_point)
    )
    LOG("Value type to number type")
    GRP(
      TEST(toNumberType(ValType::boolean) == VarNumberType::unsigned_integer)
      TEST(toNumberType(ValType::ui8) == VarNumberType::unsigned_integer)
      TEST(toNumberType(ValType::si8) == VarNumberType::signed_integer)
      TEST(toNumberType(ValType::ui16) == VarNumberType::unsigned_integer)
      TEST(toNumberType(ValType::si16) == VarNumberType::signed_integer)
      TEST(toNumberType(ValType::ui32) == VarNumberType::unsigned_integer)
      TEST(toNumberType(ValType::si32) == VarNumberType::signed_integer)
      TEST(toNumberType(ValType::f32) == VarNumberType::float_point)
      TEST(toNumberType(ValType::ui64) == VarNumberType::unsigned_integer)
      TEST(toNumberType(ValType::si64) == VarNumberType::signed_integer)
      TEST(toNumberType(ValType::f64) == VarNumberType::float_point)
    )
  )
}

#endif // TYPES_TEST_HXX
