ceptr
 All Data Structures Files Functions Variables Typedefs Macros Modules Pages
scape_spec.h
Go to the documentation of this file.
1 
7 #include "../src/ceptr.h"
8 #include "../src/scape.h"
9 #include "../src/receptor.h"
10 
11 void testScapeNew() {
13  Scape *s = _s_new(TEST_INT_SYMBOL,TEST_STR_SYMBOL);
14  spec_is_symbol_equal(0,s->key_source,TEST_INT_SYMBOL);
15  spec_is_symbol_equal(0,s->data_source,TEST_STR_SYMBOL);
16  _s_free(s);
18 }
19 
22  Scape *s = _s_new(TEST_INT_SYMBOL,TEST_STR_SYMBOL);
23  Xaddr x = {1,3}; // DUMMY XADDR
24  T *t = _t_newi(0,TEST_INT_SYMBOL,31415);
25  TreeHash h = _t_hash(G_sem,t);
26  _s_add(s,h,x);
27 
28  // check that element was added
29  Xaddr xg = _s_get(s,h);
30  spec_is_sem_equal(xg.symbol,x.symbol);
31  spec_is_equal(xg.addr,x.addr);
32 
33  // check that a different hash returns the null xaddr
34  t->contents.symbol = TEST_INT_SYMBOL2;
35  h = _t_hash(G_sem,t);
36  xg = _s_get(s,h);
37  spec_is_true(is_null_xaddr(xg));
38 
39  _s_free(s);
40  _t_free(t);
42 }
43 
44 void testScape() {
45  testScapeNew();
47 }
Definition: ceptr_types.h:114
Scape * _s_new(Symbol key_source, Symbol data_source)
Definition: scape.c:23
Xaddr _s_get(Scape *s, TreeHash h)
Definition: scape.c:83
void testScapeAddElement()
Definition: scape_spec.h:20
TreeHash _t_hash(SemTable *sem, T *t)
Definition: tree.c:1614
void _s_free(Scape *s)
Definition: scape.c:43
void testScapeNew()
Definition: scape_spec.h:11
void _t_free(T *t)
Definition: tree.c:526
void _s_add(Scape *s, TreeHash h, Xaddr x)
Definition: scape.c:57