comparison src/parallel_execution/test/rbTree_test.cbc @ 469:ed494f4004c9

add RedBlackTree.cbc insert Test
author ryokka
date Wed, 27 Dec 2017 18:26:37 +0900
parents ac244346c85d
children 4b5f9884b777
comparison
equal deleted inserted replaced
468:ac244346c85d 469:ed494f4004c9
1 #include <stdio.h>
1 #include "../../context.h" 2 #include "../../context.h"
2 #interface "Tree.h" 3 #interface "Tree.h"
4
3 /* #include <assert.h> */ 5 /* #include <assert.h> */
4 6
5 __code rbTreeTest1(struct Tree* tree) { 7 __code rbTreeTest1(struct Tree* tree) {
6 printf("Test1\n"); 8 printf("Test1\n");
7 Node* node = new Node(); 9 Node* node = new Node();
8 node->value = 3; 10 node->value = (union Data*)new Int();
11 node->value->Int = 3;
9 node->key = 3; 12 node->key = 3;
10 printf("value->%d,key->%d\n",node->value,node->key); 13 printf("value->%d,key->%d\n",node->value->Int,node->key);
11 goto tree->put(node, rbTreeTest2); 14 goto tree->put(node, rbTreeTest2);
12 } 15 }
13 16
14 __code rbTreeTest1_stub(struct Context* context) { 17 __code rbTreeTest1_stub(struct Context* context) {
15 printf("test1_stub\n"); 18 printf("test1_stub\n");
19 22
20 23
21 __code rbTreeTest2(struct Tree* tree) { 24 __code rbTreeTest2(struct Tree* tree) {
22 printf("Test2\n"); 25 printf("Test2\n");
23 Node* node = new Node(); 26 Node* node = new Node();
24 node->value = 4; 27 node->value = (union Data*)new Int();
28 node->value->Int = 4;
25 node->key = 4; 29 node->key = 4;
26 goto tree->put(node, rbTreeTest3); 30 goto tree->put(node, rbTreeTest3);
27 } 31 }
28 32
29 __code rbTreeTest2_stub(struct Context* context) { 33 __code rbTreeTest2_stub(struct Context* context) {
34 38
35 39
36 __code rbTreeTest3(struct Tree* tree) { 40 __code rbTreeTest3(struct Tree* tree) {
37 printf("test3\n"); 41 printf("test3\n");
38 Node* node = new Node(); 42 Node* node = new Node();
39 node->value = 2; 43 node->value = (union Data*)new Int();
44 node->value->Int = 2;
40 node->key = 2; 45 node->key = 2;
41 goto tree->put(node, rbTreeTest4); 46 goto tree->put(node, rbTreeTest4);
42 } 47 }
43 48
49 __code rbTreeTest3_stub(struct Context* context) {
50 Tree* tree = (struct Tree*)Gearef(context, Tree)->tree;
51 goto rbTreeTest3(context,tree);
52 }
44 53
45 __code rbTreeTest4(struct Tree* tree) { 54 __code rbTreeTest4(struct Tree* tree) {
46 printf("test4\n"); 55 printf("test4\n");
47 Node* node = new Node(); 56 Node* node = new Node();
48 node->value = 8; 57 node->value = (union Data*)new Int();
58 node->value->Int = 8;
49 node->key = 8; 59 node->key = 8;
50 goto tree->put(node, rbTreeTest5); 60 goto tree->put(node, rbTreeTest5);
51 } 61 }
52 62
63 __code rbTreeTest4_stub(struct Context* context) {
64 Tree* tree = (struct Tree*)Gearef(context, Tree)->tree;
65 goto rbTreeTest4(context,tree);
66 }
53 67
54 __code rbTreeTest5(struct Tree* tree) { 68 __code rbTreeTest5(struct Tree* tree) {
55 printf("test5\n"); 69 printf("test5\n");
56 Node* node = new Node(); 70 Node* node = new Node();
57 node->value = 7; 71 node->value = (union Data*)new Int();
72 node->value->Int = 7;
58 node->key = 7; 73 node->key = 7;
59 goto exit_code(context); 74 goto exit_code(context);
60 } 75 }
61 76
77 __code rbTreeTest5_stub(struct Context* context) {
78 Tree* tree = (struct Tree*)Gearef(context, Tree)->tree;
79 goto rbTreeTest5(context,tree);
80 }
62 81
63 82
64 83
65 int main(int argc, char const* argv[]) { 84 int main(int argc, char const* argv[]) {
66 printf("test_main\n"); 85 printf("test_main\n");