int main(int argc, char** argv) { // default arguments autopilot_parms.bearing_noise=fixed(0); autopilot_parms.target_noise=fixed(0.1); autopilot_parms.turn_speed=fixed(5.0); output_skip = 5; if (!parse_args(argc,argv)) { return 0; } plan_tests(NUM_WIND); for (int i=0; i<NUM_WIND; i++) { test_automc(5,i); } return exit_status(); }
int main(void) { plan_tests(7 + 20 + FULL_LEN * (1 + FULL_LEN*4) + CHAIN_LEN * (1 + CHAIN_LEN*2) + 12 + 32 + 7 + 2 + 2); test_trivial(); test_parallel(); test_full(); test_chain(); test_error(); test_traversal1(); test_shortcut1(); test_shortcut2(); test_negacycle(); return exit_status(); }
int main(int argc, char *argv[]) { unsigned int i; int flags[] = { NTDB_DEFAULT, NTDB_NOMMAP, NTDB_CONVERT }; NTDB_DATA key = ntdb_mkdata("hello", 5), data = ntdb_mkdata("world", 5); plan_tests(sizeof(flags) / sizeof(flags[0]) * 2 + 1); for (i = 0; i < sizeof(flags) / sizeof(flags[0]); i++) { ntdb = ntdb_open("api-95-read-only-during-parse.ntdb", flags[i]|MAYBE_NOSYNC, O_RDWR|O_CREAT|O_TRUNC, 0600, &tap_log_attr); ok1(ntdb_store(ntdb, key, data, NTDB_INSERT) == NTDB_SUCCESS); ok1(ntdb_parse_record(ntdb, key, parse, &data) == NTDB_SUCCESS); ntdb_close(ntdb); } ok1(tap_log_messages == 0); return exit_status(); }
int main(int argc, char *argv[]) { void *mem; plan_tests(7); mem = malloc(1179648); alloc_init(mem, 1179648); ok1(alloc_check(mem, 1179648)); ok1(alloc_get(mem, 1179648, 48, 16)); ok1(alloc_check(mem, 1179648)); ok1(alloc_get(mem, 1179648, 53, 16)); ok1(alloc_check(mem, 1179648)); ok1(alloc_get(mem, 1179648, 53, 16)); ok1(alloc_check(mem, 1179648)); free(mem); return exit_status(); }
int main(int argc, char *argv[]) { int x = 0, y = 0; plan_tests(9); ok1(check_type(argc, int) == 0); ok1(check_type(&argc, int *) == 0); ok1(check_types_match(argc, argc) == 0); ok1(check_types_match(argc, x) == 0); ok1(check_types_match(&argc, &x) == 0); ok1(check_type(x++, int) == 0); ok(x == 0, "check_type does not evaluate expression"); ok1(check_types_match(x++, y++) == 0); ok(x == 0 && y == 0, "check_types_match does not evaluate expressions"); return exit_status(); }
int main(int argc, char** argv) { // default arguments autopilot_parms.bearing_noise=fixed(0); autopilot_parms.target_noise=fixed(0.1); output_skip = 5; if (!parse_args(argc,argv)) { return 0; } unsigned i = rand()%NUM_WIND; plan_tests(6); // tests whether cruise efficiency is calculated correctly test_cruise_efficiency(3,i); return exit_status(); }
int main(int argc, char** argv) { #ifdef FIXED_MATH plan_tests(5); #else plan_tests(4); #endif test_normalise_err(100, 50); test_normalise_err(-100, 50); test_normalise_err(100, -50); test_normalise_err(-100, -50); #ifdef FIXED_MATH test_fixed_err(); #endif return exit_status(); }
int main(void) { int i; plan(28); char * test_nebargs[] = { "encryption=no server=localhost", "key=test12345 server=localhost", "encryption=no server=localhost export=log_queue:1:NEBCALLBACK_LOG_DATA", "encryption=no server=localhost export=log_queue:1:NEBCALLBACK_LOG_DATA export=proc_queue:0:NEBCALLBACK_PROCESS_DATA", }; int num = sizeof(test_nebargs) / sizeof(test_nebargs[0]); for(i=0;i<num;i++) { check_neb(test_nebargs[i]); } return exit_status(); }
int main(int argc, char **argv) { wp_vector org_wp = CreateOriginalWaypoints(); plan_tests(307); TestExtractParameters(); TestWinPilot(org_wp); TestSeeYou(org_wp); TestZander(org_wp); TestFS(org_wp); TestFS_UTM(org_wp); TestOzi(org_wp); TestCompeGPS(org_wp); TestCompeGPS_UTM(org_wp); return exit_status(); }
int main(int argc, char *argv[]) { unsigned int i, j; plan_tests(64 * 64 + 2); ok1(fls64(0) == 0); ok1(dumb_fls(0) == 0); for (i = 0; i < 64; i++) { for (j = 0; j < 64; j++) { uint64_t val = (1ULL << i) | (1ULL << j); ok(fls64(val) == dumb_fls(val), "%llu -> %u should be %u", (long long)val, fls64(val), dumb_fls(val)); } } return exit_status(); }
int main(void) { int i; struct tally *tally = tally_new(100); ssize_t min, max, mode; size_t err; max = (ssize_t)~(1ULL << (sizeof(max)*CHAR_BIT - 1)); min = (ssize_t)(1ULL << (sizeof(max)*CHAR_BIT - 1)); plan_tests(100 + 50 + 100 + 100 + 10); /* Simple mode test: should always be around 0 (we add that twice). */ for (i = 0; i < 100; i++) { tally_add(tally, i); tally_add(tally, -i); mode = tally_approx_mode(tally, &err); if (i < 50) ok1(err == 0); ok1(mode - (ssize_t)err <= 0 && mode + (ssize_t)err >= 0); } /* Works for big values too... */ for (i = 0; i < 100; i++) { tally_add(tally, max - i); tally_add(tally, min + 1 + i); mode = tally_approx_mode(tally, &err); ok1(mode - (ssize_t)err <= 0 && mode + (ssize_t)err >= 0); } free(tally); tally = tally_new(10); tally_add(tally, 0); for (i = 0; i < 100; i++) { tally_add(tally, i); mode = tally_approx_mode(tally, &err); if (i < 10) ok1(err == 0); ok1(mode - (ssize_t)err <= 0 && mode + (ssize_t)err >= 0); } return exit_status(); }
int main(int argc, char **argv) { char *path = NULL; int ret; struct state state = {}; if (argc < 2) { diag("Usage: path_to_sample_INI_file"); goto end; } path = utils_expand_path(argv[1]); if (!path) { fail("Failed to resolve sample INI file path") } plan_no_plan(); ret = config_get_section_entries(path, NULL, (config_entry_handler_cb)entry_handler, &state); ok(ret == 0, "Successfully opened a config file, registered to all sections"); ok(state.section_1 && state.section_2 && state.section_3 && state.section_global, "Processed entries from each sections"); ok(state.text_entry, "Text value parsed correctly"); memset(&state, 0, sizeof(struct state)); ret = config_get_section_entries(path, "section1", (config_entry_handler_cb)entry_handler, &state); ok(ret == 0, "Successfully opened a config file, registered to one section"); ok(state.section_1 && !state.section_2 && !state.section_3 && !state.section_global, "Processed an entry from section1 only"); ok(state.int_entry, "Int value parsed correctly"); memset(&state, 0, sizeof(struct state)); ret = config_get_section_entries(path, "", (config_entry_handler_cb)entry_handler, &state); ok(ret == 0, "Successfully opened a config file, registered to the global section"); ok(!state.section_1 && !state.section_2 && !state.section_3 && state.section_global, "Processed an entry from the global section only"); end: free(path); return exit_status(); }
int main(int argc, char *argv[]) { const int flags[] = { TDB_DEFAULT, TDB_NOMMAP, TDB_CONVERT, TDB_CONVERT | TDB_NOMMAP }; int i; struct tdb_context *tdb; TDB_DATA key, data; plan_tests(20); agent = prepare_external_agent(); if (!agent) err(1, "preparing agent"); unlock_callback = after_unlock; for (i = 0; i < sizeof(flags)/sizeof(flags[0]); i++) { diag("Test with %s and %s\n", (flags[i] & TDB_CONVERT) ? "CONVERT" : "DEFAULT", (flags[i] & TDB_NOMMAP) ? "no mmap" : "mmap"); unlink(TEST_DBNAME); tdb = tdb_open(TEST_DBNAME, flags[i], O_RDWR|O_CREAT|O_TRUNC, 0600, &tap_log_attr); ok1(tdb); opened = true; ok1(tdb_transaction_start(tdb) == 0); key.dsize = strlen("hi"); key.dptr = (void *)"hi"; data.dptr = (void *)"world"; data.dsize = strlen("world"); ok1(tdb_store(tdb, key, data, TDB_INSERT) == 0); ok1(tdb_transaction_commit(tdb) == 0); ok(!errors, "We had %u open errors", errors); opened = false; tdb_close(tdb); } return exit_status(); }
int main(int argc, char *argv[]) { int fd; char *p; char buf[] = "Hello world!"; plan_tests(5); failtest_init(argc, argv); fd = failtest_open("run-write-scratchpad", __FILE__, __LINE__, O_RDWR|O_CREAT, 0600); /* Child will fail, ignore. */ if (fd < 0) failtest_exit(0); if (write(fd, buf, strlen(buf)) != strlen(buf)) abort(); ok1(lseek(fd, 0, SEEK_CUR) == strlen(buf)); p = failtest_malloc(100, __FILE__, __LINE__); if (!p) { /* We are the child. Do a heap of writes. */ unsigned int i; for (i = 0; i < strlen(buf)+1; i++) if (failtest_write(fd, "x", 1, __FILE__, __LINE__) == 1) break; failtest_close(fd, __FILE__, __LINE__); failtest_exit(0); } /* Seek pointer should be left alone! */ ok1(lseek(fd, 0, SEEK_CUR) == strlen(buf)); /* Length should be restored. */ ok1(lseek(fd, 0, SEEK_END) == strlen(buf)); lseek(fd, 0, SEEK_SET); ok1(read(fd, buf, strlen(buf)) == strlen("Hello world!")); ok1(strcmp(buf, "Hello world!") == 0); failtest_close(fd, __FILE__, __LINE__); return exit_status(); }
int main(void) { char *parent, *c[4]; int i; plan_tests(11); parent = tal(NULL, char); ok1(parent); /* Zeroing allocations. */ for (i = 0; i < 4; i++) { c[i] = talz(parent, char); ok1(*c[i] == '\0'); tal_free(c[i]); } /* Array allocation. */ for (i = 0; i < 4; i++) { c[i] = tal_arr(parent, char, 4); strcpy(c[i], "abc"); tal_free(c[i]); } /* Zeroing array allocation. */ for (i = 0; i < 4; i++) { c[i] = tal_arrz(parent, char, 4); ok1(!c[i][0] && !c[i][1] && !c[i][2] && !c[i][3]); strcpy(c[i], "abc"); tal_free(c[i]); } /* Resizing. */ c[0] = tal_arrz(parent, char, 4); ok1(tal_resize(&c[0], 6)); strcpy(c[0], "hello"); tal_free(c[0]); ok1(talloc_total_blocks(parent) == 1); tal_free(parent); return exit_status(); }
int main(int argc, char** argv) { static const char hc_path[] = "tmp/map.xcm"; const char *map_path; if ((argc<2) || !strlen(argv[0])) { map_path = hc_path; } else { map_path = argv[0]; } ZZIP_DIR *dir = zzip_dir_open(map_path, nullptr); if (dir == nullptr) { fprintf(stderr, "Failed to open %s\n", map_path); return EXIT_FAILURE; } RasterMap map; NullOperationEnvironment operation; if (!LoadTerrainOverview(dir, map.GetTileCache(), operation)) { fprintf(stderr, "failed to load map\n"); zzip_dir_close(dir); return EXIT_FAILURE; } map.UpdateProjection(); SharedMutex mutex; do { UpdateTerrainTiles(dir, map.GetTileCache(), mutex, map.GetProjection(), map.GetMapCenter(), 100000); } while (map.IsDirty()); zzip_dir_close(dir); plan_tests(16*3); test_troute(map, 0, 0.1, 10000); test_troute(map, 0, 0, 10000); test_troute(map, 5.0, 1, 10000); return exit_status(); }
int main(int argc, char** argv) { if (!parse_args(argc,argv)) { return 0; } #define NUM_RANDOM 50 #define NUM_TYPE_MANIPS 50 plan_tests(NUM_TASKS+2+NUM_RANDOM+8+NUM_TYPE_MANIPS); GlidePolar glide_polar(fixed_two); Waypoints waypoints; setup_waypoints(waypoints); { TaskManager task_manager(waypoints); task_manager.SetGlidePolar(glide_polar); test_task_bad(task_manager,waypoints); } { for (unsigned i = 0; i < NUM_TYPE_MANIPS; i++) { TaskManager task_manager(waypoints); ok(test_task_type_manip(task_manager,waypoints, i+2), "construction: task type manip", 0); } } for (int i=0; i<NUM_TASKS+2; i++) { TaskManager task_manager(waypoints); task_manager.SetGlidePolar(glide_polar); ok(test_task(task_manager, waypoints, i),test_name("construction",i,0),0); } for (int i=0; i<NUM_RANDOM; i++) { TaskManager task_manager(waypoints); task_manager.SetGlidePolar(glide_polar); ok(test_task(task_manager, waypoints, 7),test_name("construction",7,0),0); } return exit_status(); }
int main(int argc, char *argv[]) { const int flags[] = { TDB_DEFAULT, TDB_CLEAR_IF_FIRST, TDB_NOMMAP, TDB_CLEAR_IF_FIRST | TDB_NOMMAP }; int i; struct tdb_context *tdb; TDB_DATA key, data; plan_tests(20); agent = prepare_external_agent(); unlock_callback = after_unlock; for (i = 0; i < sizeof(flags)/sizeof(flags[0]); i++) { clear_if_first = (flags[i] & TDB_CLEAR_IF_FIRST); diag("Test with %s and %s", clear_if_first ? "CLEAR" : "DEFAULT", (flags[i] & TDB_NOMMAP) ? "no mmap" : "mmap"); unlink(TEST_DBNAME); tdb = tdb_open_ex(TEST_DBNAME, 1024, flags[i], O_CREAT|O_TRUNC|O_RDWR, 0600, &taplogctx, NULL); ok1(tdb); opened = true; ok1(tdb_transaction_start(tdb) == 0); key.dsize = strlen("hi"); key.dptr = discard_const_p(uint8_t, "hi"); data.dptr = discard_const_p(uint8_t, "world"); data.dsize = strlen("world"); ok1(tdb_store(tdb, key, data, TDB_INSERT) == 0); ok1(tdb_transaction_commit(tdb) == 0); ok(!errors, "We had %u open errors", errors); opened = false; tdb_close(tdb); } return exit_status(); }
int main(void) { struct timers timers; struct timer t, *expired; /* This is how many tests you plan to run */ plan_tests(3); timers_init(&timers, timemono_from_usec(1364726722653919ULL)); timer_init(&t); timer_addmono(&timers, &t, timemono_from_usec(1364726722703919ULL)); ok1(!timers_expire(&timers, timemono_from_usec(1364726722653920ULL))); expired = timers_expire(&timers, timemono_from_usec(1364726725454187ULL)); ok1(expired == &t); ok1(!timers_expire(&timers, timemono_from_usec(1364726725454187ULL))); timers_cleanup(&timers); /* This exits depending on whether all tests passed */ return exit_status(); }
int main(void) { plan_tests(13); ok1(test_trivial("abcabba", "cbabac")); ok1(test_trivial("aaabbbcdaabcc", "aaabbcdaabeca")); ok1(test_trivial("aaaaaaaa", "bbbbbbbb")); ok1(test_trivial("aaaaaaaa", "")); ok1(test_trivial("", "bbbbbbbb")); ok1(test_trivial("", "")); ok1(test_trivial("aaaaaaaa", "aaaaaaaabbbbbbbb")); ok1(test_trivial("aaaaaaaa", "bbbbbbbbaaaaaaaa")); ok1(test_trivial("aaaaaaaabbbbbbbb", "aaaaaaaa")); ok1(test_trivial("aaaaaaaabbbbbbbb", "bbbbbbbb")); ok1(test_trivial("aaaaaaaabbbbbbbb", "bbbbbbbb")); ok1(test_trivial("abababababababab", "babababababababa")); ok1(test_trivial("aababcabcdabcde", "aababcabcdabcde")); return exit_status(); }
int main(int argc, char *argv[]) { unsigned int i, messages = 0; struct tdb_context *tdb; int flags[] = { TDB_DEFAULT, TDB_NOMMAP, TDB_CONVERT, TDB_NOMMAP|TDB_CONVERT, TDB_VERSION1, TDB_NOMMAP|TDB_VERSION1, TDB_CONVERT|TDB_VERSION1, TDB_NOMMAP|TDB_CONVERT|TDB_VERSION1 }; failtest_init(argc, argv); failtest_hook = block_repeat_failures; failtest_exit_check = exit_check_log; plan_tests(sizeof(flags) / sizeof(flags[0]) * 4); for (i = 0; i < sizeof(flags) / sizeof(flags[0]); i++) { tdb = tdb_open("run-35-convert.tdb", flags[i], O_RDWR|O_CREAT|O_TRUNC, 0600, &tap_log_attr); if (!ok1(tdb)) failtest_exit(exit_status()); tdb_close(tdb); /* If we say TDB_CONVERT, it must be converted */ tdb = tdb_open("run-35-convert.tdb", flags[i]|TDB_CONVERT, O_RDWR, 0600, &tap_log_attr); if (flags[i] & TDB_CONVERT) { if (!tdb) failtest_exit(exit_status()); ok1(tdb_get_flags(tdb) & TDB_CONVERT); tdb_close(tdb); } else { if (!ok1(!tdb && errno == EIO)) failtest_exit(exit_status()); ok1(tap_log_messages == ++messages); if (!ok1(log_last && strstr(log_last, "TDB_CONVERT"))) failtest_exit(exit_status()); } /* If don't say TDB_CONVERT, it *may* be converted */ tdb = tdb_open("run-35-convert.tdb", flags[i] & ~TDB_CONVERT, O_RDWR, 0600, &tap_log_attr); if (!tdb) failtest_exit(exit_status()); ok1(tdb_get_flags(tdb) == flags[i]); tdb_close(tdb); } failtest_exit(exit_status()); }
int main(void) { struct mydata a, b; /* This is how many tests you plan to run */ plan_tests(3); a.start = 0; a.end = 100; ok1(mydata_eq(&a, &a)); b = a; ok1(mydata_eq(&a, &b)); b.end++; ok1(!mydata_eq(&a, &b)); /* This exits depending on whether all tests passed */ return exit_status(); }
int main(int argc, char **argv) { ph_job_t timer; ph_unused_parameter(argc); ph_unused_parameter(argv); ph_library_init(); plan_tests(8); is(PH_OK, ph_nbio_init(0)); is(PH_OK, ph_job_init(&timer)); timer.callback = record_tick; last_tick = ph_time_now(); is(PH_OK, ph_job_set_timer_at(&timer, last_tick)); is(PH_OK, ph_sched_run()); return exit_status(); }
int main(int argc, char** argv) { // default arguments autopilot_parms.ideal(); if (!parse_args(argc,argv)) { return 0; } plan_tests(3); ok(test_airspace(20),"airspace 20",0); ok(test_airspace(100),"airspace 100",0); Airspaces airspaces; setup_airspaces(airspaces, GeoPoint(Angle::Zero(), Angle::Zero()), 20); ok(test_airspace_extra(airspaces),"airspace extra",0); return exit_status(); }
int main(int argc, char *argv[]) { struct htable ht; uint64_t val[NUM_VALS]; unsigned int i; plan_tests((NUM_VALS) * 2); for (i = 0; i < NUM_VALS; i++) val[i] = i; htable_init(&ht, hash, NULL); for (i = 0; i < NUM_VALS; i++) { ok1(ht.max >= i); ok1(ht.max <= i * 2); htable_add(&ht, hash(&val[i], NULL), &val[i]); } htable_clear(&ht); return exit_status(); }
int main(void) { setenv("hx", ".", 0); setvbuf(stdout, 0, _IOLBF, 0); struct { PAGENO inp, exp; } try_split[] = { {2,1}, {3,1}, {4,2}, {5,1}, {6,2}, {7,3} }; int i, ntry_split = sizeof try_split/sizeof*try_split; plan_tests(ntry_split); for (i = 0; i < ntry_split; ++i) { PAGENO act = _hxf2d(SPLIT_LO(_hxd2f(try_split[i].inp))); is(act, try_split[i].exp, "SPLIT_LO(%d)", try_split[i].inp); } return exit_status(); }
int main(int argc, char *argv[]) { unsigned int i; struct tdb_context *tdb; int flags[] = { TDB_INTERNAL, TDB_DEFAULT, TDB_NOMMAP, TDB_INTERNAL|TDB_CONVERT, TDB_CONVERT, TDB_NOMMAP|TDB_CONVERT }; plan_tests(sizeof(flags) / sizeof(flags[0]) * 2 + 1); for (i = 0; i < sizeof(flags) / sizeof(flags[0]); i++) { tdb = tdb_open("run-14-exists.tdb", flags[i], O_RDWR|O_CREAT|O_TRUNC, 0600, &tap_log_attr); if (ok1(tdb)) ok1(test_records(tdb)); tdb_close(tdb); } ok1(tap_log_messages == 0); return exit_status(); }
int main(int argc, char** argv) { output_skip = 60; range_threshold = 15000; autopilot_parms.bearing_noise = 25; replay_file = "test/data/9crx3101.igc"; waypoint_file = "test/data/benalla9.xcw"; if (!ParseArgs(argc,argv)) { return 0; } plan_tests(4); ok(test_replay_retrospective(),"replay retrospective",0); return exit_status(); }
int main(int argc, char **argv) { unsigned num_tests = 19 + 9 + PolarStore::Count(); // NOTE: Plausibility tests disabled for now since many fail if (0) num_tests += ARRAY_SIZE(performanceData) * 5; plan_tests(num_tests); TestBasic(); TestFileImport(); TestBuiltInPolars(); // NOTE: Plausibility tests disabled for now since many fail if (0) TestBuiltInPolarsPlausibility(); return exit_status(); }
int main(int argc, char** argv) { // default arguments autopilot_parms.SetRealistic(); if (!ParseArgs(argc,argv)) { return 0; } AircraftState dummy; TestFlightComponents components; components.aircraft_filter = new AircraftStateFilter(fixed(120)); components.aircraft_filter->Reset(dummy); plan_tests(1); ok(test_flight(components, 1,0,1.0,true),"basic flight test",0); delete components.aircraft_filter; return exit_status(); }