home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 390.lha / LibExample / test.c < prev    next >
Encoding:
C/C++ Source or Header  |  1990-06-02  |  668 b   |  40 lines

  1.  
  2. /*
  3.  *  Test the library
  4.  */
  5.  
  6. long TestBase;
  7.  
  8. extern long OpenLibrary();
  9. extern void *AllocMem();
  10. extern long Add(), Sub();
  11.  
  12. main(ac,av)
  13. char *av[];
  14. {
  15.     if (ac != 1) {
  16.     register long i = 256000;
  17.     register char *ptr;
  18.     puts("Expunging by allocating too much memory");
  19.     while (ptr = AllocMem(i,0)) {
  20.         FreeMem(ptr,i);
  21.         i <<= 1;
  22.     }
  23.     puts("ok");
  24.     exit(1);
  25.     }
  26.  
  27.     TestBase = OpenLibrary("testlib.library",0);
  28.     if (TestBase) {
  29.     printf("Open OK %08xl\n", TestBase);
  30.     printf("ADD 1 -> %ld (should be 2)\n", Add(1L));
  31.     printf("SUB 33-> %ld (should be 32)\n", Sub(33L));
  32.     CloseLibrary(TestBase);
  33.     puts("Close OK");
  34.     } else {
  35.     puts("Unable to Open");
  36.     }
  37. }
  38.  
  39.  
  40.