#include <lnv3/lnv3.h>


#include "validate.h"
#include "funcList.h"


bool
ValidateAnd( const string& operation )
{
    if( operation != "and" ) return false;

    ln A, B, C, test;
    cin >> A >> B >> C;

    test = A & B;
    CheckForError( test, C, "operator&" );

    test = A;
    A &= B;
    CheckForError( A, C, "operator&=" );

    return true;
}


//  ============================================================


bool
ValidateOr( const string& operation )
{
    if( operation != "or" ) return false;

    ln A, B, C, test;
    cin >> A >> B >> C;

    test = A | B;
    CheckForError( test, C, "operator|" );

    test = A;
    A |= B;
    CheckForError( A, C, "operator|=" );

    return true;
}


//  ============================================================


bool
ValidateXor( const string& operation )
{
    if( operation != "xor" ) return false;

    ln A, B, C, test;
    cin >> A >> B >> C;

    test = A ^ B;
    CheckForError( test, C, "operator^" );

    test = A;
    A ^= B;
    CheckForError( A, C, "operator^=" );

    return true;
}


//  ============================================================


bool
ValidateNot( const string& operation )
{
    if( operation != "not" ) return false;

    ln A, B, test;
    cin >> A >> B;

    test = ~A;
    if( CheckForError( test, B, "operator~" ) )
    {
        cout << "A = " << hex << A << endl;
        cout << "B = " << hex << B << endl;
        cout << "test = " << hex << test << endl;
    }

    test = A;
    A.Not( );
    CheckForError( A, B, "method Not( )" );

    return true;
}


//  ============================================================


static TestFunctionList RegFunc1( ValidateAnd );
static TestFunctionList RegFunc2( ValidateOr );
static TestFunctionList RegFunc3( ValidateXor );
static TestFunctionList RegFunc4( ValidateNot );