/*
 * Copyright (C) 2020-2021 Aloysius Indrayanto
 *
 * This file is part of the eCxx library, see LICENSE file for the license details.
 */


#include "TestUtility.h"


//
// Test application
//
int main()
{
    eCxx::NumPunct::setGrouping(3);
    eCxx::NumPunct::setThousandsSeparator('.');
    eCxx::NumPunct::setDecimalPoint(',');
    eCxx::NumPunct::setTrueName("benar");
    eCxx::NumPunct::setFalseName("salah");



    eCxx::String<48> str48(PGM_STR("Hello World !"));
    _CODESTR_NL1_CODERES_NL2("%s", str48.cStr());

    eCxx::Convert::toUppercase(str48);
    _CODESTR_NL1_CODERES_NL2("%s", str48.cStr());

    eCxx::Convert::toLowercase(str48);
    _CODESTR_NL1_CODERES_NL2("%s", str48.cStr());

    eCxx::Convert::reverseCharacters(str48);
    _CODESTR_NL1_CODERES_NL2("%s", str48.cStr());

    eCxx::Convert::reverseCharacters(str48);
    _CODESTR_NL1_CODERES_NL2("%s", str48.cStr());

    _DIVIDERLINE_DASHSTR_NL2();



    eCxx::int16_t  negNum16 = -21567;
    eCxx::uint16_t posNum16 =  65535;

    eCxx::Convert::toDecString(
        str48, negNum16, eCxx::Convert::NumSign::Plus_Minus, str48.capacity(), eCxx::Convert::NumPad::Space, false
    );
    _CODESTR_NL1_CODERES_NL2("|%s|", str48.cStr());

    eCxx::Convert::toDecString(
        str48, posNum16, eCxx::Convert::NumSign::Plus_Minus, str48.capacity(), eCxx::Convert::NumPad::Space, false
    );
    _CODESTR_NL1_CODERES_NL2("|%s|", str48.cStr());

    eCxx::Convert::toDecString(
        str48, negNum16, eCxx::Convert::NumSign::Plus_Minus, str48.capacity(), eCxx::Convert::NumPad::Zero, false
    );
    _CODESTR_NL1_CODERES_NL2("|%s|", str48.cStr());

    eCxx::Convert::toDecString(
        str48, posNum16, eCxx::Convert::NumSign::Plus_Minus, str48.capacity(), eCxx::Convert::NumPad::Zero, false
    );
    _CODESTR_NL1_CODERES_NL2("|%s|", str48.cStr());

    eCxx::Convert::toDecString(
        str48, negNum16, eCxx::Convert::NumSign::Plus_Minus, str48.capacity(), eCxx::Convert::NumPad::Space, true
    );
    _CODESTR_NL1_CODERES_NL2("|%s|", str48.cStr());

    eCxx::Convert::toDecString(
        str48, posNum16, eCxx::Convert::NumSign::Plus_Minus, str48.capacity(), eCxx::Convert::NumPad::Space, true
    );
    _CODESTR_NL1_CODERES_NL2("|%s|", str48.cStr());

    eCxx::Convert::toDecString(
        str48, negNum16, eCxx::Convert::NumSign::Plus_Minus, str48.capacity(), eCxx::Convert::NumPad::Zero, true
    );
    _CODESTR_NL1_CODERES_NL2("|%s|", str48.cStr());

    eCxx::Convert::toDecString(
        str48, posNum16, eCxx::Convert::NumSign::Plus_Minus, str48.capacity(), eCxx::Convert::NumPad::Zero, true
    );
    _CODESTR_NL1_CODERES_NL2("|%s|", str48.cStr());

    negNum16 = -123;
    posNum16 = 3845;

    eCxx::Convert::toDecString(
        str48, negNum16, eCxx::Convert::NumSign::Plus_Minus, str48.capacity(), eCxx::Convert::NumPad::Space, true
    );
    _CODESTR_NL1_CODERES_NL2("|%s|", str48.cStr());

    eCxx::Convert::toDecString(
        str48, posNum16, eCxx::Convert::NumSign::Plus_Minus, str48.capacity(), eCxx::Convert::NumPad::Space, true
    );
    _CODESTR_NL1_CODERES_NL2("|%s|", str48.cStr());

    _DIVIDERLINE_DASHSTR_NL2();



    eCxx::int32_t  negNum32 = -2147483648;
    eCxx::uint32_t posNum32 =  4294967295;

    eCxx::Convert::toDecString(
        str48, negNum32, eCxx::Convert::NumSign::None_Minus, str48.capacity(), eCxx::Convert::NumPad::Space, true
    );
    _CODESTR_NL1_CODERES_NL2("|%s|", str48.cStr());

    eCxx::Convert::toDecString(
        str48, posNum32, eCxx::Convert::NumSign::Space_Minus, str48.capacity(), eCxx::Convert::NumPad::Space, true
    );
    _CODESTR_NL1_CODERES_NL2("|%s|", str48.cStr());

    eCxx::Convert::toDecString(
        str48, negNum32, eCxx::Convert::NumSign::None_Minus, str48.capacity(), eCxx::Convert::NumPad::Zero, true
    );
    _CODESTR_NL1_CODERES_NL2("|%s|", str48.cStr());

    eCxx::Convert::toDecString(
        str48, posNum32, eCxx::Convert::NumSign::Space_Minus, str48.capacity(), eCxx::Convert::NumPad::Zero, true
    );
    _CODESTR_NL1_CODERES_NL2("|%s|", str48.cStr());

    _DIVIDERLINE_DASHSTR_NL2();



    eCxx::Convert::toBinString(
        str48, negNum16, eCxx::Convert::NumSign::Plus_Minus, str48.capacity(), eCxx::Convert::NumPad::Space, eCxx::Convert::NumFormat::LowercaseWithPrefix
    );
    _CODESTR_NL1_CODERES_NL2("|%s|", str48.cStr());

    eCxx::Convert::toBinString(
        str48, posNum16, eCxx::Convert::NumSign::Plus_Minus, str48.capacity(), eCxx::Convert::NumPad::Space, eCxx::Convert::NumFormat::LowercaseWithPrefix
    );
    _CODESTR_NL1_CODERES_NL2("|%s|", str48.cStr());

    eCxx::Convert::toBinString(
        str48, negNum16, eCxx::Convert::NumSign::Plus_Minus, str48.capacity(), eCxx::Convert::NumPad::Zero, eCxx::Convert::NumFormat::UppercaseWithPrefix
    );
    _CODESTR_NL1_CODERES_NL2("|%s|", str48.cStr());

    eCxx::Convert::toBinString(
        str48, posNum16, eCxx::Convert::NumSign::Plus_Minus, str48.capacity(), eCxx::Convert::NumPad::Zero, eCxx::Convert::NumFormat::UppercaseWithPrefix
    );
    _CODESTR_NL1_CODERES_NL2("|%s|", str48.cStr());

    _DIVIDERLINE_DASHSTR_NL2();



    eCxx::Convert::toBinString(
        str48, negNum32, eCxx::Convert::NumSign::None_Minus, str48.capacity(), eCxx::Convert::NumPad::Space, eCxx::Convert::NumFormat::UppercaseWithPrefix
    );
    _CODESTR_NL1_CODERES_NL2("|%s|", str48.cStr());

    eCxx::Convert::toBinString(
        str48, posNum32, eCxx::Convert::NumSign::Space_Minus, str48.capacity(), eCxx::Convert::NumPad::Space, eCxx::Convert::NumFormat::UppercaseWithPrefix
    );
    _CODESTR_NL1_CODERES_NL2("|%s|", str48.cStr());

    eCxx::Convert::toBinString(
        str48, negNum32, eCxx::Convert::NumSign::None_Minus, str48.capacity(), eCxx::Convert::NumPad::Zero, eCxx::Convert::NumFormat::LowercaseWithPrefix
    );
    _CODESTR_NL1_CODERES_NL2("|%s|", str48.cStr());

    eCxx::Convert::toBinString(
        str48, posNum32, eCxx::Convert::NumSign::Space_Minus, str48.capacity(), eCxx::Convert::NumPad::Zero, eCxx::Convert::NumFormat::LowercaseWithPrefix
    );
    _CODESTR_NL1_CODERES_NL2("|%s|", str48.cStr());

    _DIVIDERLINE_DASHSTR_NL2();



    eCxx::Convert::toOctString(
        str48, negNum16, eCxx::Convert::NumSign::Plus_Minus, str48.capacity(), eCxx::Convert::NumPad::Space, eCxx::Convert::NumFormat::LowercaseWithPrefix
    );
    _CODESTR_NL1_CODERES_NL2("|%s|", str48.cStr());

    eCxx::Convert::toOctString(
        str48, posNum16, eCxx::Convert::NumSign::Plus_Minus, str48.capacity(), eCxx::Convert::NumPad::Space, eCxx::Convert::NumFormat::LowercaseWithPrefix
    );
    _CODESTR_NL1_CODERES_NL2("|%s|", str48.cStr());

    eCxx::Convert::toOctString(
        str48, negNum32, eCxx::Convert::NumSign::None_Minus, str48.capacity(), eCxx::Convert::NumPad::Zero, eCxx::Convert::NumFormat::LowercaseWithPrefix
    );
    _CODESTR_NL1_CODERES_NL2("|%s|", str48.cStr());

    eCxx::Convert::toOctString(
        str48, posNum32, eCxx::Convert::NumSign::Space_Minus, str48.capacity(), eCxx::Convert::NumPad::Zero, eCxx::Convert::NumFormat::LowercaseWithPrefix
    );
    _CODESTR_NL1_CODERES_NL2("|%s|", str48.cStr());

    _DIVIDERLINE_DASHSTR_NL2();



    eCxx::Convert::toHexString(
        str48, negNum16, eCxx::Convert::NumSign::Plus_Minus, str48.capacity(), eCxx::Convert::NumPad::Space, eCxx::Convert::NumFormat::LowercaseWithPrefix
    );
    _CODESTR_NL1_CODERES_NL2("|%s|", str48.cStr());

    eCxx::Convert::toHexString(
        str48, posNum16, eCxx::Convert::NumSign::Plus_Minus, str48.capacity(), eCxx::Convert::NumPad::Space, eCxx::Convert::NumFormat::LowercaseWithPrefix
    );
    _CODESTR_NL1_CODERES_NL2("|%s|", str48.cStr());

    eCxx::Convert::toHexString(
        str48, negNum16, eCxx::Convert::NumSign::Plus_Minus, str48.capacity(), eCxx::Convert::NumPad::Zero, eCxx::Convert::NumFormat::UppercaseWithPrefix
    );
    _CODESTR_NL1_CODERES_NL2("|%s|", str48.cStr());

    eCxx::Convert::toHexString(
        str48, posNum16, eCxx::Convert::NumSign::Plus_Minus, str48.capacity(), eCxx::Convert::NumPad::Zero, eCxx::Convert::NumFormat::UppercaseWithPrefix
    );
    _CODESTR_NL1_CODERES_NL2("|%s|", str48.cStr());

    _DIVIDERLINE_DASHSTR_NL2();



    eCxx::Convert::toHexString(
        str48, negNum32, eCxx::Convert::NumSign::None_Minus, str48.capacity(), eCxx::Convert::NumPad::Space, eCxx::Convert::NumFormat::UppercaseWithPrefix
    );
    _CODESTR_NL1_CODERES_NL2("|%s|", str48.cStr());

    eCxx::Convert::toHexString(
        str48, posNum32, eCxx::Convert::NumSign::Space_Minus, str48.capacity(), eCxx::Convert::NumPad::Space, eCxx::Convert::NumFormat::UppercaseWithPrefix
    );
    _CODESTR_NL1_CODERES_NL2("|%s|", str48.cStr());

    eCxx::Convert::toHexString(
        str48, negNum32, eCxx::Convert::NumSign::None_Minus, str48.capacity(), eCxx::Convert::NumPad::Zero, eCxx::Convert::NumFormat::LowercaseWithPrefix
    );
    _CODESTR_NL1_CODERES_NL2("|%s|", str48.cStr());

    eCxx::Convert::toHexString(
        str48, posNum32, eCxx::Convert::NumSign::Space_Minus, str48.capacity(), eCxx::Convert::NumPad::Zero, eCxx::Convert::NumFormat::LowercaseWithPrefix
    );
    _CODESTR_NL1_CODERES_NL2("|%s|", str48.cStr());

    _DIVIDERLINE_DASHSTR_NL2();



    eCxx::FixedPoint fpPos = eCxx::FixedPoint::L_POSITIVE;
    eCxx::FixedPoint fpNeg = eCxx::FixedPoint::L_NEGATIVE;

    eCxx::Convert::toDecString(
        str48, fpNeg, eCxx::Convert::NumSign::None_Minus, str48.capacity(), eCxx::Convert::NumPad::Space, true
    );
    _CODESTR_NL1_CODERES_NL2("|%s|", str48.cStr());

    eCxx::Convert::toDecString(
        str48, fpPos, eCxx::Convert::NumSign::None_Minus, str48.capacity(), eCxx::Convert::NumPad::Space, true
    );
    _CODESTR_NL1_CODERES_NL2("|%s|", str48.cStr());

    eCxx::Convert::toDecString(
        str48, fpNeg, eCxx::Convert::NumSign::None_Minus, str48.capacity(), eCxx::Convert::NumPad::Zero, false
    );
    _CODESTR_NL1_CODERES_NL2("|%s|", str48.cStr());

    eCxx::Convert::toDecString(
        str48, fpPos, eCxx::Convert::NumSign::None_Minus, str48.capacity(), eCxx::Convert::NumPad::Zero, false
    );
    _CODESTR_NL1_CODERES_NL2("|%s|", str48.cStr());

    fpPos = 0.01_fp;
    eCxx::Convert::toDecString(
        str48, fpPos, eCxx::Convert::NumSign::None_Minus, str48.capacity(), eCxx::Convert::NumPad::Zero, true
    );
    _CODESTR_NL1_CODERES_NL2("|%s|", str48.cStr());

    fpPos = 0.21_fp;
    eCxx::Convert::toDecString(
        str48, fpPos, eCxx::Convert::NumSign::None_Minus, str48.capacity(), eCxx::Convert::NumPad::Zero, true
    );
    _CODESTR_NL1_CODERES_NL2("|%s|", str48.cStr());

    _DIVIDERLINE_DASHSTR_NL2();



    eCxx::NumPunct::setThousandsSeparator(',');
    eCxx::NumPunct::setDecimalPoint('.');

    eCxx::Convert::toDecString( // Error = 28.31541%
        str48, eCxx::FixedPoint(0.31_fp) * eCxx::FixedPoint(0.09_fp), eCxx::Convert::NumSign::None_Minus, str48.capacity(), eCxx::Convert::NumPad::Zero, true
    );
    _CODESTR_NL1_CODERES_NL2("|%s|", str48.cStr());

    eCxx::Convert::toDecString( // Error = 1.82328%
        str48, eCxx::FixedPoint(0.31_fp) * eCxx::FixedPoint(0.92_fp), eCxx::Convert::NumSign::None_Minus, str48.capacity(), eCxx::Convert::NumPad::Zero, true
    );
    _CODESTR_NL1_CODERES_NL2("|%s|", str48.cStr());

    eCxx::Convert::toDecString( // Error = 0.12344%
        str48, eCxx::FixedPoint(3.17_fp) * eCxx::FixedPoint(0.92_fp), eCxx::Convert::NumSign::None_Minus, str48.capacity(), eCxx::Convert::NumPad::Zero, true
    );
    _CODESTR_NL1_CODERES_NL2("|%s|", str48.cStr());

    eCxx::Convert::toDecString( // Error = 0.01018%
        str48, eCxx::FixedPoint(31.75_fp) * eCxx::FixedPoint(9.28_fp), eCxx::Convert::NumSign::None_Minus, str48.capacity(), eCxx::Convert::NumPad::Zero, true
    );
    _CODESTR_NL1_CODERES_NL2("|%s|", str48.cStr());

    eCxx::Convert::toDecString( // Error = 0.00081%
        str48, eCxx::FixedPoint(317.50_fp) * eCxx::FixedPoint(92.8_fp), eCxx::Convert::NumSign::None_Minus, str48.capacity(), eCxx::Convert::NumPad::Zero, true
    );
    _CODESTR_NL1_CODERES_NL2("|%s|", str48.cStr());



    return 0;
}
