int main(int argc, char *argv[]) { test_one("", XML_END); test_one("<foo></foo>", XML_TAG_OPEN, "foo", XML_TAG_CLOSE, "foo", XML_END); test_one("<foo waldo=piep meh=\"huhu\"/>", XML_TAG_OPEN, "foo", XML_ATTRIBUTE_NAME, "waldo", XML_ATTRIBUTE_VALUE, "piep", XML_ATTRIBUTE_NAME, "meh", XML_ATTRIBUTE_VALUE, "huhu", XML_TAG_CLOSE_EMPTY, NULL, XML_END); test_one("xxxx\n" "<foo><?xml foo?> <!-- zzzz --> </foo>", XML_TEXT, "xxxx\n", XML_TAG_OPEN, "foo", XML_TEXT, " ", XML_TEXT, " ", XML_TAG_CLOSE, "foo", XML_END); return 0; }
int main() { test_one({}); test_one({0}); test_one({1}); test_one({0,1,2,3,4,5,6,7,8,9}); test_one({1,3,5,7,9,0,2,4,6,8}); }
void test_all(int n, int k) { test_one(n, k, stupid_select, "Stupid", 1); test_one(n, k, heap_select, "Heap", 1); test_one(n, k, median_select, "Median", 1); test_one(n, k, quick_select, "Quick", 10); }
static int testcase(void) { char *s1; char *s2; unsigned long i; s1 = memalign(128, SIZE); if (!s1) { perror("memalign"); exit(1); } s2 = memalign(128, SIZE); if (!s2) { perror("memalign"); exit(1); } srandom(1); for (i = 0; i < ITERATIONS; i++) { unsigned long j; unsigned long change; for (j = 0; j < SIZE; j++) s1[j] = random(); memcpy(s2, s1, SIZE); /* change one byte */ change = random() % SIZE; s2[change] = random() & 0xff; test_one(s1, s2); } srandom(1); for (i = 0; i < ITERATIONS; i++) { unsigned long j; unsigned long change; for (j = 0; j < SIZE; j++) s1[j] = random(); memcpy(s2, s1, SIZE); /* change multiple bytes, 1/8 of total */ for (j = 0; j < SIZE / 8; j++) { change = random() % SIZE; s2[change] = random() & 0xff; } test_one(s1, s2); } return 0; }
int main (int argc, char *argv[]) { printf ("enter main\n"); test_one (); test_one (); printf ("leave main\n"); return 0; }
fas::nanospan test( F& f, size_t count, size_t probe ) { fas::nanospan best = test_one( f, count); for (size_t i = 0 ; i < probe; ++i) { fas::nanospan current = test_one( f, count); if ( current < best ) best = current; } return best; }
void test(unsigned N) { test_one(N, 0); test_one(N, 1); test_one(N, 2); test_one(N, 3); test_one(N, N/2-1); test_one(N, N/2); test_one(N, N/2+1); test_one(N, N-3); test_one(N, N-2); test_one(N, N-1); }
static void test_fixed (void) { mpz_t r; mpz_init (r); /* Triggered a bug reported by Hanno Böck. */ mpz_set_str (r, "FFFFFFFF00000001000000000000000000000000FFFFFFFFFFFFFFFF001C2C00", 16); mpz_mul_2exp (r, r, 256); test_one ("p", &nettle_secp_256r1.p, r); test_one ("q", &nettle_secp_256r1.q, r); mpz_set_str (r, "ffffffff00000001fffffffeffffffffffffffffffffffffffffffc0000000000007ffffffffffffffffffffffffffff00000000000000000fffffffffffffff", 16); test_one ("p", &nettle_secp_256r1.p, r); test_one ("q", &nettle_secp_256r1.q, r); /* Triggered a bug reported by Hanno Böck. */ mpz_set_str (r, "4c9000000000000000000000000000000000000000000000004a604db486e000000000000000000000000000000000000000121025be29575adb2c8ffffffffffffffffffffffffffffffffffffffffffffffffffffffff", 16); test_one ("p", &nettle_secp_384r1.p, r); test_one ("q", &nettle_secp_384r1.q, r); /* Triggered a carry bug in development version. */ mpz_set_str (r, "e64a84643150260640e4677c19ffc4faef06042132b86af6e9ee33fe1850222e57a514d5f1d6d444008bb896a96a43d5629945e57548f5e12f66be132b24110cbb2df6d7d3dd3aaadc98b0bbf29573843ad72e57f59fc5d4f56cc599da18bb99", 16); test_one ("p", &nettle_secp_384r1.p, r); test_one ("q", &nettle_secp_384r1.q, r); mpz_clear (r); }
GLboolean test(void) { GLboolean all_pass = GL_TRUE; int npass = 0, total = 0; unsigned semantic, blend, logicop, vpmode, fpmode; unsigned vpmodes = 1 + !!piglit_is_extension_supported("GL_ARB_vertex_program"); unsigned fpmodes = 1 + !!piglit_is_extension_supported("GL_ARB_fragment_program"); unsigned vert_clamp, frag_clamp; glFogi(GL_FOG_MODE, GL_LINEAR); for (vert_clamp = 0; vert_clamp < (sanity ? 1 : 3); ++vert_clamp) for (frag_clamp = sanity ? 1 : 0; frag_clamp < (sanity ? 2 : 3); ++frag_clamp) for (semantic = 0; semantic < 2; ++semantic) for (blend = 0; blend < 4; ++blend) for (logicop = 0; logicop < 2; ++logicop) for (vpmode = 0; vpmode < vpmodes; ++vpmode) for (fpmode = 0; fpmode < fpmodes; ++fpmode) { GLboolean pass; if (!fpmode && semantic) continue; pass = test_one(vert_clamp, frag_clamp, semantic, blend, logicop, vpmode, fpmode); if (pass) { npass++; } else { #if 0 /* Enable this code to re-run the failed test. * It's easy to set a breakpoint here to start debugging. */ pass = test_one(vert_clamp, frag_clamp, semantic, blend, logicop, vpmode, fpmode); #endif } total++; all_pass = all_pass && pass; } printf("Summary: %i/%i passed.\n", npass, total); return all_pass; }
int main() { if (!(list = bert_list_create())) { test_fail("malloc failed"); } bert_data_t *data; if (!(data = bert_data_create_int(EXPECTED_ONE))) { test_fail("malloc failed"); } bert_list_append(list,data); if (!(data = bert_data_create_int(EXPECTED_TWO))) { test_fail("malloc failed"); } bert_list_append(list,data); test_one(); test_two(); bert_list_destroy(list); return 0; }
bool zTimeTest::execute(int index) { switch(index) { case 0: return test_one(); default: return false; } return false; }
result_list runner::test_range(files_iterator begin, files_iterator end, std::reference_wrapper<report_type> report) const { config defaults; result_list results; for (runner::files_iterator i = begin; i != end; i++) { runner::path_type const & file = *i; if (file.extension() == ".xml") { try { result_list r = test_one(file, defaults, report); std::move(r.begin(), r.end(), std::back_inserter(results)); } catch (std::exception const& ex) { result r; r.state = STATE_ERROR; r.name = file.string(); r.error_message = ex.what(); results.emplace_back(r); mapnik::util::apply_visitor(report_visitor(r), report.get()); } } } return results; }
static void test_handles (const char *name, void *(func) (void *, const char *), const char *suffix) { test_one (RTLD_DEFAULT, name, func, suffix); test_one (RTLD_NEXT, name, func, suffix); void *handle = dlopen (LIBC_SO, RTLD_LAZY); if (handle == NULL) { printf ("error: cannot dlopen %s: %s\n", LIBC_SO, dlerror ()); abort (); } test_one (handle, name, func, suffix); dlclose (handle); }
boolean test_all(unsigned verbose, FILE *fp) { const struct lp_type *src_type; const struct lp_type *dst_type; boolean success = TRUE; int error_count = 0; for(src_type = conv_types; src_type < &conv_types[num_types]; ++src_type) { for(dst_type = conv_types; dst_type < &conv_types[num_types]; ++dst_type) { if(src_type == dst_type) continue; if(!test_one(verbose, fp, *src_type, *dst_type)){ success = FALSE; ++error_count; } } } fprintf(stderr, "%d failures\n", error_count); return success; }
bool for_sparse_hes(void) { bool ok = true; ok &= test_one(); return ok; }
int main(void) { setvbuf(stdout, nullptr, _IONBF, 0); test_one(); return 0; }
int main(int argc, char *argv[]) { int r; r = test_one(true, true, false, false); assert_se(r >= 0); r = test_one(true, false, false, false); assert_se(r >= 0); r = test_one(false, true, false, false); assert_se(r >= 0); r = test_one(false, false, false, false); assert_se(r >= 0); r = test_one(true, true, true, true); assert_se(r >= 0); r = test_one(true, true, false, true); assert_se(r >= 0); r = test_one(true, true, true, false); assert_se(r == -EPERM); return EXIT_SUCCESS; }
bool torture_mangle(int dummy) { static struct cli_state *cli; int i; bool ret = True; printf("starting mangle test\n"); if (!torture_open_connection(&cli, 0)) { return False; } /* we will use an internal tdb to store the names we have used */ tdb = tdb_open(NULL, 100000, TDB_INTERNAL, 0, 0); if (!tdb) { printf("ERROR: Failed to open tdb\n"); return False; } cli_unlink(cli, "\\mangle_test\\*", FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN); cli_rmdir(cli, "\\mangle_test"); if (!NT_STATUS_IS_OK(cli_mkdir(cli, "\\mangle_test"))) { printf("ERROR: Failed to make directory\n"); return False; } for (i=0;i<torture_numops;i++) { fstring name; ZERO_STRUCT(name); gen_name(name); if (!test_one(cli, name)) { ret = False; break; } if (total && total % 100 == 0) { printf("collisions %u/%u - %.2f%% (%u failures)\r", collisions, total, (100.0*collisions) / total, failures); } } cli_unlink(cli, "\\mangle_test\\*", FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN); if (!NT_STATUS_IS_OK(cli_rmdir(cli, "\\mangle_test"))) { printf("ERROR: Failed to remove directory\n"); return False; } printf("\nTotal collisions %u/%u - %.2f%% (%u failures)\n", collisions, total, (100.0*collisions) / total, failures); torture_close_connection(cli); printf("mangle test finished\n"); return (ret && (failures == 0)); }
void main() { test_one(); test_two(); test_three(); test_four(); test_five(); test_six(); }
int main() { test_zero("strtonumtest: 0 test"); test_one("strtonumtest: -1 test"); test_badnum("strtonumtest: bad number test"); test_overflow("strtonumtest: overflow test"); test_minmax("strtonumtest: minmax test"); _exit(0); }
int main(int argc, char *argv[]) { test_one(DIGITS LETTERS DIGITS LETTERS); test_one("한국어한국어한국어한국어한국어한국어한국어한국어한국어한국어한국어한국어한국어한국어한국어한국어한국어한국어"); test_one("-日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国日本国"); test_one("中国中国中国中国中国中国中国中国中国中国中国中国中国中国中国中国中国中国中国中国中国中国-中国中国中国中国中国中国中国中国中国中国中国中国中国"); test_one("sÿstëmd sÿstëmd sÿstëmd sÿstëmd sÿstëmd sÿstëmd sÿstëmd sÿstëmd sÿstëmd sÿstëmd sÿstëmd sÿstëmd sÿstëmd"); test_one("🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮🐮"); test_one("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."); test_one("shórt"); return 0; }
int main() { printf("test hulib begin...\n"); WaveTable::getInstance()->load("wave_table.data"); WaveEyeTable::getInstance()->load("wave_eye_table.data"); //test_two_color(); test_one(); return 0; }
static void test_pair (const struct testcase_pair *pair) { double positive = 1234567.89; test_one ("%i", positive, pair->positive.i); test_one ("%n", positive, pair->positive.n); test_one ("%^i", positive, pair->positive.i_ungrouped); test_one ("%^n", positive, pair->positive.n_ungrouped); double negative = -1234567.89; test_one ("%i", negative, pair->negative.i); test_one ("%n", negative, pair->negative.n); test_one ("%^i", negative, pair->negative.i_ungrouped); test_one ("%^n", negative, pair->negative.n_ungrouped); }
boolean test_all(unsigned verbose, FILE *fp) { const unsigned *rgb_func; const unsigned *rgb_src_factor; const unsigned *rgb_dst_factor; const unsigned *alpha_func; const unsigned *alpha_src_factor; const unsigned *alpha_dst_factor; struct pipe_blend_state blend; enum vector_mode mode; const struct lp_type *type; bool success = TRUE; for(rgb_func = blend_funcs; rgb_func < &blend_funcs[num_funcs]; ++rgb_func) { for(alpha_func = blend_funcs; alpha_func < &blend_funcs[num_funcs]; ++alpha_func) { for(rgb_src_factor = blend_factors; rgb_src_factor < &blend_factors[num_factors]; ++rgb_src_factor) { for(rgb_dst_factor = blend_factors; rgb_dst_factor <= rgb_src_factor; ++rgb_dst_factor) { for(alpha_src_factor = blend_factors; alpha_src_factor < &blend_factors[num_factors]; ++alpha_src_factor) { for(alpha_dst_factor = blend_factors; alpha_dst_factor <= alpha_src_factor; ++alpha_dst_factor) { for(mode = 0; mode < 2; ++mode) { for(type = blend_types; type < &blend_types[num_types]; ++type) { if(*rgb_dst_factor == PIPE_BLENDFACTOR_SRC_ALPHA_SATURATE || *alpha_dst_factor == PIPE_BLENDFACTOR_SRC_ALPHA_SATURATE) continue; memset(&blend, 0, sizeof blend); blend.blend_enable = 1; blend.rgb_func = *rgb_func; blend.rgb_src_factor = *rgb_src_factor; blend.rgb_dst_factor = *rgb_dst_factor; blend.alpha_func = *alpha_func; blend.alpha_src_factor = *alpha_src_factor; blend.alpha_dst_factor = *alpha_dst_factor; blend.colormask = PIPE_MASK_RGBA; if(!test_one(verbose, fp, &blend, mode, *type)) success = FALSE; } } } } } } } } return success; }
static void handle_one(char *f, int flags) { int fd; Elf *elf; if ((fd = open(f, O_RDONLY)) >= 0) { if ((elf = elf_begin(fd, ELF_C_READ_MMAP, NULL)) != NULL) { test_one(f, elf, flags); elf_end(elf); } close(fd); } }
boolean test_some(unsigned verbose, FILE *fp, unsigned long n) { const unsigned *rgb_func; const unsigned *rgb_src_factor; const unsigned *rgb_dst_factor; const unsigned *alpha_func; const unsigned *alpha_src_factor; const unsigned *alpha_dst_factor; struct pipe_blend_state blend; enum vector_mode mode; const struct lp_type *type; unsigned long i; boolean success = TRUE; for(i = 0; i < n; ++i) { rgb_func = &blend_funcs[rand() % num_funcs]; alpha_func = &blend_funcs[rand() % num_funcs]; rgb_src_factor = &blend_factors[rand() % num_factors]; alpha_src_factor = &blend_factors[rand() % num_factors]; do { rgb_dst_factor = &blend_factors[rand() % num_factors]; } while(*rgb_dst_factor == PIPE_BLENDFACTOR_SRC_ALPHA_SATURATE); do { alpha_dst_factor = &blend_factors[rand() % num_factors]; } while(*alpha_dst_factor == PIPE_BLENDFACTOR_SRC_ALPHA_SATURATE); mode = rand() & 1; type = &blend_types[rand() % num_types]; memset(&blend, 0, sizeof blend); blend.rt[0].blend_enable = 1; blend.rt[0].rgb_func = *rgb_func; blend.rt[0].rgb_src_factor = *rgb_src_factor; blend.rt[0].rgb_dst_factor = *rgb_dst_factor; blend.rt[0].alpha_func = *alpha_func; blend.rt[0].alpha_src_factor = *alpha_src_factor; blend.rt[0].alpha_dst_factor = *alpha_dst_factor; blend.rt[0].colormask = PIPE_MASK_RGBA; if(!test_one(verbose, fp, &blend, mode, *type)) success = FALSE; } return success; }
int main(void) { int i; for (i = 0; i < ARRAY_SIZE(vectors); i++) { test_one(&vectors[i]); } test_big_vector(); putchar('\n'); return 0; }
boolean test_single(unsigned verbose, FILE *fp) { /* float, fixed, sign, norm, width, len */ struct lp_type f32x4_type = { TRUE, FALSE, TRUE, TRUE, 32, 4 }; struct lp_type ub8x4_type = { FALSE, FALSE, FALSE, TRUE, 8, 16 }; boolean success; success = test_one(verbose, fp, f32x4_type, ub8x4_type); return success; }
static int test_vphn(void) { static struct test *test; for (test = all_tests; test->descr; test++) { int ret; ret = test_one(test); test_finish(test->descr, ret); if (ret) return ret; } return 0; }
static void test_big_vector(void) { enum { SIZE = 1000000 }; struct test_vector vec = { NULL, SIZE, { 0x34, 0xAA, 0x97, 0x3C, 0xD4, 0xC4, 0xDA, 0xA4, 0xF6, 0x1E, 0xEB, 0x2B, 0xDB, 0xAD, 0x27, 0x31, 0x65, 0x34, 0x01, 0x6F } }; vec.data = xmalloc(SIZE); memset(vec.data, 'a', SIZE); test_one(&vec); free(vec.data); }