home *** CD-ROM | disk | FTP | other *** search
/ Dream 41 / Amiga_Dream_41.iso / Amiga / Programmation / c / gcc / objam02.lha / objam / test / objamTest.m < prev    next >
Encoding:
Text File  |  1995-04-16  |  2.4 KB  |  100 lines

  1. #include <stdio.h>
  2.  
  3. #import <objam/FlatList.h>
  4. #import <objam/ExecList.h>
  5. #import <objam/FileList.h>
  6. #import "FooObject.h"
  7.  
  8.  
  9. void testflatlist(void)
  10. {
  11.   id myList,foo1,foo2,foo3,foo4,foo5;
  12.  
  13.   foo1=[[FooObject new] setFoo:100];
  14.   foo2=[[FooObject new] setFoo:2000];
  15.   foo3=[[FooObject new] setFoo:3];
  16.   foo4=[[FooObject new] setFoo:444];
  17.   foo5=[[FooObject new] setFoo:505];
  18.  
  19.   if(myList=[FlatList new])
  20.   {
  21.     [myList addObject:foo1];
  22.     [myList addObject:foo2];
  23.     [myList addObject:foo3];
  24.     [myList addObject:foo4];
  25.     [myList addObject:foo5];
  26.     [myList makeObjectsPerform:@selector(printFoo)];
  27.     if(!([myList storeOn:"ram:myFlatList.tds"])) puts("Error storing FlatList object.");
  28.     [myList freeObjects];
  29.     [myList free];
  30.  
  31.     if( myList = [FlatList readFrom:"ram:myFlatList.tds"] )
  32.     {
  33.       puts("Contents of read list:");
  34.       [myList makeObjectsPerform:@selector(printFoo)];
  35.       [myList free];
  36.     }
  37.     else puts("Error loading FlatList object.");
  38.   }
  39.   else puts("Error creating FlatList object.");
  40.   return;
  41. }
  42.  
  43.  
  44. void testexeclist(void)
  45. {
  46.   id myList;
  47.   struct Node *node;
  48.  
  49.   if(myList=[ExecList new])
  50.   {
  51.     printf("Number of elements in list: %d\n",[myList count]);
  52.     [myList addNodeNamed:"foo"];
  53.     [myList addNodeNamed:"bar"];
  54.     printf("Number of elements in list: %d\n",[myList count]);
  55.     for(node=[myList execList]->lh_Head;node->ln_Succ;node=node->ln_Succ) printf("Line: %s\n",node->ln_Name);
  56.     if(!([myList storeOn:"ram:myExecList.tds"])) puts("Error storing ExecList object.");
  57.     [myList free];
  58.  
  59.     if( myList = [ExecList readFrom:"ram:myExecList.tds"] )
  60.     {
  61.       printf("Number of elements in list: %d\n",[myList count]);
  62.       for(node=[myList execList]->lh_Head;node->ln_Succ;node=node->ln_Succ)
  63.     printf("Line: %s\n",node->ln_Name);
  64.       [myList free];
  65.     }
  66.     else puts("Error loading ExecList object.");
  67.   }
  68.   else puts("Error creating ExecList object.");
  69.   return;
  70. }
  71.  
  72.  
  73. void testfilelist(void)
  74. {
  75.   id myList;
  76.   struct Node *node;
  77.  
  78.   if(myList=[FileList new])
  79.   {
  80.     if([myList addDirectory:"env:"])
  81.     {
  82.       for(node=[myList execList]->lh_Head;node->ln_Succ;node=node->ln_Succ)
  83.     printf("Line: %s\n",node->ln_Name);
  84.       [myList free];
  85.     }
  86.     else puts("Error adding 'env:' to FileList object.");
  87.   }
  88.   else puts("Error creating FileList object.");
  89.   return;
  90. }
  91.  
  92.  
  93. int main(void)
  94. {
  95.   testflatlist();
  96.   testexeclist();
  97.   testfilelist();
  98.   return 0;
  99. }
  100.