ceptr
 All Data Structures Files Functions Variables Typedefs Macros Modules Pages
tree_spec.h
Go to the documentation of this file.
1 
7 #include "../src/ceptr.h"
8 #include "../src/receptor.h"
9 #include "http_example.h"
10 
11 void testCreateTreeNodes() {
12  /* test the creation of trees and the various function that give access to created data elements
13  and basic tree structure navigation
14  */
15  T *t, *t1, *t2, *t3, *t4, *t5;
16 
17  t = _t_new(0,TEST_STR_SYMBOL,"hello",6);
18  spec_is_long_equal(_t_size(t),(long)6);
19  spec_is_equal(_t_children(t),0);
20  spec_is_str_equal((char *)_t_surface(t),"hello");
21  spec_is_ptr_equal(_t_parent(t),NULL);
22  spec_is_ptr_equal(_t_root(t),t);
23  spec_is_ptr_equal(_t_child(t,1),NULL);
24  spec_is_true(semeq(_t_symbol(t),TEST_STR_SYMBOL));
25 
26  t1 = _t_new(t,TEST_STR_SYMBOL,"t1",3);
27  spec_is_ptr_equal(_t_parent(t1),t);
28  spec_is_equal(_t_children(t),1);
29  spec_is_ptr_equal(_t_child(t,1),t1);
30  spec_is_ptr_equal(_t_root(t1),t);
31 
32  t2 = _t_new(t,TEST_STR_SYMBOL,"t2",3);
33  spec_is_ptr_equal(_t_parent(t2),t);
34  spec_is_equal(_t_children(t),2);
35  spec_is_ptr_equal(_t_child(t,2),t2);
36  spec_is_ptr_equal(_t_root(t2),t);
37 
38  Symbol s99 = {0,0,99};
39 
40  t3 = _t_newi(t,s99,101);
41  spec_is_ptr_equal(_t_parent(t3),t);
42  spec_is_equal(_t_children(t),3);
43  spec_is_equal(*(int *)_t_surface(_t_child(t,3)),101);
44 
45  spec_is_ptr_equal(_t_next_sibling(t1),t2);
46  spec_is_ptr_equal(_t_next_sibling(t),NULL);
47  spec_is_ptr_equal(_t_next_sibling(t2),t3);
48  spec_is_ptr_equal(_t_next_sibling(t3),NULL);
49 
50  t4 = _t_new_root(TEST_ANYTHING_SYMBOL);
51  _t_add(t,t4);
52  spec_is_equal(_t_children(t),4);
53  spec_is_ptr_equal(_t_child(t,4),t4);
54 
55  t5 = _t_newr(t4,TEST_ANYTHING_SYMBOL2);
56  spec_is_ptr_equal(_t_parent(t5),t4);
57  spec_is_long_equal(_t_size(t5),(long)0);
58  spec_is_symbol_equal(0,_t_symbol(t5),TEST_ANYTHING_SYMBOL2);
59 
60  _t_detach_by_ptr(t,t3);
61  _t_free(t3); // detatch doesn't free the memory of the removed node
62  spec_is_equal(_t_children(t),3);
63  spec_is_ptr_equal(_t_child(t,3),t4);
64  spec_is_ptr_equal(_t_child(t,2),t2);
65 
66  _t_free(t);
67 
68  float f = 3.1415;
69  T *tf = _t_new(0,TEST_FLOAT_SYMBOL,&f,sizeof(float));
70 
71  spec_is_str_equal(t2s(tf),"(TEST_FLOAT_SYMBOL:3.141500)");
72  _t_free(tf);
73 }
74 
77 
78  // @fixme this is really a bogus test, because why would a TEST_INT have a receptor as a child?
79  // we should make this a rational test
80 
81  T *t = _t_new_root(TEST_ANYTHING_SYMBOL);
82  Receptor *r = _r_new(G_sem,TEST_RECEPTOR);
83  T *tr = _t_new_receptor(t,TEST_RECEPTOR,r);
84 
85  spec_is_ptr_equal(_t_surface(tr),r);
86  spec_is_true(!(tr->context.flags & TFLAG_ALLOCATED));
87 
88  spec_is_str_equal(t2s(t),"(TEST_ANYTHING_SYMBOL (TEST_RECEPTOR:{(RECEPTOR_INSTANCE (INSTANCE_OF:TEST_RECEPTOR) (CONTEXT_NUM:3) (PARENT_CONTEXT_NUM:0) (RECEPTOR_STATE (FLUX (DEFAULT_ASPECT (EXPECTATIONS) (SIGNALS))) (PENDING_SIGNALS) (PENDING_RESPONSES) (CONVERSATIONS) (RECEPTOR_ELAPSED_TIME:0)))}))");
89 
90  _t_free(t); // note, no need to free the receptor explicitly, as _t_free knows about it
92 }
93 
94 void testTreeScape() {
96  Scape *s = _s_new(TEST_INT_SYMBOL,TEST_STR_SYMBOL);
97  T *ts = _t_new_scape(0,TEST_ALPHABETIZE_SCAPE_SYMBOL,s);
98 
99  spec_is_true(ts->context.flags &= TFLAG_SURFACE_IS_SCAPE);
100  spec_is_ptr_equal(_t_surface(ts),s);
101  spec_is_str_equal(t2s(ts),"(TEST_ALPHABETIZE_SCAPE_SYMBOL:key TEST_INT_SYMBOL,data TEST_STR_SYMBOL)");
102 
103  _t_free(ts); // note, no need to free the scape explicitly, as _t_free knows about it
105 }
106 
109  FILE *stream;
110  char buffer[] = "line1\nline2\n";
111  stream = fmemopen(buffer, strlen (buffer), "r+");
112 
113  Stream *s = _st_new_unix_stream(stream,0);
114  T *ts = _t_new_cptr(0,EDGE_STREAM,s);
115 
116  spec_is_true(ts->context.flags & TFLAG_SURFACE_IS_CPTR);
117  spec_is_true(ts->context.flags & TFLAG_REFERENCE);
118  spec_is_ptr_equal(_t_surface(ts),s);
119  char *x = t2s(ts);
120  x[12]=0; // chop off the actual address cus that changes all the time
121  spec_is_str_equal(x,"(EDGE_STREAM");
122 
123  _t_free(ts);
124  // note, for now we must handle all stream deallocation manually because the stream
125  // is just stored in the tree as a cptr
126  _st_free(s);
127 
129 }
130 
131 void testTreeOrthogonal() {
132  T *t = _t_new_root(TEST_ANYTHING_SYMBOL);
133  T *t2 = _t_newi(0,TEST_INT_SYMBOL2,99);
134  T *o = _t_newt(t,TEST_TREE_SYMBOL,t2);
135 
136  spec_is_str_equal(t2s(t),"(TEST_ANYTHING_SYMBOL (TEST_TREE_SYMBOL:{(TEST_INT_SYMBOL2:99)}))");
137 
138  T *tc = _t_clone(t);
139  spec_is_str_equal(t2s(tc),"(TEST_ANYTHING_SYMBOL (TEST_TREE_SYMBOL:{(TEST_INT_SYMBOL2:99)}))");
140 
141  _t_free(t);
142  _t_free(tc);
143 }
144 
145 void testTreeRealloc() {
146  T *ts[12];
147  T *t = _t_new(0,TEST_STR_SYMBOL,"t",2);
148  char tname[3];
149  int i;
150  tname[0] = 't';
151  tname[2] = 0;
152  for (i=0;i<12;i++){
153  tname[1] = 'a'+i;
154  ts[i] = _t_new(t,TEST_STR_SYMBOL,tname,3);
155  }
156  spec_is_str_equal((char *)_t_surface(ts[11]),"tl");
157  _t_free(t);
158 }
159 
162  T *t = _makeTestHTTPRequestTree(); // GET /groups/5/users.json?sort_by=last_name?page=2 HTTP/1.0
163 
164  int p0[] = {TREE_PATH_TERMINATOR};
165  int p1[] = {1,TREE_PATH_TERMINATOR};
166  int p2[] = {2,TREE_PATH_TERMINATOR};
167  int p3[] = {3,TREE_PATH_TERMINATOR};
168  int p33[] = {3,3,TREE_PATH_TERMINATOR};
169  int p331[] = {3,3,1,TREE_PATH_TERMINATOR};
170  int p3312[] = {3,3,1,2,TREE_PATH_TERMINATOR};
171  int p33122[] = {3,3,1,2,2,TREE_PATH_TERMINATOR};
172  int p311[] = {3,1,1,TREE_PATH_TERMINATOR};
173 
174  spec_is_ptr_equal(_t_get(t,p0),t);
175  spec_is_symbol_equal(0,_t_symbol(_t_get(t,p1)),HTTP_REQUEST_VERSION);
176  spec_is_symbol_equal(0,_t_symbol(_t_get(t,p2)),HTTP_REQUEST_METHOD);
177  spec_is_symbol_equal(0,_t_symbol(_t_get(t,p3)),HTTP_REQUEST_PATH);
178  spec_is_symbol_equal(0,_t_symbol(_t_get(t,p33)),HTTP_REQUEST_PATH_QUERY);
179  spec_is_symbol_equal(0,_t_symbol(_t_get(t,p331)),HTTP_REQUEST_PATH_QUERY_PARAMS);
180  spec_is_symbol_equal(0,_t_symbol(_t_get(t,p3312)),HTTP_REQUEST_PATH_QUERY_PARAM);
181  spec_is_symbol_equal(0,_t_symbol(_t_get(t,p33122)),PARAM_VALUE);
182  spec_is_symbol_equal(0,_t_symbol(_t_get(t,p311)),HTTP_REQUEST_PATH_SEGMENT);
183 
184  spec_is_str_equal(t2s(_t_getv(t,3,3,1,2,TREE_PATH_TERMINATOR)),"(HTTP_REQUEST_PATH_QUERY_PARAM (PARAM_KEY:page) (PARAM_VALUE:2))");
185 
186  // _t_get returns null if tree doesn't have a node at the given path
187  p311[2] = 3;
188  spec_is_ptr_equal(_t_get(t,p311),NULL);
189 
190  _t_free(t);
192 }
193 
196  T *t = _makeTestHTTPRequestTree(); // GET /groups/5/users.json?sort_by=last_name?page=2 HTTP/1.0
197 
198  int p1[] = {3,1,1,TREE_PATH_TERMINATOR};
199  int p2[] = {3,1,2,TREE_PATH_TERMINATOR};
200  int p3[] = {3,3,1,2,2,TREE_PATH_TERMINATOR};
201 
202  spec_is_str_equal((char *)_t_get_surface(t,p1),"groups");
203  spec_is_str_equal((char *)_t_get_surface(t,p2),"5");
204  spec_is_str_equal((char *)_t_get_surface(t,p3),"2");
205 
206  // make a test tree with the HTTP request tree as an orthogonal tree
207  T *tt = _t_newt(0,TEST_TREE_SYMBOL,t);
208  int po[] = {0,TREE_PATH_TERMINATOR};
209  int po1[] = {0,3,1,1,TREE_PATH_TERMINATOR};
210 
211  // using 0 in the path should "dive"into the orthogonal tree
212  T *x =_t_get(tt,po);
213  spec_is_ptr_equal(x,t);
214  spec_is_str_equal((char *)_t_get_surface(tt,po1),"groups");
215 
216  _t_free(tt);
218 }
219 
222  T *t = _makeTestHTTPRequestTree(); // GET /groups/5/users.json?sort_by=last_name?page=2 HTTP/1.0
223  int p0[] = {TREE_PATH_TERMINATOR};
224  int p1[] = {1,TREE_PATH_TERMINATOR};
225  int p2[] = {3,1,TREE_PATH_TERMINATOR};
226  int p3[] = {3,1,1,TREE_PATH_TERMINATOR};
227  int *path;
228 
229  path = _t_get_path(_t_get(t,p0));
230  spec_is_path_equal(path,p0);
231  free(path);
232  path = _t_get_path(_t_get(t,p1));
233  spec_is_path_equal(path,p1);
234  free(path);
235  path = _t_get_path(_t_get(t,p3));
236  spec_is_path_equal(path,p3);
237  free(path);
238  path = _t_get_path(_t_get(t,p2));
239  spec_is_path_equal(path,p2);
240  free(path);
241 
242  _t_free(t);
244  }
245 
248  int p0[] = {TREE_PATH_TERMINATOR};
249  int p1[] = {1,TREE_PATH_TERMINATOR};
250  int p2[] = {2,TREE_PATH_TERMINATOR};
251  int p3[] = {2,1,1,TREE_PATH_TERMINATOR};
252  int p4[] = {3,0,TREE_PATH_TERMINATOR};
253  int p5[] = {3,0,2,1,1,TREE_PATH_TERMINATOR};
254 
255  spec_is_true(_t_path_equal(p0,p0));
256  spec_is_true(_t_path_equal(p1,p1));
257  spec_is_true(_t_path_equal(p2,p2));
258  spec_is_true(_t_path_equal(p3,p3));
259  spec_is_true(!_t_path_equal(p0,p1));
260  spec_is_true(!_t_path_equal(p2,p3));
261  spec_is_true(!_t_path_equal(p4,p3));
262  spec_is_true(!_t_path_equal(p0,p3));
263  spec_is_true(!_t_path_equal(p4,p5));
265 }
266 
269  int p0[] = {TREE_PATH_TERMINATOR};
270  int p1[] = {1,TREE_PATH_TERMINATOR};
271  int p2[] = {3,0,TREE_PATH_TERMINATOR};
272  int p3[] = {2,1,1,TREE_PATH_TERMINATOR};
273  int p5[] = {3,0,2,1,1,TREE_PATH_TERMINATOR};
274 
275  spec_is_equal(_t_path_depth(p0),0);
276  spec_is_equal(_t_path_depth(p1),1);
277  spec_is_equal(_t_path_depth(p2),2);
278  spec_is_equal(_t_path_depth(p3),3);
279  spec_is_equal(_t_path_depth(p5),5);
281 }
282 
285  int pp[10];
286  int p5[] = {3,0,2,1,1,TREE_PATH_TERMINATOR};
287  _t_pathcpy(pp,p5);
288 
289  spec_is_path_equal(pp,p5);
291 }
292 
295  char buf[255];
296  int p5[] = {3,0,2,1,1,TREE_PATH_TERMINATOR};
297 
298  spec_is_str_equal(_t_sprint_path(p5,buf),"/3/0/2/1/1");
300 }
301 
304  T *x,*t = _t_parse(G_sem,0,"(Root (A) (B (C (D) (E))) (F))");
305 
306  int *path = NULL;
307  int len;
308 
309  x = _t_path_walk(t,&path,&len);
310  spec_is_str_equal(t2s(x),"(A)");
311  int p1[] = {1,TREE_PATH_TERMINATOR};
312  spec_is_path_equal(path,p1);
313  spec_is_equal(len,2*sizeof(int));
314 
315  x = _t_path_walk(t,&path,&len);
316  spec_is_str_equal(t2s(x),"(D)");
317  int p2[] = {2,1,1,TREE_PATH_TERMINATOR};
318  spec_is_path_equal(path,p2);
319  spec_is_equal(len,4*sizeof(int));
320 
321  x = _t_path_walk(t,&path,&len);
322  spec_is_str_equal(t2s(x),"(E)");
323  int p3[] = {2,1,2,TREE_PATH_TERMINATOR};
324  spec_is_path_equal(path,p3);
325 
326  x = _t_path_walk(t,&path,&len);
327  spec_is_str_equal(t2s(x),"(C (D) (E))");
328  int p4[] = {2,1,TREE_PATH_TERMINATOR};
329  spec_is_path_equal(path,p4);
330 
331  x = _t_path_walk(t,&path,&len);
332  spec_is_str_equal(t2s(x),"(B (C (D) (E)))");
333  int p5[] = {2,TREE_PATH_TERMINATOR};
334  spec_is_path_equal(path,p5);
335 
336  x = _t_path_walk(t,&path,&len);
337  spec_is_str_equal(t2s(x),"(F)");
338  int p6[] = {3,TREE_PATH_TERMINATOR};
339  spec_is_path_equal(path,p6);
340 
341  x = _t_path_walk(t,&path,&len);
342  spec_is_str_equal(t2s(x),"(Root (A) (B (C (D) (E))) (F))");
343  int p7[] = {TREE_PATH_TERMINATOR};
344  spec_is_path_equal(path,p7);
345 
346  x = _t_path_walk(t,&path,&len);
347  spec_is_ptr_equal(x,NULL);
348 
349  free(path);
351 }
352 
355  T *t = _makeTestHTTPRequestTree(); // GET /groups/5/users.json?sort_by=last_name?page=2 HTTP/1.0
356  spec_is_equal(_t_node_index(_t_child(t,1)),1);
357  spec_is_equal(_t_node_index(_t_child(t,2)),2);
358  spec_is_equal(_t_node_index(_t_child(t,3)),3);
359  spec_is_equal(_t_node_index(t),0);
360 
361  _t_free(t);
363 }
364 
368  T *c = _t_clone(t);
369 
370  spec_is_true(t!=c);
371  spec_is_equal(_t_children(c),_t_children(t));
372 
373  char buf1[2000];
374  char buf2[2000];
375  __t_dump(G_sem,c,0,buf1);
376  __t_dump(G_sem,t,0,buf2);
377 
378  spec_is_str_equal(buf1,buf2);
379 
380  spec_is_equal((int)_t_size(t),(int)_t_size(c)); // test cloning of 0 size items (i.e. roots)
381 
382  _t_free(t);
383  _t_free(c);
384 
386 }
387 
390  T *t = _makeTestHTTPRequestTree(); // GET /groups/5/users.json?sort_by=last_name?page=2 HTTP/1.0
391 
392  // replace the version with a new version
393  T *t_version = _t_newr(0,HTTP_REQUEST_VERSION);
394  _t_newi(t_version,VERSION_MAJOR,1);
395  _t_newi(t_version,VERSION_MINOR,1);
396 
397  _t_replace(t,1,t_version);
398  int p[] = {1,TREE_PATH_TERMINATOR};
399  spec_is_str_equal(t2s(_t_get(t,p)),"(HTTP_REQUEST_VERSION (VERSION_MAJOR:1) (VERSION_MINOR:1))");
400 
401  _t_free(t);
402 
403  t = _t_build(G_sem,0,SEMANTIC_MAP,SEMANTIC_LINK,USAGE,REQUEST_TYPE,REPLACEMENT_VALUE,ACTUAL_SYMBOL,PING,NULL_SYMBOL,NULL_SYMBOL,NULL_SYMBOL);
404 
405  T *t2 = _t_build(G_sem,0,TEST_ANYTHING_SYMBOL,TEST_INT_SYMBOL,1,TEST_INT_SYMBOL,2,TEST_INT_SYMBOL,1,TEST_INT_SYMBOL,3,NULL_SYMBOL,NULL_SYMBOL);
406 
407  // test that replace_node can replace at the parent level.
408  _t_replace_node(t,t2);
409  spec_is_str_equal(t2s(t),"(TEST_ANYTHING_SYMBOL (TEST_INT_SYMBOL:1) (TEST_INT_SYMBOL:2) (TEST_INT_SYMBOL:1) (TEST_INT_SYMBOL:3))");
410  spec_is_ptr_equal(_t_parent(t),NULL);
411  spec_is_ptr_equal(_t_parent(_t_child(t,2)),t);
412 
413  // and also at the child level
414  t2 = _t_newi(0,TEST_INT_SYMBOL,314);
415  _t_replace_node(_t_child(t,2),t2);
416  spec_is_str_equal(t2s(t),"(TEST_ANYTHING_SYMBOL (TEST_INT_SYMBOL:1) (TEST_INT_SYMBOL:314) (TEST_INT_SYMBOL:1) (TEST_INT_SYMBOL:3))");
417  spec_is_ptr_equal(_t_parent(_t_child(t,2)),t);
418 
419 
420  _t_free(t);
421 
423 }
424 
425 void testTreeSwap() {
427  T *t = _makeTestHTTPRequestTree(); // GET /groups/5/users.json?sort_by=last_name?page=2 HTTP/1.0
428 
429  // replace the version with a new version
430  T *t_version = _t_newr(0,HTTP_REQUEST_VERSION);
431  _t_newi(t_version,VERSION_MAJOR,1);
432  _t_newi(t_version,VERSION_MINOR,2);
433 
434  spec_is_str_equal(t2s(_t_child(t,1)),"(HTTP_REQUEST_VERSION (VERSION_MAJOR:1) (VERSION_MINOR:1))");
435  T *s = _t_swap(t,1,t_version);
436  // swap returns the node swapped out as a root node
437  spec_is_str_equal(t2s(s),"(HTTP_REQUEST_VERSION (VERSION_MAJOR:1) (VERSION_MINOR:1))");
438  spec_is_ptr_equal(_t_parent(s),NULL);
439  spec_is_str_equal(t2s(_t_child(t,1)),"(HTTP_REQUEST_VERSION (VERSION_MAJOR:1) (VERSION_MINOR:2))");
440 
441  _t_free(s);
442  _t_free(t);
444 }
445 
448  T *t = _makeTestHTTPRequestTree(); // GET /groups/5/users.json?sort_by=last_name?page=2 HTTP/1.0
449  int p[] = {3,1,2,TREE_PATH_TERMINATOR};
450  T *c = _t_new(0,HTTP_REQUEST_PATH_SEGMENT,"a",2);
451  _t_insert_at(t,p,c);
452  char buf[2000];
453  p[2] = TREE_PATH_TERMINATOR;
454  c = _t_get(t,p);
455  __t_dump(G_sem,c,0,buf);
456  spec_is_str_equal(buf,"(HTTP_REQUEST_PATH_SEGMENTS (HTTP_REQUEST_PATH_SEGMENT:groups) (HTTP_REQUEST_PATH_SEGMENT:a) (HTTP_REQUEST_PATH_SEGMENT:5))");
457 
458  _t_free(t);
460 
461  t = _t_new_root(ASCII_CHARS);
462  p[0] = 1;
463  p[1] = TREE_PATH_TERMINATOR;
464  _t_insert_at(t,p,_t_newc(0,ASCII_CHAR,'x'));
465 
466  spec_is_str_equal(t2s(t),"(ASCII_CHARS (ASCII_CHAR:'x'))");
467  _t_free(t);
468 }
469 
472  T *x = _t_newi(0,TEST_INT_SYMBOL,123);
473  T *z = _t_new(0,TEST_STR_SYMBOL,"fish",5);
474 
475  _t_morph(x,z);
476  spec_is_str_equal(t2s(x),"(TEST_STR_SYMBOL:fish)");
477 
478  _t_free(x);
479  _t_free(z);
481 }
482 
485  T *x = _t_new(0,TEST_STR_SYMBOL,"fish",5);
486  int i = 789;
487 
488  __t_morph(x,TEST_INT_SYMBOL,&i,sizeof(int),0);
489  spec_is_str_equal(t2s(x),"(TEST_INT_SYMBOL:789)");
490 
491  _t_free(x);
493 }
494 
497  T *t = _makeTestHTTPRequestTree(); // GET /groups/5/users.json?sort_by=last_name?page=2 HTTP/1.0
498  char buf[2000];
499  int p1[] = {1,TREE_PATH_TERMINATOR};
500 
501  // remove the version from the tree
502  spec_is_symbol_equal(0,_t_symbol(_t_get(t,p1)),HTTP_REQUEST_VERSION);
503  T *t_version = _t_detach_by_idx(t,1);
504  spec_is_symbol_equal(0,_t_symbol(_t_get(t,p1)),HTTP_REQUEST_METHOD);
505 
506  // detached nodes shouldn't have a parent
507  spec_is_ptr_equal(_t_parent(t_version),NULL);
508 
509  _t_free(t);
510  _t_free(t_version);
512 }
513 
514 void testTreeHash() {
516  T *t = _makeTestHTTPRequestTree(); // GET /groups/5/users.json?sort_by=last_name?page=2 HTTP/1.0
517  TreeHash h = _t_hash(G_sem,t);
518 
519  // test that changing a symbol changes the hash
520  t->contents.symbol.id++;
521  spec_is_true(!_t_hash_equal(h,_t_hash(G_sem,t)));
522  t->contents.symbol.id--;
523 
524  // test that changing a surface changes the hash
525  int p[] = {1,2,TREE_PATH_TERMINATOR};
526  T *v = _t_get(t,p);
527  int orig_version = *(int *)&v->contents.surface;
528  *(int *)&v->contents.surface = orig_version + 1;
529  spec_is_true(!_t_hash_equal(h,_t_hash(G_sem,t)));
530  *(int *)&v->contents.surface = orig_version; // change value back
531 
532  // test that changing child order changes the hash
533  T *t_version = _t_detach_by_idx(t,1);
534  _t_add(t,t_version);
535  spec_is_true(!_t_hash_equal(h,_t_hash(G_sem,t)));
536 
537  _t_free(t);
539 }
540 
541 void testUUID() {
542  spec_is_long_equal(sizeof(UUIDt),16); //128 bits
543  UUIDt u = __uuid_gen();
544 
545  struct timespec c;
546  clock_gettime(CLOCK_MONOTONIC, &c);
547  uint64_t t = ((c.tv_sec * (1000000)) + (c.tv_nsec / 1000));
548 
549  // time should be right about now, i.e. within X ms
550  spec_is_long_equal(u.time,t);
551 
552  // @todo something else for the other bits of the UUID.
553 }
554 
557  char buf[2000] = {0};
558  char buf1[2000] = {0};
559  T *t1,*t = _makeTestHTTPRequestTree(); // GET /groups/5/users.json?sort_by=last_name?page=2 HTTP/1.0
560  __t_dump(G_sem,t,0,buf);
561 
562  size_t l;
563  void *surface,*s;
564 
565  _t_serialize(G_sem,t,&surface,&l);
566  s = surface;
567  t1 = _t_unserialize(G_sem,&surface,&l,0);
568  __t_dump(G_sem,t1,0,buf1);
569 
570  spec_is_str_equal(buf1,buf);
571 
572  _t_free(t);
573  _t_free(t1);
574  free(s);
575 
577 }
578 
579 void testTreeJSON() {
581  char buf[5000] = {0};
582  T *t = _makeTestHTTPRequestTree(); // GET /groups/5/users.json?sort_by=last_name?page=2 HTTP/1.0
583  _t2json(G_sem,t,INDENT,buf);
584 
585  // @todo got screwed up by removing list, too lazy to fix
586  //spec_is_str_equal(buf,"{ \"symbol\":{ \"context\":255,\"id\":17 },\"type\":\"HTTP_REQUEST_V09\",\"name\":\"HTTP_REQUEST\",\"children\":[\n { \"symbol\":{ \"context\":255,\"id\":16 },\"type\":\"VERSION\",\"name\":\"HTTP_REQUEST_VERSION\",\"children\":[\n { \"symbol\":{ \"context\":255,\"id\":14 },\"type\":\"INTEGER\",\"name\":\"VERSION_MAJOR\",\"surface\":1},\n { \"symbol\":{ \"context\":255,\"id\":15 },\"type\":\"INTEGER\",\"name\":\"VERSION_MINOR\",\"surface\":0}]},\n { \"symbol\":{ \"context\":255,\"id\":2 },\"type\":\"CSTRING\",\"name\":\"HTTP_REQUEST_METHOD\",\"surface\":\"GET\"},\n { \"symbol\":{ \"context\":255,\"id\":13 },\"type\":\"URI\",\"name\":\"HTTP_REQUEST_PATH\",\"children\":[\n { \"symbol\":{ \"context\":255,\"id\":3 },\"type\":\"segments list\",\"name\":\"HTTP_REQUEST_PATH_SEGMENTS\",\"children\":[\n { \"symbol\":{ \"context\":255,\"id\":4 },\"type\":\"CSTRING\",\"name\":\"HTTP_REQUEST_PATH_SEGMENT\",\"surface\":\"groups\"},\n { \"symbol\":{ \"context\":255,\"id\":4 },\"type\":\"CSTRING\",\"name\":\"HTTP_REQUEST_PATH_SEGMENT\",\"surface\":\"5\"}]},\n { \"symbol\":{ \"context\":255,\"id\":7 },\"type\":\"FILE_HANDLE\",\"name\":\"HTTP_REQUEST_PATH_FILE\",\"children\":[\n { \"symbol\":{ \"context\":255,\"id\":5 },\"type\":\"CSTRING\",\"name\":\"FILE_NAME\",\"surface\":\"users\"},\n { \"symbol\":{ \"context\":255,\"id\":6 },\"type\":\"CSTRING\",\"name\":\"FILE_EXTENSION\",\"surface\":\"json\"}]},\n { \"symbol\":{ \"context\":255,\"id\":8 },\"type\":\"query struct\",\"name\":\"HTTP_REQUEST_PATH_QUERY\",\"children\":[\n { \"symbol\":{ \"context\":255,\"id\":9 },\"type\":\"query param list\",\"name\":\"HTTP_REQUEST_PATH_QUERY_PARAMS\",\"children\":[\n { \"symbol\":{ \"context\":255,\"id\":12 },\"type\":\"KEY_VALUE_PARAM\",\"name\":\"HTTP_REQUEST_PATH_QUERY_PARAM\",\"children\":[\n { \"symbol\":{ \"context\":255,\"id\":10 },\"type\":\"CSTRING\",\"name\":\"PARAM_KEY\",\"surface\":\"sort_by\"},\n { \"symbol\":{ \"context\":255,\"id\":11 },\"type\":\"CSTRING\",\"name\":\"PARAM_VALUE\",\"surface\":\"last_name\"}]},\n { \"symbol\":{ \"context\":255,\"id\":12 },\"type\":\"KEY_VALUE_PARAM\",\"name\":\"HTTP_REQUEST_PATH_QUERY_PARAM\",\"children\":[\n { \"symbol\":{ \"context\":255,\"id\":10 },\"type\":\"CSTRING\",\"name\":\"PARAM_KEY\",\"surface\":\"page\"},\n { \"symbol\":{ \"context\":255,\"id\":11 },\"type\":\"CSTRING\",\"name\":\"PARAM_VALUE\",\"surface\":\"2\"}]}]}]}]}]}");
587 
588  wjson(G_sem,t,"httpreq",0);
589  char *stxs = "/%<HTTP_REQUEST_PATH_SEGMENTS:HTTP_REQUEST_PATH_SEGMENTS,HTTP_REQUEST_PATH_FILE>";
590  T *stx;
591  stx = parseSemtrex(G_sem,stxs);
592  wjson(G_sem,stx,"httpreq",1);
593 
594  T *r;
595  if (_t_matchr(stx,t,&r)) {
596  wjson(G_sem,r,"httpreq",2);
597  _t_free(r);
598  }
599 
600  _t_free(stx);
601  _t_free(t);
603 }
604 
605 void testProcessHTML() {
606  T *t = parseHTML("<html><body><div id=\"314\" class=\"contents\">Hello world<img src=\"test.png\"/></div></body></html>");
607  spec_is_str_equal(t2s(t),"(HTML_HTML (HTML_ATTRIBUTES) (HTML_CONTENT (HTML_BODY (HTML_ATTRIBUTES) (HTML_CONTENT (HTML_DIV (HTML_ATTRIBUTES (HTML_ATTRIBUTE (PARAM_KEY:id) (PARAM_VALUE:314)) (HTML_ATTRIBUTE (PARAM_KEY:class) (PARAM_VALUE:contents))) (HTML_CONTENT (HTML_TEXT:Hello world) (HTML_IMG (HTML_ATTRIBUTES (HTML_ATTRIBUTE (PARAM_KEY:src) (PARAM_VALUE:test.png))) (HTML_CONTENT))))))))");
608  _t_free(t);
609 }
610 
613 
614  // tests basic structures plus the STRUCTURE_ANYTHING
615  T *t = _t_build(G_sem,0,TEST_ANYTHING_SYMBOL,ACTION,IF,TEST_ANYTHING_SYMBOL,TEST_STR_SYMBOL,"fish",NULL_SYMBOL,TEST_INT_SYMBOL,3141,SIGNAL_REF,SignalMessageIdx,MessageHeadIdx,HeadCarrierIdx,TREE_PATH_TERMINATOR,NULL_SYMBOL);
616  spec_is_str_equal(t2s(t),"(TEST_ANYTHING_SYMBOL (ACTION:IF) (TEST_ANYTHING_SYMBOL (TEST_STR_SYMBOL:fish)) (TEST_INT_SYMBOL:3141) (SIGNAL_REF:/2/1/4))");
617  _t_free(t);
618 
619  // tests the STRUCTURE_SEQUENCE def
620  t = _t_build(G_sem,0,SYMBOL_DEFINITION,SYMBOL_LABEL,ENGLISH_LABEL,"shoe size",NULL_SYMBOL,SYMBOL_STRUCTURE,INTEGER,NULL_SYMBOL);
621  spec_is_str_equal(t2s(t),"(SYMBOL_DEFINITION (SYMBOL_LABEL (ENGLISH_LABEL:shoe size)) (SYMBOL_STRUCTURE:INTEGER))");
622  _t_free(t);
623  t = _t_build(G_sem,0,TODAY,YEAR,2015,MONTH,1,DAY,30,NULL_SYMBOL);
624  spec_is_str_equal(t2s(t),"(TODAY (YEAR:2015) (MONTH:1) (DAY:30))");
625  _t_free(t);
626  // tests the STRUCTURE_OR def
627  t = _t_build(G_sem,0,PATTERN,SEMTREX_SYMBOL_LITERAL,SEMTREX_SYMBOL,PING,NULL_SYMBOL);
628  spec_is_str_equal(t2s(t),"(PATTERN (SEMTREX_SYMBOL_LITERAL (SEMTREX_SYMBOL:PING)))");
629  _t_free(t);
630 
631  // tests building a code tree
632  t = _t_build(G_sem,0,RESPOND,SIGNAL_REF,SignalMessageIdx,MessageHeadIdx,HeadCarrierIdx,TREE_PATH_TERMINATOR,YUP,NULL_SYMBOL);
633  spec_is_str_equal(t2s(t),"(process:RESPOND (SIGNAL_REF:/2/1/4) (YUP))");
634  _t_free(t);
635 
636  // test building floats
637  t = _t_build(G_sem,0,TEST_FLOAT_SYMBOL,3.14);
638  spec_is_str_equal(t2s(t),"(TEST_FLOAT_SYMBOL:3.140000)");
639  _t_free(t);
640 
641  // test building chars
642  t = _t_build(G_sem,0,ASCII_CHAR,'x');
643  spec_is_str_equal(t2s(t),"(ASCII_CHAR:'x')");
644  _t_free(t);
645 
646 
647  // build2 tests
648  t = _t_build2(G_sem,0,STX_OP,PROTOCOL_DEFINITION,STX_OP,PROTOCOL_LABEL,STX_OP,ENGLISH_LABEL,"RECOGNIZE",STX_CP,STX_CP,STX_OP,PROTOCOL_SEMANTICS,STX_CP,STX_OP,INCLUSION,STX_OP,PNAME,REQUESTING,STX_CP,STX_OP,LINKAGE,STX_OP,WHICH_ROLE,STX_OP,ROLE,REQUESTER,STX_CP,STX_OP,ROLE,RECOGNIZER,STX_CP,STX_CP,STX_CP,STX_OP,LINKAGE,STX_OP,WHICH_ROLE,STX_OP,ROLE,RESPONDER,STX_CP,STX_OP,ROLE,RECOGNIZEE,STX_CP,STX_CP,STX_CP,STX_OP,LINKAGE,STX_OP,WHICH_GOAL,STX_OP,GOAL,RESPONSE_HANDLER,STX_CP,STX_OP,GOAL,RECOGNITION,STX_CP,STX_CP,STX_CP,STX_OP,RESOLUTION,STX_OP,WHICH_SYMBOL,STX_OP,USAGE,REQUEST_TYPE,STX_CP,STX_OP,ACTUAL_SYMBOL,are_you,STX_CP,STX_CP,STX_CP,STX_OP,RESOLUTION,STX_OP,WHICH_SYMBOL,STX_OP,USAGE,RESPONSE_TYPE,STX_CP,STX_OP,ACTUAL_SYMBOL,i_am,STX_CP,STX_CP,STX_CP,STX_OP,RESOLUTION,STX_OP,WHICH_PROCESS,STX_OP,GOAL,REQUEST_HANDLER,STX_CP,STX_OP,ACTUAL_PROCESS,fill_i_am,STX_CP,STX_CP,STX_CP,STX_CP,STX_CP);
649  spec_is_str_equal(t2s(t),"(PROTOCOL_DEFINITION (PROTOCOL_LABEL (ENGLISH_LABEL:RECOGNIZE)) (PROTOCOL_SEMANTICS) (INCLUSION (PNAME:REQUESTING) (LINKAGE (WHICH_ROLE (ROLE:REQUESTER) (ROLE:RECOGNIZER))) (LINKAGE (WHICH_ROLE (ROLE:RESPONDER) (ROLE:RECOGNIZEE))) (LINKAGE (WHICH_GOAL (GOAL:RESPONSE_HANDLER) (GOAL:RECOGNITION))) (RESOLUTION (WHICH_SYMBOL (USAGE:REQUEST_TYPE) (ACTUAL_SYMBOL:are_you))) (RESOLUTION (WHICH_SYMBOL (USAGE:RESPONSE_TYPE) (ACTUAL_SYMBOL:i_am))) (RESOLUTION (WHICH_PROCESS (GOAL:REQUEST_HANDLER) (ACTUAL_PROCESS:fill_i_am)))))");
650  _t_free(t);
651 
652  // test building characters
653  t = _t_build2(G_sem,0,STX_OP,ASCII_CHAR,'x',STX_CP);
654  spec_is_str_equal(t2s(t),"(ASCII_CHAR:'x')");
655  _t_free(t);
656 
658 
659 }
660 
663 
664  // test filling a value slot
665  T *template = _t_parse(G_sem,0,"(PATTERN (SEMTREX_SYMBOL_LITERAL (SLOT (USAGE:REQUEST_TYPE) (SLOT_IS_VALUE_OF:SEMTREX_SYMBOL))))");
666  T *sem_map = _t_parse(G_sem,0,"(SEMANTIC_MAP (SEMANTIC_LINK (USAGE:REQUEST_TYPE) (REPLACEMENT_VALUE (ACTUAL_SYMBOL:PING))))");
667  _t_fill_template(template,sem_map);
668  spec_is_str_equal(t2s(template),"(PATTERN (SEMTREX_SYMBOL_LITERAL (SEMTREX_SYMBOL:PING)))");
669  _t_free(template);
670  _t_free(sem_map);
671 
672  // test filling a value slot of a non leaf node
673  template = _t_build(G_sem,0,REQUEST,SLOT,ROLE,RESPONDER,SLOT_IS_VALUE_OF,TO_ADDRESS,NULL_SYMBOL,SLOT,USAGE,REQUEST_TYPE,NULL_SYMBOL,SLOT,USAGE,REQUEST_TYPE,NULL_SYMBOL,NULL_SYMBOL);
674  spec_is_str_equal(t2s(template),"(process:REQUEST (SLOT (ROLE:RESPONDER) (SLOT_IS_VALUE_OF:TO_ADDRESS)) (SLOT (USAGE:REQUEST_TYPE)) (SLOT (USAGE:REQUEST_TYPE)))");
675  sem_map = _t_parse(G_sem,0,"(SEMANTIC_MAP (SEMANTIC_LINK (USAGE:REQUEST_TYPE) (REPLACEMENT_VALUE (ACTUAL_SYMBOL:PING))) (SEMANTIC_LINK (ROLE:RESPONDER) (REPLACEMENT_VALUE (ACTUAL_RECEPTOR (RECEPTOR_ADDR:3)))))");
676  _t_fill_template(template,sem_map);
677  spec_is_str_equal(t2s(template),"(process:REQUEST (TO_ADDRESS (RECEPTOR_ADDR:3)) (PING) (PING))");
678  _t_free(template);
679  _t_free(sem_map);
680 
681  // test filling a structure slot
682  template = _t_parse(G_sem,0,"(PATTERN (SEMTREX_SYMBOL_LITERAL (SLOT (USAGE:REQUEST_TYPE))))");
683  sem_map = _t_parse(G_sem,0,"(SEMANTIC_MAP (SEMANTIC_LINK (USAGE:REQUEST_TYPE) (REPLACEMENT_VALUE (SEMTREX_SYMBOL:PING))))");
684  _t_fill_template(template,sem_map);
685  spec_is_str_equal(t2s(template),"(PATTERN (SEMTREX_SYMBOL_LITERAL (SEMTREX_SYMBOL:PING)))");
686 
687  _t_free(template);
688  _t_free(sem_map);
689 
690  // test filling a slot that has specified children (which might also have SLOT)
691  template = _t_parse(G_sem,0,"(SLOT (GOAL:RESPONSE_HANDLER) (SLOT_CHILDREN (TEST_INT_SYMBOL:1) (SLOT (USAGE:REQUEST_TYPE))))");
692  sem_map = _t_parse(G_sem,0,"(SEMANTIC_MAP (SEMANTIC_LINK (USAGE:REQUEST_TYPE) (REPLACEMENT_VALUE (TEST_INT_SYMBOL:32))) (SEMANTIC_LINK (GOAL:RESPONSE_HANDLER) (REPLACEMENT_VALUE (ACTUAL_PROCESS:ADD_INT))))");
693  _t_fill_template(template,sem_map);
694  spec_is_str_equal(t2s(template),"(process:ADD_INT (TEST_INT_SYMBOL:1) (TEST_INT_SYMBOL:32))");
695 
696  _t_free(template);
697  _t_free(sem_map);
698 
699  // test filling a slot with nothing
700  template = _t_parse(G_sem,0,"(SLOT (GOAL:RESPONSE_HANDLER) (SLOT_CHILDREN (TEST_INT_SYMBOL:1) (SLOT (USAGE:REQUEST_TYPE)) (TEST_INT_SYMBOL:2)))");
701  sem_map = _t_parse(G_sem,0,"(SEMANTIC_MAP (SEMANTIC_LINK (USAGE:REQUEST_TYPE) (REPLACEMENT_VALUE (NULL_SYMBOL))) (SEMANTIC_LINK (GOAL:RESPONSE_HANDLER) (REPLACEMENT_VALUE (ACTUAL_PROCESS:ADD_INT))))");
702  _t_fill_template(template,sem_map);
703  spec_is_str_equal(t2s(template),"(process:ADD_INT (TEST_INT_SYMBOL:1) (TEST_INT_SYMBOL:2))");
704 
705  _t_free(template);
706  _t_free(sem_map);
707 
708 
710 }
711 
712 void testTreeStreamWrite() {
713  char buffer[500] = "x";
714  FILE *stream;
715  stream = fmemopen(buffer, 500, "r+");
716  Stream *st = _st_new_unix_stream(stream,1);
717  T *t = _t_new_str(0,TEST_STR_SYMBOL,"fish\n");
718  spec_is_equal(_t_write(G_sem,t,st),5);
719  spec_is_str_equal(buffer,"fish\n");
720  _t_free(t);
721 
722  t = _t_new_str(0,LINE,"cow");
723  spec_is_equal(_t_write(G_sem,t,st),4);
724  spec_is_str_equal(buffer,"fish\ncow\n");
725  _t_free(t);
726 
727  t = _t_new_root(LINES);
728  _t_new_str(t,LINE,"thing1");
729  _t_new_str(t,LINE,"thing2");
730  _t_write(G_sem,t,st);
731  _t_free(t);
732 
733  t = _t_newi(0,TEST_INT_SYMBOL,314);
734  _t_write(G_sem,t,st);
735  _t_free(t);
736 
737  char *expected_result = "fish\ncow\nthing1\nthing2\n(TEST_INT_SYMBOL:314)";
738  spec_is_str_equal(buffer,expected_result);
739 
740  _st_free(st);
741 }
742 
743 void testTreeInt64() {
744  T *t = _t_newi64(0,TEST_INT64_SYMBOL,5000000001);
745  spec_is_str_equal(t2s(t),"(TEST_INT64_SYMBOL:5000000001)");
746  _t_free(t);
747 }
748 
749 void testTreeFindBySymbol() {
750  // many times we have symbols with structures that have optional items
751  // instead of using a semtrex search, this is a simply scan by symbol type
752  // find routine. So for example expectations have optional semantic maps and
753  // conversation so this can be used to find one if it exists.
754 
755  T *match = _t_newr(0,PATTERN);
756  _sl(match,TEST_INT_SYMBOL);
757  UUIDt cuuid = __uuid_gen();
758  T *cid = __cid_new(0,&cuuid,0);
759 
760  T *t = __r_build_expectation(TEST_INT_SYMBOL,match,_t_newp(0,ACTION,NOOP),0,0,NULL,cid);
761 
762  spec_is_ptr_equal(__t_find(t,CONVERSATION_IDENT,ExpectationOptionalsIdx),cid);
763  spec_is_ptr_equal(__t_find(t,SEMANTIC_MAP,ExpectationOptionalsIdx),NULL);
764 
765  _t_free(t);
766 }
767 
768 void testTreeParse() {
769  char *s = "( ) \n\t TEST_LABEL:1 1.2 .334 /) 'c'%\"string\" /1/2/3)";
770  T *t = __t_tokenize(s);
771  spec_is_str_equal(t2s(t),"(P_TOKENS (P_OP) (P_CP) (P_LABEL:TEST_LABEL) (P_COLON) (P_VAL_I:1) (P_VAL_F:1.200000) (P_VAL_F:0.334000) (P_VAL_PATH:/) (P_CP) (P_VAL_C:'c') (P_INTERPOLATE) (P_VAL_S:string) (P_VAL_PATH:/1/2/3) (P_CP))");
772 
773  s = "(DO (SCOPE (TEST_INT_SYMBOL:1) (TEST_CHAR_SYMBOL:'x')% (TEST_STR_SYMBOL:\"fish\") (PARAM_REF:/1/2/3) (CARRIER:backnforth)))";
774  t = _t_parse(G_sem,0,s,_t_newc(0,ASCII_CHAR,'y'));
775  spec_is_str_equal(t2s(t),"(process:DO (SCOPE (TEST_INT_SYMBOL:1) (TEST_CHAR_SYMBOL:'x') (ASCII_CHAR:'y') (TEST_STR_SYMBOL:fish) (PARAM_REF:/1/2/3) (CARRIER:backnforth)))");
776  _t_free(t);
777 
778  s = "(SIGNATURE_SYMBOL:NULL_SYMBOL)";
779  t = _t_parse(G_sem,0,s);
780  spec_is_str_equal(t2s(t),s);
781  _t_free(t);
782 
783  s = "(NULL_SYMBOL)";
784  t = _t_parse(G_sem,0,s);
785  spec_is_str_equal(t2s(t),s);
786  _t_free(t);
787 }
788 
789 void testTree() {
790  testCreateTreeNodes();
792  testTreeScape();
793  testTreeStream();
794  testTreeOrthogonal();
795  testTreeRealloc();
797  testTreePathGet();
805  testTreeClone();
806  testTreeReplace();
807  testTreeSwap();
809  testTreeMorph();
811  testTreeDetach();
812  testTreeHash();
813  testUUID();
815  testTreeJSON();
816  testProcessHTML();
817  testTreeBuild();
819  testTreeStreamWrite();
820  testTreeInt64();
821  testTreeFindBySymbol();
822  testTreeParse();
823 }
void testTreeTemplate()
Definition: tree_spec.h:661
T * _t_new_root(Symbol symbol)
Definition: tree.c:160
Definition: ceptr_types.h:114
Scape * _s_new(Symbol key_source, Symbol data_source)
Definition: scape.c:23
T * _t_next_sibling(T *t)
Definition: tree.c:1306
T * _t_new_scape(T *parent, Symbol symbol, Scape *s)
Definition: tree.c:222
void _t_morph(T *dst, T *src)
Definition: tree.c:357
T * _t_build2(SemTable *sem, T *parent,...)
Definition: tree.c:771
void testTreeMorphLowLevel()
Definition: tree_spec.h:483
Definition: stream.h:30
void testTreePathGet()
Definition: tree_spec.h:160
void testTreePathGetPath()
Definition: tree_spec.h:220
T * _t_get(T *t, int *p)
Definition: tree.c:1441
int _t_write(SemTable *sem, T *t, Stream *stream)
Definition: tree.c:2066
void testTreeHash()
Definition: tree_spec.h:514
void testTreeSerialize()
Definition: tree_spec.h:555
T * _t_path_walk(T *t, int **pathP, int *lenP)
Definition: tree.c:1543
int _t_hash_equal(TreeHash h1, TreeHash h2)
Definition: tree.c:1649
T * _t_detach_by_idx(T *t, int i)
Definition: tree.c:278
int _t_path_depth(int *p)
Definition: tree.c:1365
int _t_node_index(T *t)
Definition: tree.c:1284
void testTreeScape()
Definition: tree_spec.h:94
T * _t_new_receptor(T *parent, Symbol symbol, Receptor *r)
Definition: tree.c:204
void testTreeJSON()
Definition: tree_spec.h:579
TreeHash _t_hash(SemTable *sem, T *t)
Definition: tree.c:1614
int * _t_get_path(T *t)
Definition: tree.c:1384
T * _t_clone(T *t)
Definition: tree.c:589
T * _t_root(T *t)
Definition: tree.c:1272
void _t_serialize(SemTable *sem, T *t, void **surfaceP, size_t *lengthP)
Definition: tree.c:1723
void testTreeMorph()
Definition: tree_spec.h:470
Symbol _t_symbol(T *t)
Definition: tree.c:1228
T * _t_child(T *t, int i)
Definition: tree.c:1251
T * _t_newp(T *parent, Symbol symbol, Process surface)
Definition: tree.c:251
void testTreePathDepth()
Definition: tree_spec.h:267
T * _t_swap(T *t, int i, T *r)
Definition: tree.c:418
void _t_pathcpy(int *dst_p, int *src_p)
Definition: tree.c:1424
void _t_insert_at(T *t, int *path, T *i)
Definition: tree.c:438
void testTreeDetach()
Definition: tree_spec.h:495
void testTreeNewReceptor()
Definition: tree_spec.h:75
void testTreeNodeIndex()
Definition: tree_spec.h:353
void testTreeBuild()
Definition: tree_spec.h:611
void testTreeSwap()
Definition: tree_spec.h:425
void * _t_surface(T *t)
Definition: tree.c:1215
Receptor * _r_new(SemTable *sem, SemanticID r)
Creates a new receptor.
Definition: receptor.c:88
T * _t_newt(T *parent, Symbol symbol, T *surface)
Definition: tree.c:133
void _t_replace_node(T *t, T *r)
Definition: tree.c:391
T * _t_parent(T *t)
Definition: tree.c:1262
void testTreeStream()
Definition: tree_spec.h:107
void testTreePathCopy()
Definition: tree_spec.h:283
void _st_free(Stream *st)
Definition: stream.c:507
void testTreeReplace()
Definition: tree_spec.h:388
int _t_matchr(T *semtrex, T *t, T **rP)
Definition: semtrex.c:798
void * _t_get_surface(T *t, int *p)
Definition: tree.c:1492
T * __t_find(T *t, SemanticID sym, int start_child)
Definition: tree.c:1328
void testTreeClone()
Definition: tree_spec.h:365
void testTreePathGetSurface()
Definition: tree_spec.h:194
T * _makeTestHTTPRequestTree()
[makeTestHTTPRequestTree]
Definition: http_example.h:26
void testTreePathEqual()
Definition: tree_spec.h:246
void testTreePathSprint()
Definition: tree_spec.h:293
#define _sl(t, s)
macro to add a single symbol literal to semtrex tree
Definition: semtrex.h:122
T * parseSemtrex(SemTable *sem, char *stx)
Definition: semtrex.c:1298
T * _t_parse(SemTable *sem, T *parent, char *s,...)
Definition: tree.c:919
int _t_path_equal(int *p1, int *p2)
Definition: tree.c:1350
void _t_add(T *t, T *c)
Definition: tree.c:261
char * _t2json(SemTable *sem, T *t, int level, char *buf)
Definition: tree.c:1912
void __t_morph(T *t, Symbol s, void *surface, size_t size, int allocate)
Definition: tree.c:325
int _t_children(T *t)
Definition: tree.c:1205
void _t_replace(T *t, int i, T *r)
Definition: tree.c:372
void testTreePathWalk()
Definition: tree_spec.h:302
void _t_detach_by_ptr(T *t, T *c)
Definition: tree.c:291
void testTreeInsertAt()
Definition: tree_spec.h:446
void _t_free(T *t)
Definition: tree.c:526
T * _t_build(SemTable *sem, T *parent,...)
Definition: tree.c:635
T * _t_getv(T *t,...)
Definition: tree.c:1470
size_t _t_size(T *t)
Definition: tree.c:1238
T * _t_new_cptr(T *parent, Symbol symbol, void *s)
Definition: tree.c:239
char * _t_sprint_path(int *fp, char *buf)
Definition: tree.c:1508