#include "../Utils.cpp"
/* enter to make: g++ utilsTest.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 = 13;
    bool testresults[testAmount];
    for(int i = 0; i < testAmount; i++){
        testresults[i] = false;
    }
    // Test 1 median() Test
    int array[] = {42,23,4,15,16,8,16,108};
    testresults[0] = (Utils::median(4,108,array,8) == 16)? true : false;

    // Test 2 hammingWeight() Test
    testresults[1] = (Utils::hammingWeight(42) == 3)? true : false;
    testresults[2] = (Utils::hammingWeight(23) == 4)? true : false;
    testresults[3] = (Utils::hammingWeight(0) == 0)? true : false;

    // Test 3 hamming_distance() Test
    testresults[4] = (Utils::hamming_distance(42, 42) == 0)? true : false;
    testresults[5] = (Utils::hamming_distance(42, 0) == 3)? true : false;
    testresults[6] = (Utils::hamming_distance(42, 23) == 5)? true : false;

    // Test 4 mean() Test
    testresults[7] = (Utils::mean(array, 8) == 29)? true : false;
    
    // Test 5 unsignificantBitCount() Test
    testresults[8] = (Utils::unsignificantBitCount(0,32) == 32)? true : false;
    testresults[9] = (Utils::unsignificantBitCount(256,32) == 23)? true : false;
    testresults[10] = (Utils::unsignificantBitCount(INT_MAX,32) == 1)? true : false;

    // Test 6 standardDeviation() Test
    double devResult = Utils::standardDeviation(array, 8);
    cout << devResult << endl;
    testresults[11] = (devResult- 31.713561767799 > -0.0001 && devResult- 31.713561767799 < 0.0001)? true : false;
    testresults[12] = (Utils::standardDeviation(0,0) == 0)? true : false;

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



}
