MCPcopy Create free account
hub / github.com/acl-dev/acl / test1

Function test1

lib_acl_cpp/samples/dbuf/alloc/main.cpp:33–86  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

31};
32
33static void test1(int nblock, int capacity, int incr, int max, int pos) {
34 acl::dbuf_guard dbuf((size_t) nblock, (size_t) capacity);
35 dbuf.set_increment((size_t) incr);
36 myobj* o;
37 std::list<myobj*, acl::dbuf_allocator<myobj*> > objs;
38 //std::list<myobj*> objs;
39
40 for (int i = 0; i < max; i++) {
41 o = dbuf.create<myobj>(&dbuf, i);
42 if (i < 10) {
43 o->run();
44 }
45 objs.push_back(o);
46 }
47
48 o = (myobj*) dbuf.get((size_t) pos);
49 if (o == NULL) {
50 printf("get: %d NULL\r\n", pos);
51 } else if (o->get() != pos) {
52 printf("get: %d != %d\r\n", o->get(), pos);
53 } else {
54 printf("ok, max: %d, pos: %d\r\n", max, pos);
55 }
56
57 printf("\r\n----------------walk the list------------\r\n");
58 int n = 0;
59 for (std::list<myobj*, acl::dbuf_allocator<myobj*> >::iterator
60 it = objs.begin(); it != objs.end(); ++it) {
61 (*it)->run();
62 if (++n >= 10) {
63 break;
64 }
65 }
66
67 objs.clear();
68 dbuf.dbuf_reset();
69
70 for (int i = 0; i < max; i++) {
71 o = dbuf.create<myobj>(&dbuf, i);
72 if (i < 10) {
73 o->run();
74 }
75 }
76
77 o = (myobj*) dbuf.get((size_t) pos);
78
79 if (o == NULL) {
80 printf("get: %d NULL\r\n", pos);
81 } else if (o->get() != pos) {
82 printf("get: %d != %d\r\n", o->get(), pos);
83 } else {
84 printf("ok, max: %d, pos: %d\r\n", max, pos);
85 }
86}
87
88static void test2(void) {
89 acl::dbuf_guard dbuf;

Callers 1

mainFunction · 0.70

Calls 8

set_incrementMethod · 0.80
beginMethod · 0.80
dbuf_resetMethod · 0.80
runMethod · 0.45
push_backMethod · 0.45
getMethod · 0.45
endMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…