void test_gfx(int argc, char **argv) { int delay = 1000; Screen* screen = switch_to_vga(); fill_screen(screen, color_make(2, 0, 0)); draw_button(screen); sleep(delay); test_lines(screen); sleep(delay); test_circles(screen); sleep(delay); test_rects(screen); sleep(delay); test_triangles(screen); sleep(delay); test_text(screen); sleep(delay); draw_julia(screen); sleep(delay); draw_mandelbrot(screen); sleep(delay); gfx_teardown(screen); switch_to_text(); }
static gboolean test_row(GtkTreeModel *model, GtkTreeIter *iter, gint sel, gint col_num, gint search_val, const gchar *search_text) { gchar *text = NULL; gboolean found = FALSE; gint val; switch (col_num) { case TRACE_VIEW_STORE_COL_INDEX: case TRACE_VIEW_STORE_COL_CPU: case TRACE_VIEW_STORE_COL_PID: /* integers */ gtk_tree_model_get(model, iter, col_num, &val, -1); if (test_int(val, search_val, sel)) found = TRUE; break; case TRACE_VIEW_STORE_COL_TS: case TRACE_VIEW_STORE_COL_COMM: case TRACE_VIEW_STORE_COL_LAT: case TRACE_VIEW_STORE_COL_EVENT: case TRACE_VIEW_STORE_COL_INFO: /* strings */ gtk_tree_model_get(model, iter, col_num, &text, -1); if (test_text(text, search_text, sel)) found = TRUE; break; } return found; }
int main (void) { gsl_ieee_env_setup (); test_func (); test_float_func (); test_long_double_func (); test_ulong_func (); test_long_func (); test_uint_func (); test_int_func (); test_ushort_func (); test_short_func (); test_uchar_func (); test_char_func (); test_complex_func (); test_complex_float_func (); test_complex_long_double_func (); test_text (); test_float_text (); #if HAVE_PRINTF_LONGDOUBLE test_long_double_text (); #endif test_ulong_text (); test_long_text (); test_uint_text (); test_int_text (); test_ushort_text (); test_short_text (); test_uchar_text (); test_char_text (); test_complex_text (); test_complex_float_text (); #if HAVE_PRINTF_LONGDOUBLE test_complex_long_double_text (); #endif test_binary (); test_float_binary (); test_long_double_binary (); test_ulong_binary (); test_long_binary (); test_uint_binary (); test_int_binary (); test_ushort_binary (); test_short_binary (); test_uchar_binary (); test_char_binary (); test_complex_binary (); test_complex_float_binary (); test_complex_long_double_binary (); gsl_set_error_handler (&my_error_handler); test_trap (); test_float_trap (); test_long_double_trap (); test_ulong_trap (); test_long_trap (); test_uint_trap (); test_int_trap (); test_ushort_trap (); test_short_trap (); test_uchar_trap (); test_char_trap (); test_complex_trap (); test_complex_float_trap (); test_complex_long_double_trap (); exit (gsl_test_summary ()); }
static void validate_accessible (Accessible *accessible, gboolean has_parent, gboolean recurse_down) { Accessible *tmp; char *name, *descr; AccessibleRole role; AccessibleRelation **relations; char *role_name; GString *item_str = g_string_new (""); int i; name = Accessible_getName (accessible); g_assert (name != NULL); descr = Accessible_getDescription (accessible); g_assert (descr != NULL); role = Accessible_getRole (accessible); g_assert (role != SPI_ROLE_INVALID); role_name = Accessible_getRoleName (accessible); g_assert (role_name != NULL); relations = Accessible_getRelationSet (accessible); g_assert (relations != NULL); for (i = 0; relations [i]; i++) { AccessibleRelationType type; int targets; fprintf (stderr, "relation %d\n", i); type = AccessibleRelation_getRelationType (relations [i]); g_assert (type != SPI_RELATION_NULL); targets = AccessibleRelation_getNTargets (relations [i]); g_assert (targets != -1); AccessibleRelation_unref (relations [i]); relations [i] = NULL; } free (relations); if (print_tree) { int i; for (i = 0; i < print_tree_depth; i++) fputc (' ', stderr); fputs ("|-> [ ", stderr); } if (Accessible_isAction (accessible)) { tmp = Accessible_getAction (accessible); g_assert (tmp != NULL); if (print_tree) fprintf (stderr, "At"); else test_action (tmp); AccessibleAction_unref (tmp); } if (Accessible_isApplication (accessible)) { tmp = Accessible_getApplication (accessible); if (print_tree) fprintf (stderr, "Ap"); else test_application (tmp); AccessibleApplication_unref (tmp); } if (Accessible_isComponent (accessible)) { tmp = Accessible_getComponent (accessible); g_assert (tmp != NULL); if (print_tree) fprintf (stderr, "Co"); else test_component (tmp); AccessibleComponent_unref (tmp); } if (Accessible_isEditableText (accessible)) { tmp = Accessible_getEditableText (accessible); g_assert (tmp != NULL); if (print_tree) fprintf (stderr, "Et"); else test_editable_text (tmp); AccessibleEditableText_unref (tmp); } if (Accessible_isHypertext (accessible)) { tmp = Accessible_getHypertext (accessible); g_assert (tmp != NULL); if (print_tree) fprintf (stderr, "Ht"); AccessibleHypertext_unref (tmp); } if (Accessible_isImage (accessible)) { tmp = Accessible_getImage (accessible); g_assert (tmp != NULL); if (print_tree) { char *desc; fprintf (stderr, "Im"); desc = AccessibleImage_getImageDescription (tmp); g_string_append_printf ( item_str, " image descr: '%s'", desc); SPI_freeString (desc); } else test_image (tmp); AccessibleImage_unref (tmp); } if (Accessible_isSelection (accessible)) { tmp = Accessible_getSelection (accessible); g_assert (tmp != NULL); if (print_tree) fprintf (stderr, "Se"); AccessibleSelection_unref (tmp); } if (Accessible_isTable (accessible)) { tmp = Accessible_getTable (accessible); g_assert (tmp != NULL); if (print_tree) fprintf (stderr, "Ta"); else test_table (tmp); AccessibleTable_unref (tmp); } if (Accessible_isText (accessible)) { tmp = Accessible_getText (accessible); g_assert (tmp != NULL); if (print_tree) fprintf (stderr, "Te"); else { if (strcmp (name, TEST_STRING_A_OBJECT) == 0) test_text (tmp); } AccessibleText_unref (tmp); } if (Accessible_isValue (accessible)) { tmp = Accessible_getValue (accessible); g_assert (tmp != NULL); if (print_tree) fprintf (stderr, "Va"); else test_value (tmp); AccessibleValue_unref (tmp); } if (print_tree) fprintf (stderr, " ] '%s' (%s) - %s: %s\n", name, descr, role_name, item_str->str); SPI_freeString (name); SPI_freeString (descr); SPI_freeString (role_name); g_string_free (item_str, TRUE); validate_tree (accessible, has_parent, recurse_down); }
int main (void) { size_t M = 53; size_t N = 107; gsl_ieee_env_setup (); test_func (M, N); test_float_func (M, N); test_long_double_func (M, N); test_ulong_func (M, N); test_long_func (M, N); test_uint_func (M, N); test_int_func (M, N); test_ushort_func (M, N); test_short_func (M, N); test_uchar_func (M, N); test_char_func (M, N); test_complex_func (M, N); test_complex_float_func (M, N); test_complex_long_double_func (M, N); test_ops (M, N); test_float_ops (M, N); test_long_double_ops (M, N); test_ulong_ops (M, N); test_long_ops (M, N); test_uint_ops (M, N); test_int_ops (M, N); test_ushort_ops (M, N); test_short_ops (M, N); test_uchar_ops (M, N); test_char_ops (M, N); /* Must use smaller dimensions to prevent approximation of floats in float_mul_elements test*/ { const size_t P = 8; const size_t Q = 12; test_complex_ops (P, Q); test_complex_float_ops (P, Q); test_complex_long_double_ops (P, Q); } test_text (M, N); test_float_text (M, N); #if HAVE_PRINTF_LONGDOUBLE test_long_double_text (M, N); #endif test_ulong_text (M, N); test_long_text (M, N); test_uint_text (M, N); test_int_text (M, N); test_ushort_text (M, N); test_short_text (M, N); test_uchar_text (M, N); test_char_text (M, N); test_complex_text (M, N); test_complex_float_text (M, N); #if HAVE_PRINTF_LONGDOUBLE test_complex_long_double_text (M, N); #endif test_binary (M, N); test_float_binary (M, N); test_long_double_binary (M, N); test_ulong_binary (M, N); test_long_binary (M, N); test_uint_binary (M, N); test_int_binary (M, N); test_ushort_binary (M, N); test_short_binary (M, N); test_uchar_binary (M, N); test_char_binary (M, N); test_complex_binary (M, N); test_complex_float_binary (M, N); test_complex_long_double_binary (M, N); #if GSL_RANGE_CHECK gsl_set_error_handler (&my_error_handler); test_trap (M, N); test_float_trap (M, N); test_long_double_trap (M, N); test_ulong_trap (M, N); test_long_trap (M, N); test_uint_trap (M, N); test_int_trap (M, N); test_ushort_trap (M, N); test_short_trap (M, N); test_uchar_trap (M, N); test_char_trap (M, N); test_complex_trap (M, N); test_complex_float_trap (M, N); test_complex_long_double_trap (M, N); #endif exit (gsl_test_summary ()); }
int main (void) { size_t stride, ostride, N; gsl_ieee_env_setup (); for (N = 10; N < 1024; N = 2*N + 1) { for (stride = 1; stride < 5 ; stride++) { test_func (stride, N); test_float_func (stride, N); test_long_double_func (stride, N); test_ulong_func (stride, N); test_long_func (stride, N); test_uint_func (stride, N); test_int_func (stride, N); test_ushort_func (stride, N); test_short_func (stride, N); test_uchar_func (stride, N); test_char_func (stride, N); test_complex_func (stride, N); test_complex_float_func (stride, N); test_complex_long_double_func (stride, N); for (ostride = 1; ostride < 5 ; ostride++) { test_ops (stride, ostride, N); test_float_ops (stride, ostride, N); test_long_double_ops (stride, ostride, N); test_ulong_ops (stride, ostride, N); test_long_ops (stride, ostride, N); test_uint_ops (stride, ostride, N); test_int_ops (stride, ostride, N); test_ushort_ops (stride, ostride, N); test_short_ops (stride, ostride, N); test_uchar_ops (stride, ostride, N); test_char_ops (stride, ostride, N); test_complex_ops (stride, ostride, N); test_complex_float_ops (stride, ostride, N); test_complex_long_double_ops (stride, ostride, N); } test_text (stride, N); test_float_text (stride, N); #if HAVE_PRINTF_LONGDOUBLE test_long_double_text (stride, N); #endif test_ulong_text (stride, N); test_long_text (stride, N); test_uint_text (stride, N); test_int_text (stride, N); test_ushort_text (stride, N); test_short_text (stride, N); test_uchar_text (stride, N); test_char_text (stride, N); test_complex_text (stride, N); test_complex_float_text (stride, N); #if HAVE_PRINTF_LONGDOUBLE test_complex_long_double_text (stride, N); #endif test_file (stride, N); test_float_file (stride, N); test_long_double_file (stride, N); test_ulong_file (stride, N); test_long_file (stride, N); test_uint_file (stride, N); test_int_file (stride, N); test_ushort_file (stride, N); test_short_file (stride, N); test_uchar_file (stride, N); test_char_file (stride, N); test_complex_file (stride, N); test_complex_float_file (stride, N); test_complex_long_double_file (stride, N); } } test_alloc_zero_length (); test_float_alloc_zero_length (); test_long_double_alloc_zero_length (); test_ulong_alloc_zero_length (); test_long_alloc_zero_length (); test_uint_alloc_zero_length (); test_int_alloc_zero_length (); test_ushort_alloc_zero_length (); test_short_alloc_zero_length (); test_uchar_alloc_zero_length (); test_char_alloc_zero_length (); test_complex_alloc_zero_length (); test_complex_float_alloc_zero_length (); test_complex_long_double_alloc_zero_length (); test_calloc_zero_length (); test_float_calloc_zero_length (); test_long_double_calloc_zero_length (); test_ulong_calloc_zero_length (); test_long_calloc_zero_length (); test_uint_calloc_zero_length (); test_int_calloc_zero_length (); test_ushort_calloc_zero_length (); test_short_calloc_zero_length (); test_uchar_calloc_zero_length (); test_char_calloc_zero_length (); test_complex_calloc_zero_length (); test_complex_float_calloc_zero_length (); test_complex_long_double_calloc_zero_length (); #if GSL_RANGE_CHECK gsl_set_error_handler (&my_error_handler); for (N = 1; N < 1024; N *=2) { for (stride = 1; stride < 5 ; stride++) { test_trap (stride, N); test_float_trap (stride, N); test_long_double_trap (stride, N); test_ulong_trap (stride, N); test_long_trap (stride, N); test_uint_trap (stride, N); test_int_trap (stride, N); test_ushort_trap (stride, N); test_short_trap (stride, N); test_uchar_trap (stride, N); test_char_trap (stride, N); test_complex_trap (stride, N); test_complex_float_trap (stride, N); test_complex_long_double_trap (stride, N); } } #endif exit (gsl_test_summary ()); }
int main (int argc, const char *argv[]) { int rc; int sb; int sc; int sb2; int opt; size_t sz; int i; char any_address[128]; test_addr_from (socket_address, "ws", "127.0.0.1", get_test_port (argc, argv)); test_addr_from (any_address, "ws", "*", get_test_port (argc, argv)); /* Try closing bound but unconnected socket. */ sb = test_socket (AF_SP, NN_PAIR); test_bind (sb, any_address); test_close (sb); /* Try closing a TCP socket while it not connected. At the same time test specifying the local address for the connection. */ sc = test_socket (AF_SP, NN_PAIR); test_connect (sc, socket_address); test_close (sc); /* Open the socket anew. */ sc = test_socket (AF_SP, NN_PAIR); /* Check socket options. */ sz = sizeof (opt); rc = nn_getsockopt (sc, NN_WS, NN_WS_MSG_TYPE, &opt, &sz); errno_assert (rc == 0); nn_assert (sz == sizeof (opt)); nn_assert (opt == NN_WS_MSG_TYPE_BINARY); /* Default port 80 should be assumed if not explicitly declared. */ rc = nn_connect (sc, "ws://127.0.0.1"); errno_assert (rc >= 0); /* Try using invalid address strings. */ rc = nn_connect (sc, "ws://*:"); nn_assert (rc < 0); errno_assert (nn_errno () == EINVAL); rc = nn_connect (sc, "ws://*:1000000"); nn_assert (rc < 0); errno_assert (nn_errno () == EINVAL); rc = nn_connect (sc, "ws://*:some_port"); nn_assert (rc < 0); rc = nn_connect (sc, "ws://eth10000;127.0.0.1:5555"); nn_assert (rc < 0); errno_assert (nn_errno () == ENODEV); rc = nn_bind (sc, "ws://127.0.0.1:"); nn_assert (rc < 0); errno_assert (nn_errno () == EINVAL); rc = nn_bind (sc, "ws://127.0.0.1:1000000"); nn_assert (rc < 0); errno_assert (nn_errno () == EINVAL); rc = nn_bind (sc, "ws://eth10000:5555"); nn_assert (rc < 0); errno_assert (nn_errno () == ENODEV); rc = nn_connect (sc, "ws://:5555"); nn_assert (rc < 0); errno_assert (nn_errno () == EINVAL); rc = nn_connect (sc, "ws://-hostname:5555"); nn_assert (rc < 0); errno_assert (nn_errno () == EINVAL); rc = nn_connect (sc, "ws://abc.123.---.#:5555"); nn_assert (rc < 0); errno_assert (nn_errno () == EINVAL); rc = nn_connect (sc, "ws://[::1]:5555"); nn_assert (rc < 0); errno_assert (nn_errno () == EINVAL); rc = nn_connect (sc, "ws://abc.123.:5555"); nn_assert (rc < 0); errno_assert (nn_errno () == EINVAL); rc = nn_connect (sc, "ws://abc...123:5555"); nn_assert (rc < 0); errno_assert (nn_errno () == EINVAL); rc = nn_connect (sc, "ws://.123:5555"); nn_assert (rc < 0); errno_assert (nn_errno () == EINVAL); test_close (sc); sb = test_socket (AF_SP, NN_PAIR); test_bind (sb, socket_address); sc = test_socket (AF_SP, NN_PAIR); test_connect (sc, socket_address); /* Ping-pong test. */ for (i = 0; i != 100; ++i) { test_send (sc, "ABC"); test_recv (sb, "ABC"); test_send (sb, "DEF"); test_recv (sc, "DEF"); } /* Batch transfer test. */ for (i = 0; i != 100; ++i) { test_send (sc, "0123456789012345678901234567890123456789"); } for (i = 0; i != 100; ++i) { test_recv (sb, "0123456789012345678901234567890123456789"); } test_close (sc); test_close (sb); /* Test two sockets binding to the same address. */ sb = test_socket (AF_SP, NN_PAIR); test_bind (sb, socket_address); sb2 = test_socket (AF_SP, NN_PAIR); rc = nn_bind (sb2, socket_address); nn_assert (rc < 0); errno_assert (nn_errno () == EADDRINUSE); test_close(sb); test_close(sb2); /* Test that NN_RCVMAXSIZE can be -1, but not lower */ sb = test_socket (AF_SP, NN_PAIR); opt = -1; rc = nn_setsockopt (sb, NN_SOL_SOCKET, NN_RCVMAXSIZE, &opt, sizeof (opt)); nn_assert (rc >= 0); opt = -2; rc = nn_setsockopt (sb, NN_SOL_SOCKET, NN_RCVMAXSIZE, &opt, sizeof (opt)); nn_assert (rc < 0); errno_assert (nn_errno () == EINVAL); test_close (sb); /* Test NN_RCVMAXSIZE limit */ sb = test_socket (AF_SP, NN_PAIR); test_bind (sb, socket_address); sc = test_socket (AF_SP, NN_PAIR); test_connect (sc, socket_address); opt = 1000; test_setsockopt (sc, NN_SOL_SOCKET, NN_SNDTIMEO, &opt, sizeof (opt)); nn_assert (opt == 1000); opt = 1000; test_setsockopt (sb, NN_SOL_SOCKET, NN_RCVTIMEO, &opt, sizeof (opt)); nn_assert (opt == 1000); opt = 4; test_setsockopt (sb, NN_SOL_SOCKET, NN_RCVMAXSIZE, &opt, sizeof (opt)); test_send (sc, "ABC"); test_recv (sb, "ABC"); test_send (sc, "ABCD"); test_recv (sb, "ABCD"); test_send (sc, "ABCDE"); test_drop (sb, ETIMEDOUT); /* Increase the size limit, reconnect, then try sending again. The reason a reconnect is necessary is because after a protocol violation, the connecting socket will not continue automatic reconnection attempts. */ opt = 5; test_setsockopt (sb, NN_SOL_SOCKET, NN_RCVMAXSIZE, &opt, sizeof (opt)); test_connect (sc, socket_address); test_send (sc, "ABCDE"); test_recv (sb, "ABCDE"); test_close (sb); test_close (sc); test_text (); /* Test closing a socket that is waiting to connect. */ sc = test_socket (AF_SP, NN_PAIR); test_connect (sc, socket_address); nn_sleep (100); test_close (sc); return 0; }
virtual void onDrawContent(SkCanvas* canvas) { if (false) { // avoid bit rot, suppress warning test_strokerect(canvas); return; } if (false) { // avoid bit rot, suppress warning test_text(canvas); return; } #ifdef SK_DEBUG if (true) { SkRegion a, b, c; test_union_bug_1505668(&a, &b, &c); if (false) { // draw the result of the test SkPaint paint; canvas->translate(SkIntToScalar(10), SkIntToScalar(10)); paint.setColor(SK_ColorRED); paint_rgn(canvas, a, paint); paint.setColor(0x800000FF); paint_rgn(canvas, b, paint); paint.setColor(SK_ColorBLACK); paint.setStyle(SkPaint::kStroke_Style); // paint_rgn(canvas, c, paint); return; } } #endif const SkPoint origins[] = { { 30*SK_Scalar1, 50*SK_Scalar1 }, { 150*SK_Scalar1, 50*SK_Scalar1 }, }; this->drawPredicates(canvas, origins); static const struct { SkColor fColor; const char* fName; SkRegion::Op fOp; } gOps[] = { { SK_ColorBLACK, "Difference", SkRegion::kDifference_Op }, { SK_ColorRED, "Intersect", SkRegion::kIntersect_Op }, { 0xFF008800, "Union", SkRegion::kUnion_Op }, { SK_ColorBLUE, "XOR", SkRegion::kXOR_Op } }; SkPaint textPaint; textPaint.setAntiAlias(true); textPaint.setTextSize(SK_Scalar1*24); this->drawOrig(canvas, false); canvas->save(); canvas->translate(SkIntToScalar(200), 0); this->drawRgnOped(canvas, SkRegion::kUnion_Op, SK_ColorBLACK); canvas->restore(); canvas->translate(0, SkIntToScalar(200)); for (size_t op = 0; op < SK_ARRAY_COUNT(gOps); op++) { canvas->drawText(gOps[op].fName, strlen(gOps[op].fName), SkIntToScalar(75), SkIntToScalar(50), textPaint); this->drawRgnOped(canvas, gOps[op].fOp, gOps[op].fColor); canvas->save(); canvas->translate(0, SkIntToScalar(200)); this->drawPathOped(canvas, gOps[op].fOp, gOps[op].fColor); canvas->restore(); canvas->translate(SkIntToScalar(200), 0); } }