#include <stdio.h>
#include "math.h"
//#include "test.h"

static int failures = 0;
static int successes = 0;

void check(int expected, int actual, char *msg) {
  fprintf(stderr, "Checking '%s': ", msg);
  if (expected!=actual) {
    fprintf(stderr,
            " failed, Expected: %d  Got: %d\n",
            expected, actual);
    failures++; }
  else {
    printf ("OK\n");
    successes++; }
}

void test_mean_value(){
  int mean;

  int p[]  = { 12, 13, 14 };
  int p1[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9 };
  /* int p2[] = { 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 };  */
  
  mean = mean_value(p, 3);
  check(13, mean, "mean_value");
  
  mean = mean_value(p1, 9);
  check(5, mean, "mean_value");
  
  /*  mean = mean_value(p2, 100);
  CHECK(2, mean, "mean_value");
  */
  
  return ;
}

int main() {

  test_mean_value();

  printf ("Tests:       %d\n", failures+successes);
  printf ("Successes:   %d\n", successes);
  printf ("Failures:    %d\n", failures);

  return failures;  
}
