int main() { int32_t a; uint32_t b; void *c; a = 0; test_int(a); a = -1; test_int(a); a = 1; test_int(a); a = -2; test_int(a); a = 2; test_int(a); a = MAX_TAG_INT-2; test_int(a); a = MAX_TAG_INT-1; test_int(a); a = MAX_TAG_INT; test_int(a); a = MIN_TAG_INT+2; test_int(a); a = MIN_TAG_INT+1; test_int(a); a = MIN_TAG_INT; test_int(a); b = 0; test_uint(b); b = 1; test_uint(b); b = 2; test_uint(b); b = MAX_TAG_UINT-2; test_uint(b); b = MAX_TAG_UINT-1; test_uint(b); b = MAX_TAG_UINT; test_uint(b); c = NULL; test_ptr(c); c = (void *) &a; test_ptr(c); c = (void *) &b; test_ptr(c); c = (void *) &c; test_ptr(c); return 0; }
void finalize(void *ctxt) { test_ptr_null("finalizer ran", NULL); test_ptr("correct context", ctxt, ctxt_magic); test_stop(); }
// Types can be defined in constexpr functions. constexpr int f() { enum E { e1, e2, e3 }; struct S { constexpr S(E e) : e(e) {} constexpr int get() { return e; } E e; }; return S(e2).get(); }
int main() { test_MDBU(); test_ROU(); test_hex(); test_struct(); test_ptr(); test_ptr2(); test_st(); return; }
int main(int argc, char** argv) { wlog("testing creating, get, set and iteration\n"); test_create_and_access(); wlog("testing realloc resize clear and freedata\n"); test_realloc_resize(); wlog("testing push pop and extend\n"); test_pushpop(); wlog("testing sort\n"); test_sort(); wlog("testing basic type long\n"); test_long(); wlog("testing pointer\n"); test_ptr(); }
int main(void) { test_start("Dispatch Suspend Timer"); dispatch_queue_t main_q = dispatch_get_main_queue(); test_ptr("dispatch_get_main_queue", main_q, dispatch_get_current_queue()); __block int i = 0; __block int j = 0; dispatch_source_attr_t attr = dispatch_source_attr_create(); test_ptr_notnull("dispatch_source_attr_create", attr); dispatch_source_attr_set_finalizer(attr, ^(dispatch_source_t ds) { test_ptr_notnull("finalizer ran", ds); if (ds == tweedledum) test_stop(); });
void test_fin(void *cxt) { fprintf(stderr, "Called back every %llu us on average\n", (delay/count)/NSEC_PER_USEC); test_long_less_than("Frequency", 1, ceil((double)delay/(count*interval))); int i; for (i = 0; i < N; i++) { dispatch_source_cancel(t[i]); dispatch_release(t[i]); } dispatch_resume(q); dispatch_release(q); dispatch_release(g); test_ptr("finalizer ran", cxt, cxt); test_stop(); }
void main(int a) { test_ull (); test_struct () ; test_struct_ptr () ; test_tab (13) ; test_float_double (); int b = init(5); // TODO: init(5); b = 0; z = add3 (a, 0, 0); int *p = test_ptr (y); //@ assert *p == 7 ; int *q = a?p:&y; int yy = *q; //@ assert a==0 ==> q==&y ; //@ assert *q == 7 ; }
int main(void) { dispatch_queue_t main_q; test_start("Dispatch Update Timer"); main_q = dispatch_get_main_queue(); test_ptr("dispatch_get_main_queue", main_q, dispatch_get_current_queue()); timer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, main_q); dispatch_source_set_timer(timer, 1000000000ull, 0, 0); dispatch_source_set_cancel_handler_f(timer, cancel_handler); dispatch_source_set_event_handler_f(timer, event_handler); test_ptr_notnull("dispatch_source_timer_create", timer); gettimeofday(&start_time, NULL); dispatch_resume(as_do(timer)); dispatch_main(); }
int main(void) { test_start("Dispatch Update Timer"); dispatch_queue_t main_q = dispatch_get_main_queue(); test_ptr("dispatch_get_main_queue", main_q, dispatch_get_current_queue()); __block int i = 0; struct timeval start_time; gettimeofday(&start_time, NULL); dispatch_source_attr_t attr = dispatch_source_attr_create(); dispatch_source_attr_set_finalizer(attr, ^(dispatch_source_t ds) { struct timeval end_time; gettimeofday(&end_time, NULL); // Make sure we actually managed to adjust the interval // duration. Seven one second ticks would blow past // this. test_long_less_than("total duration", end_time.tv_sec - start_time.tv_sec, 3); test_ptr_notnull("finalizer ran", ds); test_stop(); });
int main(void) { test_start("Dispatch Source Timer, bit 31"); dispatch_queue_t main_q = dispatch_get_main_queue(); test_ptr("dispatch_get_main_queue", main_q, dispatch_get_current_queue()); __block int i = 0; struct timeval start_time; gettimeofday(&start_time, NULL); dispatch_source_attr_t attr = dispatch_source_attr_create(); dispatch_source_attr_set_finalizer(attr, ^(dispatch_source_t ds) { struct timeval end_time; gettimeofday(&end_time, NULL); test_ptr_notnull("finalizer ran", ds); // XXX: check, s/b 2.0799... seconds, which is <4 seconds // when it could end on a bad boundry. test_long_less_than("needs to finish faster than 4 seconds", end_time.tv_sec - start_time.tv_sec, 4); // And it has to take at least two seconds... test_long_less_than("can't finish faster than 2 seconds", 1, end_time.tv_sec - start_time.tv_sec); test_stop(); });
void test_fin(void *cxt) { test_ptr("test_fin run", cxt, cxt); test_stop(); }
DEF_TEST(Writer32_misc, reporter) { test_reserve(reporter); test_string_null(reporter); test_ptr(reporter); test_rewind(reporter); }
static void finalizer(void *ctxt) { test_ptr("finalizer ran", ctxt, ctxt_magic); test_stop(); }
void never_call(void *ctxt) { test_ptr_notnull("never_call should not run", NULL); test_ptr("correct context", ctxt, NULL); }