Advertisement
DanFloyd

VoidList - some tests

Mar 15th, 2014
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.39 KB | None | 0 0
  1. /* Here it is a main test for voidlist library */
  2.  
  3. #include <stdio.h>
  4. #include <stdlib.h>
  5. #include <string.h>
  6. #include "voidlist.h"
  7.  
  8. int main(){
  9.    
  10.     printf("=======================================\n");
  11.     printf("=============== TESTING ===============\n");
  12.     printf("=======================================\n");
  13.     list_t *int_Test, *string_Test;
  14.     int *a, *b, *c;
  15.     char *s1, *s2, *s3;
  16.     printf("Setting up the environment...\n");
  17.    
  18.     //creating a new list of int
  19.     int_Test = create_int_list();
  20.     printf("A new list of int has been created...\n");
  21.    
  22.     //creating a new list of strings
  23.     string_Test = create_string_list();
  24.     printf("A new list of strings has been created...\n\n");
  25.  
  26.     //test 1a : trying to print an empty list
  27.     printf("=============== TEST 1A ===============\n");
  28.     printf("trying to print an empty list of int...\n");
  29.     printf("expected a warning msg :\n");
  30.     printList(int_Test);
  31.     printf("================= END =================\n\n");
  32.  
  33.     //inserting elements 1,5,9 into int_Test
  34.     a = (int*) malloc(sizeof(int));
  35.     *a = 1;
  36.     b = (int*) malloc(sizeof(int));
  37.     *b = 5;
  38.     c = (int*) malloc(sizeof(int));
  39.     *c = 9;
  40.     insert_inList(int_Test,a);
  41.     insert_inList(int_Test,c);
  42.     insert_inList(int_Test,b);
  43.     printf("Elements : 1, 5, 9 has been inserted...\n\n");
  44.  
  45.     //test 2a : print the list
  46.     printf("=============== TEST 2A ===============\n");
  47.     printf("trying to print a list of int...\n");
  48.     printf("expected msg : 1 -> 5-> 9-># end of list\n");
  49.     printList(int_Test);
  50.     printf("================= END =================\n\n");
  51.  
  52.     //extracting element 5 from int_Test
  53.     extract_fromList(int_Test,b);
  54.     printf("Elements : 5 has been extracted\n\n");
  55.  
  56.     //test 3a : print the list
  57.     //test 2a : print the list
  58.     printf("=============== TEST 3A ===============\n");
  59.     printf("trying to print a list of int...\n");
  60.     printf("expected msg : 1 -> 9-># end of list\n");
  61.     printList(int_Test);
  62.     printf("================= END =================\n\n");
  63.  
  64.     //test 1b : trying to print an empty list
  65.     printf("=============== TEST 1B ===============\n");
  66.     printf("trying to print an empty list of strings...\n");
  67.     printf("expected a warning msg :\n");
  68.     printList(string_Test);
  69.     printf("================= END =================\n\n");
  70.    
  71.     printf("=======================================\n");
  72.     printf("=============== @@@@@@@ ===============\n");
  73.     printf("=======================================\n");
  74.     return 0;
  75. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement