/* divtest.c (emx+gcc) */

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

static int result;

void div_test (int num, int den, int xquot, int xrem)
{
  div_t q;

  q = div (num, den);
  if (q.quot != xquot || q.rem != xrem)
    {
      printf ("ERROR: num=%d den=%d: quot=%d rem=%d\n",
              num, den, q.quot, q.rem);
      result = 1;
    }
}


int main (void)
{
  result = 0;
  div_test ( 0,  2,  0,  0);
  div_test ( 0, -2,  0,  0);
  div_test ( 5,  2,  2,  1);
  div_test ( 5, -2, -2,  1);
  div_test (-5,  2, -2, -1);
  div_test (-5, -2,  2, -1);
  return result;
}
