/*
 * 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()
{
    _EXECUTECODE_CODESTR_NL1( eCxx::Ext::SharedPtr<eCxx::uint8_t> dv1( new eCxx::uint8_t(11) ); );
    _CODESTR_NL1_CODERES_NL2( "%zd", (eCxx::ssize_t) *dv1 );

    _EXECUTECODE_CODESTR_NL1( eCxx::Ext::SharedPtr<eCxx::uint8_t> dv2( new eCxx::uint8_t(12) ); );
    _CODESTR_NL1_CODERES_NL2( "%zd", (eCxx::ssize_t) *dv2 );

    _EXECUTECODE_CODESTR_NL1( eCxx::Ext::SharedPtr<eCxx::int32_t> mv1 = eCxx::Ext::makeSharedPtr<eCxx::int32_t>(-321); );
    _CODESTR_NL1_CODERES_NL2( "%zd", (eCxx::ssize_t) *mv1 );

    _EXECUTECODE_CODESTR_NL1( eCxx::Ext::SharedPtr<eCxx::int32_t> mv2 = eCxx::Ext::makeSharedPtr<eCxx::int32_t>(-322); );
    _CODESTR_NL1_CODERES_NL2( "%zd", (eCxx::ssize_t) *mv2 );

    _DIVIDERLINE_DASHSTR_NL2();



    _EXECUTECODE_CODESTR_NL1( eCxx::Ext::SharedPtr<eCxx::uint8_t> dv01( new eCxx::uint8_t(75) ); );
    _CODESTR_NL1_CODERES_NL2( "%zd [%p]", (eCxx::ssize_t) *dv01, dv01.get() );

    _EXECUTECODE_CODESTR_NL1( eCxx::Ext::SharedPtr<eCxx::uint8_t> dv02( new eCxx::uint8_t(85) ); );
    _CODESTR_NL1_CODERES_NL2( "%zd [%p]", (eCxx::ssize_t) *dv02, dv02.get() );

    _EXECUTECODE_CODESTR_NL1( dv02 = dv01; );
    _CODESTR_NL1_CODERES_NL1( "%zd [%p]", (eCxx::ssize_t) *dv01, dv01.get() );
    _CODESTR_NL1_CODERES_NL2( "%zd [%p]", (eCxx::ssize_t) *dv02, dv02.get() );

    _EXECUTECODE_CODESTR_NL1( dv02 = eCxx::move(dv01); );
    _CODESTR_NL1_CODERES_NL1( "[%p]", dv01.get() );
    _CODESTR_NL1_CODERES_NL2( "[%p]", dv02.get() );

    _EXECUTECODE_CODESTR_NL1( eCxx::Ext::SharedPtr<eCxx::uint8_t> dv03( eCxx::move(dv02) ); );
    _CODESTR_NL1_CODERES_NL1( "[%p]", dv01.get() );
    _CODESTR_NL1_CODERES_NL1( "[%p]", dv02.get() );
    _CODESTR_NL1_CODERES_NL2( "[%p]", dv03.get() );

    _DIVIDERLINE_DASHSTR_NL2();



    _EXECUTECODE_CODESTR_NL1( eCxx::Ext::SharedPtr<eCxx::uint8_t> dv11 = dv1; );
    _EXECUTECODE_CODESTR_NL1( eCxx::Ext::SharedPtr<eCxx::uint8_t> dv12 = dv1; );
    _CODESTR_NL1_CODERES_NL1( "%zd", (eCxx::ssize_t) *dv11 );
    _CODESTR_NL1_CODERES_NL2( "%zd", (eCxx::ssize_t) *dv12 );

    _EXECUTECODE_CODESTR_NL1( dv1 = nullptr; );
    _CODESTR_NL1_CODERES_NL1( "%zd [%p]", (eCxx::ssize_t) *dv11, dv11.get() );
    _CODESTR_NL1_CODERES_NL2( "%zd [%p]", (eCxx::ssize_t) *dv12, dv12.get() );

    _EXECUTECODE_CODESTR_NL1( dv11 = nullptr; );
    _EXECUTECODE_CODESTR_NL1( dv12 = nullptr; );
    _CODESTR_NL1_CODERES_NL1( "[%p]", dv1 .get() );
    _CODESTR_NL1_CODERES_NL1( "[%p]", dv11.get() );
    _CODESTR_NL1_CODERES_NL2( "[%p]", dv12.get() );

    _DIVIDERLINE_DASHSTR_NL2();



    _CODESTR_NL1_CODERES_NL1( "%zd [%p]", (eCxx::ssize_t) *mv1, mv1.get() );
    _CODESTR_NL1_CODERES_NL2( "%zd [%p]", (eCxx::ssize_t) *mv2, mv2.get() );

    _EXECUTECODE_CODESTR_NL1( mv1 = mv2; );
    _CODESTR_NL1_CODERES_NL1( "%zd [%p]", (eCxx::ssize_t) *mv1, mv1.get() );
    _CODESTR_NL1_CODERES_NL2( "%zd [%p]", (eCxx::ssize_t) *mv2, mv2.get() );

    _EXECUTECODE_CODESTR_NL1( mv1 = nullptr; );
    _EXECUTECODE_CODESTR_NL1( mv2 = nullptr; );
    _CODESTR_NL1_CODERES_NL1( "[%p]", mv1 .get() );
    _CODESTR_NL1_CODERES_NL2( "[%p]", mv2 .get() );

    _DIVIDERLINE_DASHSTR_NL2();



    _EXECUTECODE_CODESTR_NL1( eCxx::Ext::SharedPtr<eCxx::uint32_t[]> dva1 = new eCxx::uint32_t[3]; );
    _CODESTR_NL1_CODERES_NL1( "[%p]", dva1.get() );
    _EXECUTECODE_CODESTR_NL1( dva1[0] = 10000; dva1[1] = 10001; dva1[2] = 10002; );
    _CODESTR_NL1_CODERES_NL1( "%zd", (eCxx::ssize_t) dva1[0] );
    _CODESTR_NL1_CODERES_NL1( "%zd", (eCxx::ssize_t) dva1[1] );
    _CODESTR_NL1_CODERES_NL2( "%zd", (eCxx::ssize_t) dva1[2] );

    _EXECUTECODE_CODESTR_NL1( eCxx::Ext::SharedPtr<eCxx::uint32_t[]> dva2 = dva1; );
    _EXECUTECODE_CODESTR_NL1( dva1 = nullptr; );
    _CODESTR_NL1_CODERES_NL1( "[%p]", dva1.get() );
    _CODESTR_NL1_CODERES_NL1( "[%p]", dva2.get() );
    _CODESTR_NL1_CODERES_NL1( "%zd", (eCxx::ssize_t) dva2[0] );
    _CODESTR_NL1_CODERES_NL1( "%zd", (eCxx::ssize_t) dva2[1] );
    _CODESTR_NL1_CODERES_NL2( "%zd", (eCxx::ssize_t) dva2[2] );

    _DIVIDERLINE_DASHSTR_NL2();



    _EXECUTECODE_CODESTR_NL1( eCxx::Ext::SharedPtr<eCxx::uint32_t[]> mva1 = eCxx::Ext::makeSharedPtr<eCxx::uint32_t, 3>(); );
    _EXECUTECODE_CODESTR_NL1( mva1[0] = 100000; mva1[1] = 100001; mva1[2] = 100002; );
    _CODESTR_NL1_CODERES_NL1( "%zd", (eCxx::ssize_t) mva1[0] );
    _CODESTR_NL1_CODERES_NL1( "%zd", (eCxx::ssize_t) mva1[1] );
    _CODESTR_NL1_CODERES_NL2( "%zd", (eCxx::ssize_t) mva1[2] );

    _EXECUTECODE_CODESTR_NL1( eCxx::Ext::SharedPtr<eCxx::uint32_t[]> mva2 = eCxx::Ext::makeSharedPtr<eCxx::uint32_t, 3>(200000, 200001, 200002); );
    _CODESTR_NL1_CODERES_NL1( "%zd", (eCxx::ssize_t) mva2[0] );
    _CODESTR_NL1_CODERES_NL1( "%zd", (eCxx::ssize_t) mva2[1] );
    _CODESTR_NL1_CODERES_NL2( "%zd", (eCxx::ssize_t) mva2[2] );



    return 0;
}
