#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>

#include "tester.h"

static int fillArray(int32_t V[], int32_t size) {
    int32_t i, isq, odd ;
    i = 0 ;
    isq = 0 ;
    odd = 1 ;
    while (i<size) {
        V[i] = isq ;
        i = i + 1 ;
        isq = isq + odd ;
        odd = odd + 2 ;
    }
    return isq ;
}

void testArrayFunctions(
        int32_t (*f1)(int32_t *, int32_t),
        int32_t (*f2)(int32_t *, int32_t),
        int32_t size) {
    int32_t a1[SIZE] ;
    int32_t a2[SIZE] ;
    int32_t rc1 ;
    int32_t rc2 ;
    int i ;
    int worked = 1 ;
    (void) fillArray(a1, size) ;
    (void) fillArray(a2, size) ;
    rc1 = f1(a1, size) ;
    rc2 = f2(a2, size) ;
    for (i=0; i<size; ++i) {
        if (a1[i] != a2[i]) {
            printf("Disagree at %3d: %10d != %10d\n", i, a1[i], a2[i]) ;
            worked = 0 ;
        }
    }
    if (rc1 != rc2) {
        printf("Disagree at ret: %10d != %10d\n", rc1, rc2) ;
        worked = 0 ;
    }
    if (worked) {
        puts("Perfect!") ;
    }

}
