forked from svaderia/ParallelDF
-
Notifications
You must be signed in to change notification settings - Fork 0
/
myStack_test.c
46 lines (36 loc) · 987 Bytes
/
myStack_test.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include "myStack.h"
struct Element{
int data;
};
typedef struct Element Element;
int main(){
int i;
Element* e1 = (Element*) malloc(sizeof(Element));
Element* e2 = (Element*) malloc(sizeof(Element));
Element* e3 = (Element*) malloc(sizeof(Element));
e1 -> data = 1;
e2 -> data = 2;
e3 -> data = 3;
Stack* temp = new_stack();
printf("%d\n", temp -> size);
temp = push(temp, e1);
temp = push(temp, e2);
temp = push(temp, e3);
printf("%d\n", temp -> size);
printf("%d\n", ((Element*)(temp -> head -> ele)) -> data);
printf("%d\n", ((Element*)(temp -> head -> next -> ele)) -> data);
printf("%d\n", ((Element*)(temp -> head -> next -> next -> ele)) -> data);
temp = pop(temp);
printf("%d\n", temp -> size);
printf("%d\n", ((Element*)(temp -> head -> ele)) -> data);
temp = pop(temp);
temp = pop(temp);
bool test_empty = is_empty(temp);
if(test_empty){
printf("List is empty\n");
}
return 0;
}