#include "../RessourceHandler.cpp"
/* enter to make: g++ ressourceHandlerTest.cpp -I /usr/local/systemc-2.3.3/include -L /usr/local/systemc-2.3.3/lib-linux64 -o  main -lsystemc */
int sc_main(int argc, char* argv[])
{
    int testAmount = 6;
    bool testresults[testAmount];
    for(int i = 0; i < testAmount; i++){
        testresults[i] = false;
    }
    /* Test 1 - addModel() Test
    01011100
    00111010
    11110000
    ------
    10010110
    */
    testresults[0] = (RessourceHandler::getInstance()->addModel(92,58,false) == 11)? true : false;
    
    /* Test 2  subModel() Test
    11000110
    01101100
    11110000
    ------
    01011010
    */
     testresults[1] = (RessourceHandler::getInstance()->subModel(198,108,false) == 11)? true : false;
    
    /* Test 3 mulModel() Test
    1010 * 101 = 110010
             0
          1010
          ----
          1010

        001010
        101000
        ------  
        110010   
    */
    testresults[2] = (RessourceHandler::getInstance()->mulModel(10,5) == 12)? true : false;
    /* Test 4 modModel() Test
     11010 % 101 = 1
    -10100
     -----
     00110
    -00101
     -----
     00001
    */
    testresults[3] = (RessourceHandler::getInstance()->modModel(26,5) == 7+6+1)? true : false;

    // Test 5 Trace Difference and Sum Test
    map<int,int> one, two;

    one[1] = 10;
    one[5] = 4;
    two[0] = 3;
    two[5] = 6;
    two[6] = 1;
    testresults[4] = (RessourceHandler::getInstance()->traceSum(RessourceHandler::getInstance()->traceDifference(one,two)) == 16)? true : false;

    // Test 6 Trace Variance Test
    two[2] = -3;
    two[8] = -6;
    two[9] = 0;
    testresults[5] = (RessourceHandler::getInstance()->traceVariance(two) == 9.1)? true : false;

    for(int i = 0; i < testAmount; i++){
        if(testresults[i]){
            cout << "Test " << i+1 << " successful" << endl;
        }else{
             cout << "Test " << i+1 << " failed" << endl;
        }
    }
    return 0;



}
