/*
 * 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::RingBuffer<eCxx::int8_t, 4> rb;

    _CODESTR_NL1_CODERES_NL2( "%d", (int) rb.full()  );
    _CODESTR_NL1_CODERES_NL2( "%d", (int) rb.empty() );

    _CODESTR_NL1_CODERES_NL2( "%d", (int) rb.put(3)  );
    _CODESTR_NL1_CODERES_NL2( "%d", (int) rb.put(2)  );
    _CODESTR_NL1_CODERES_NL2( "%d", (int) rb.put(8)  );
    _CODESTR_NL1_CODERES_NL2( "%d", (int) rb.put(7)  );

    _CODESTR_NL1_CODERES_NL2( "%d", (int) rb.full()  );
    _CODESTR_NL1_CODERES_NL2( "%d", (int) rb.empty() );

    _CODESTR_NL1_CODERES_NL2( "%d", (int) rb.put(9)  );

    _DIVIDERLINE_DASHSTR_NL2();



    eCxx::int8_t t = 0;

    _CODESTR_NL1_CODERES_NL2( "%d", (int) rb.size()  );
    _CODESTR_NL1_CODERES_NL0( "%d", (int) rb.peek(t) ); _____________CODERES_NL2(" => t = %d", t);
    _CODESTR_NL1_CODERES_NL2( "%d", (int) rb.size()  );

    _CODESTR_NL1_CODERES_NL0( "%d", (int) rb.get(t)  ); _____________CODERES_NL2(" => t = %d", t);
    _CODESTR_NL1_CODERES_NL0( "%d", (int) rb.get(t)  ); _____________CODERES_NL2(" => t = %d", t);
    _CODESTR_NL1_CODERES_NL0( "%d", (int) rb.get(t)  ); _____________CODERES_NL2(" => t = %d", t);
    _CODESTR_NL1_CODERES_NL0( "%d", (int) rb.get(t)  ); _____________CODERES_NL2(" => t = %d", t);

    _CODESTR_NL1_CODERES_NL2( "%d", (int) rb.full()  );
    _CODESTR_NL1_CODERES_NL2( "%d", (int) rb.empty() );

    _CODESTR_NL1_CODERES_NL0( "%d", (int) rb.get(t)  ); _____________CODERES_NL2(" => t = %d", t);

    _DIVIDERLINE_DASHSTR_NL2();



    _CODESTR_NL1_CODERES_NL2( "%d", (int) rb.put(3)  );
    _CODESTR_NL1_CODERES_NL2( "%d", (int) rb.put(2)  );
    _CODESTR_NL1_CODERES_NL2( "%d", (int) rb.put(8)  );
    _CODESTR_NL1_CODERES_NL2( "%d", (int) rb.put(7)  );
    _CODESTR_NL1_CODERES_NL2( "%d", (int) rb.put(9)  );

    _CODESTR_NL1_CODERES_NL2( "%d", (int) rb.full()  );
    _CODESTR_NL1_CODERES_NL2( "%d", (int) rb.empty() );

    _EXECUTECODE_CODESTR_NL2( rb.clear(); );

    _CODESTR_NL1_CODERES_NL2( "%d", (int) rb.full()  );
    _CODESTR_NL1_CODERES_NL2( "%d", (int) rb.empty() );

    _DIVIDERLINE_DASHSTR_NL2();



    _CODESTR_NL1_CODERES_NL1( "%d", (int) rb.put(3)  );
    _CODESTR_NL1_CODERES_NL1( "%d", (int) rb.put(2)  );
    _CODESTR_NL1_CODERES_NL1( "%d", (int) rb.peekMatchLastN<3>( eCxx::makeArray<eCxx::int8_t, 2, 8, 7>() ) );
    _CODESTR_NL1_CODERES_NL1( "%d", (int) rb.put(8)  );
    _CODESTR_NL1_CODERES_NL1( "%d", (int) rb.put(7)  );
    _CODESTR_NL1_CODERES_NL1( "%d", (int) rb.peekMatchLastN<3>( eCxx::makeArray<eCxx::int8_t, 2, 8, 7>() ) );
    _EXECUTECODE_CODESTR_NL1( rb.clear();            );
    _CODESTR_NL1_CODERES_NL2( "%d", (int) rb.peekMatchLastN<3>( eCxx::makeArray<eCxx::int8_t, 2, 8, 7>() ) );

    _CODESTR_NL1_CODERES_NL1( "%d", (int) rb.put(1)  );
    _CODESTR_NL1_CODERES_NL1( "%d", (int) rb.put(1)  );
    _CODESTR_NL1_CODERES_NL1( "%d", (int) rb.put(1)  );
    _CODESTR_NL1_CODERES_NL1( "%d", (int) rb.get(t)  );
    _CODESTR_NL1_CODERES_NL1( "%d", (int) rb.get(t)  );
    _CODESTR_NL1_CODERES_NL1( "%d", (int) rb.peekMatchLastN<3>( eCxx::makeArray<eCxx::int8_t, 2, 8, 7>() ) );
    _CODESTR_NL1_CODERES_NL1( "%d", (int) rb.put(2)  );
    _CODESTR_NL1_CODERES_NL1( "%d", (int) rb.put(8)  );
    _CODESTR_NL1_CODERES_NL1( "%d", (int) rb.put(7)  );
    _CODESTR_NL1_CODERES_NL1( "%d", (int) rb.peekMatchLastN<3>( eCxx::makeArray<eCxx::int8_t, 2, 8, 7>() ) );
    _EXECUTECODE_CODESTR_NL1( rb.clear();            );
    _CODESTR_NL1_CODERES_NL2( "%d", (int) rb.peekMatchLastN<3>( eCxx::makeArray<eCxx::int8_t, 2, 8, 7>() ) );

    _CODESTR_NL1_CODERES_NL1( "%d", (int) rb.put(1)  );
    _CODESTR_NL1_CODERES_NL1( "%d", (int) rb.put(1)  );
    _CODESTR_NL1_CODERES_NL1( "%d", (int) rb.put(1)  );
    _CODESTR_NL1_CODERES_NL1( "%d", (int) rb.put(2)  );
    _CODESTR_NL1_CODERES_NL1( "%d", (int) rb.get(t)  );
    _CODESTR_NL1_CODERES_NL1( "%d", (int) rb.get(t)  );
    _CODESTR_NL1_CODERES_NL1( "%d", (int) rb.peekMatchLastN<3>( eCxx::makeArray<eCxx::int8_t, 2, 8, 7>() ) );
    _CODESTR_NL1_CODERES_NL1( "%d", (int) rb.put(8)  );
    _CODESTR_NL1_CODERES_NL1( "%d", (int) rb.put(7)  );
    _CODESTR_NL1_CODERES_NL1( "%d", (int) rb.peekMatchLastN<3>( eCxx::makeArray<eCxx::int8_t, 2, 8, 7>() ) );
    _EXECUTECODE_CODESTR_NL1( rb.clear();            );
    _CODESTR_NL1_CODERES_NL2( "%d", (int) rb.peekMatchLastN<3>( eCxx::makeArray<eCxx::int8_t, 2, 8, 7>() ) );

    return 0;
}
