Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Here it is a main test for voidlist library */
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include "voidlist.h"
- int main(){
- printf("=======================================\n");
- printf("=============== TESTING ===============\n");
- printf("=======================================\n");
- list_t *int_Test, *string_Test;
- int *a, *b, *c;
- char *s1, *s2, *s3;
- printf("Setting up the environment...\n");
- //creating a new list of int
- int_Test = create_int_list();
- printf("A new list of int has been created...\n");
- //creating a new list of strings
- string_Test = create_string_list();
- printf("A new list of strings has been created...\n\n");
- //test 1a : trying to print an empty list
- printf("=============== TEST 1A ===============\n");
- printf("trying to print an empty list of int...\n");
- printf("expected a warning msg :\n");
- printList(int_Test);
- printf("================= END =================\n\n");
- //inserting elements 1,5,9 into int_Test
- a = (int*) malloc(sizeof(int));
- *a = 1;
- b = (int*) malloc(sizeof(int));
- *b = 5;
- c = (int*) malloc(sizeof(int));
- *c = 9;
- insert_inList(int_Test,a);
- insert_inList(int_Test,c);
- insert_inList(int_Test,b);
- printf("Elements : 1, 5, 9 has been inserted...\n\n");
- //test 2a : print the list
- printf("=============== TEST 2A ===============\n");
- printf("trying to print a list of int...\n");
- printf("expected msg : 1 -> 5-> 9-># end of list\n");
- printList(int_Test);
- printf("================= END =================\n\n");
- //extracting element 5 from int_Test
- extract_fromList(int_Test,b);
- printf("Elements : 5 has been extracted\n\n");
- //test 3a : print the list
- //test 2a : print the list
- printf("=============== TEST 3A ===============\n");
- printf("trying to print a list of int...\n");
- printf("expected msg : 1 -> 9-># end of list\n");
- printList(int_Test);
- printf("================= END =================\n\n");
- //test 1b : trying to print an empty list
- printf("=============== TEST 1B ===============\n");
- printf("trying to print an empty list of strings...\n");
- printf("expected a warning msg :\n");
- printList(string_Test);
- printf("================= END =================\n\n");
- printf("=======================================\n");
- printf("=============== @@@@@@@ ===============\n");
- printf("=======================================\n");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement