/*

accumulator test

             CREATOR: DAn williams
                DATE:
         DESCRIPTION: test the viewport class
            FILENAME: fileaccumtest.cpp
             STARTED: jan 22
    OPERATING SYSTEM: Linux
1st VERSION FINISHED:

This code tests the functions of an accumulator

  char * DataEnd()
  long   GetSize( void );
  int    ReSize( long newSize);
  long   Insert( long position, long size);
  long   Remove( long position, long size);

*/


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

void Error( char * desc );

#include "accumulator2.h"
#include <string.h>

//global variables

int main(int argc, char** argv)
{

  Accumulator    buffer;
  char           foo[20];
  long           fool;
  
  printf("The origional size reports as: %d\n", buffer.GetSize());

  
  printf("Writing \"hello\" from char 0, result code:");
  printf(" %d \n", buffer.SetN(0, 0, "hello\0", 6));

  printf("Size reports as: %d\n", buffer.GetSize());


  printf("Reading 6 characters from char 0, result code: ");
  printf("%d \n", buffer.ReadN(0, foo, 6));
  printf("With string: %s\n", foo);


  printf("Writing \"world\" from char 0, result code: ");
  printf("%d \n", buffer.SetN(3, 0, "world", 5));    

  printf("Size reports as: %d\n", buffer.GetSize());

  fool = buffer.ReadN(0, foo, 11);
  printf("Reading 11 characters from char 0, result code: %d \n", fool );
  printf("With string: %s\n", foo);


  // those were all sane checks, here are the evil ones >:-}
  // ok, just the semi-evil ones...

  printf("Writing \"12345\" from char 20, result code: ");
  printf("%d \n", buffer.SetN(20, 0, "12345", 5));    

  printf("Size reports as: %d\n", buffer.GetSize());

  fool = buffer.ReadN(0, foo, 11);
  printf("Reading 11 characters from char 0, result code: %d \n", fool );
  printf("With string: %s\n", foo);


  printf("Writing \"67890\" from char 8, result code: ");
  printf("%d \n", buffer.SetN(8, 50, "67890", 5));    

  printf("Size reports as: %d\n", buffer.GetSize());

  fool = buffer.ReadN(0, foo, 13);
  foo[fool] = '\0';
  printf("Reading 13 characters from char 0, result code: %d \n", fool );
  printf("With string: %s\n", foo);
  
  printf("Done testing accumulator2\n");
    
  return ( 0 );
}


//subroutines


void Error( char * desc ){
  printf ("%s\n", desc);
  exit ( 0 );
}

