inline void error_impl(char const * msg, char const * file, int line, char const * function) { BOOST_LIGHTWEIGHT_TEST_OSTREAM << file << "(" << line << "): " << msg << " in function '" << function << "'" << std::endl; ++test_errors(); }
inline void throw_failed_impl(char const * excep, char const * file, int line, char const * function) { BOOST_LIGHTWEIGHT_TEST_OSTREAM << file << "(" << line << "): Exception '" << excep << "' not thrown in function '" << function << "'" << std::endl; ++test_errors(); }
inline void test_failed_impl(char const * expr, char const * file, int line, char const * function) { BOOST_LIGHTWEIGHT_TEST_OSTREAM << file << "(" << line << "): test '" << expr << "' failed in function '" << function << "'" << std::endl; ++test_errors(); }
int main() { test_errors(); test_basics(); test_add(); zisolate(); return 0; }
inline void run_test(const char* name) { test_name() = name; long errors_before = boost::asio::detail::test_errors(); Test(); if (test_errors() == errors_before) BOOST_ASIO_TEST_IOSTREAM << name << " passed" << std::endl; else BOOST_ASIO_TEST_IOSTREAM << name << " failed" << std::endl; }
template<class T, class U> inline void test_eq_impl( char const * expr1, char const * expr2, char const * file, int line, char const * function, T const & t, U const & u ) { if( t == u ) { } else { std::cerr << file << "(" << line << "): test '" << expr1 << " == " << expr2 << "' failed in function '" << function << "': " << "'" << t << "' != '" << u << "'" << std::endl; ++test_errors(); } }
template<class T, class U> inline void test_ne_impl( char const * expr1, char const * expr2, char const * file, int line, char const * function, T const & t, U const & u ) { if( t != u ) { } else { BOOST_LIGHTWEIGHT_TEST_OSTREAM << file << "(" << line << "): test '" << expr1 << " != " << expr2 << "' failed in function '" << function << "': " << "'" << t << "' == '" << u << "'" << std::endl; ++test_errors(); } }
inline void test_cstr_ne_impl( char const * expr1, char const * expr2, char const * file, int line, char const * function, char const * const t, char const * const u ) { if( std::strcmp(t, u) != 0 ) { report_errors_remind(); } else { BOOST_LIGHTWEIGHT_TEST_OSTREAM << file << "(" << line << "): test '" << expr1 << " == " << expr2 << "' failed in function '" << function << "': " << "'" << t << "' == '" << u << "'" << std::endl; ++test_errors(); } }
template<class T, class U> inline void test_eq_impl( char const * expr1, char const * expr2, char const * file, int line, char const * function, T const & t, U const & u ) { if( t == u ) { report_errors_remind(); } else { BOOST_LIGHTWEIGHT_TEST_OSTREAM << file << "(" << line << "): test '" << expr1 << " == " << expr2 << "' failed in function '" << function << "': " << "'" << test_output_impl(t) << "' != '" << test_output_impl(u) << "'" << std::endl; ++test_errors(); } }
template< class T > inline void test_trait_impl( char const * trait, void (*)( T ), bool expected, char const * file, int line, char const * function ) { if( T::value == expected ) { report_errors_remind(); } else { BOOST_LIGHTWEIGHT_TEST_OSTREAM << file << "(" << line << "): predicate '" << trait << "' [" << boost::core::demangled_name( BOOST_CORE_TYPEID(T) ) << "]" << " test failed in function '" << function << "' (should have been " << ( expected? "true": "false" ) << ")" << std::endl; ++test_errors(); } }
rtems_task Init (rtems_task_argument ignored) { puts("*** START OF TEST 28 ***" ); test_errors(); test_multiple_taskvars(); test_delete_as_side_effect(); test_delete_from_other_task(); starttask (1); starttask (2); starttask (3); test_out_of_memory(); rtems_task_suspend (RTEMS_SELF); }
void piglit_init(int argc, char **argv) { unsigned i; /* Parse first param. */ if (argc < 3) print_usage_and_exit(argv[0]); for (i = 0; i < ARRAY_SIZE(tests); i++) { if (strcmp(argv[1], tests[i].name) == 0) { test = &tests[i]; break; } } if (test == NULL) print_usage_and_exit(argv[0]); /* Parse options. */ for (i = 3; i < argc; i++) { if (strcmp(argv[i], "interface") == 0) use_interface_blocks = true; else print_usage_and_exit(argv[0]); } /* Parse second param and setup test */ if (strcmp(argv[2], "error") == 0) { report_result(test_errors()); } else if (strcmp(argv[2], "get") == 0) { link_shaders(true); report_result(test_gets()); } else if (strcmp(argv[2], "run") == 0) { link_shaders(true); /* Testing will occur in piglit_display */ } else if (strcmp(argv[2], "run-no-fs") == 0) { link_shaders(false); report_result(test_xfb(true)); } else { print_usage_and_exit(argv[0]); } }
int main(int argc, char **argv) { int failed = 0; last_condition = pn_condition(); RUN_ARGV_TEST(failed, t, test_inactive(&t)); RUN_ARGV_TEST(failed, t, test_interrupt_timeout(&t)); RUN_ARGV_TEST(failed, t, test_errors(&t)); RUN_ARGV_TEST(failed, t, test_proton_1586(&t)); RUN_ARGV_TEST(failed, t, test_client_server(&t)); RUN_ARGV_TEST(failed, t, test_connection_wake(&t)); RUN_ARGV_TEST(failed, t, test_ipv4_ipv6(&t)); RUN_ARGV_TEST(failed, t, test_release_free(&t)); #if !defined(_WIN32) RUN_ARGV_TEST(failed, t, test_ssl(&t)); #endif RUN_ARGV_TEST(failed, t, test_proactor_addr(&t)); RUN_ARGV_TEST(failed, t, test_parse_addr(&t)); RUN_ARGV_TEST(failed, t, test_netaddr(&t)); RUN_ARGV_TEST(failed, t, test_disconnect(&t)); RUN_ARGV_TEST(failed, t, test_abort(&t)); RUN_ARGV_TEST(failed, t, test_refuse(&t)); RUN_ARGV_TEST(failed, t, test_message_stream(&t)); pn_condition_free(last_condition); return failed; }
inline void test_failed_impl(char const * expr, char const * file, int line, char const * function) { std::cerr << file << "(" << line << "): test '" << expr << "' failed in function '" << function << "'" << std::endl; ++test_errors(); }
int main (void) { #if HAVE_DECL_ALARM /* Declare failure if test takes too long, by using default abort caused by SIGALRM. */ int alarm_value = 5; signal (SIGALRM, SIG_DFL); alarm (alarm_value); #endif { char buffer[256]; int result; errno = 0; result = ptsname_r (-1, buffer, sizeof buffer); ASSERT (result != 0); ASSERT (result == errno); ASSERT (errno == EBADF || errno == ENOTTY); } { int fd; char buffer[256]; int result; /* Open the controlling tty of the current process. */ fd = open ("/dev/tty", O_RDONLY); if (fd < 0) { fprintf (stderr, "Skipping test: cannot open controlling tty\n"); return 77; } result = ptsname_r (fd, buffer, sizeof buffer); /* The result is usually NULL, because /dev/tty is a slave, not a master. */ if (result == 0) { ASSERT (memcmp (buffer, "/dev/", 5) == 0); } close (fd); } #if defined __sun /* Solaris has BSD-style /dev/pty[p-r][0-9a-f] files, but the function ptsname() does not work on them. */ { int fd; char buffer[256]; int result; /* Open a pty master. */ fd = open ("/dev/ptmx", O_RDWR | O_NOCTTY); if (fd < 0) { fprintf (stderr, "Skipping test: cannot open pseudo-terminal\n"); return 77; } result = ptsname_r (fd, buffer, sizeof buffer); ASSERT (result == 0); ASSERT (memcmp (buffer, "/dev/pts/", 9) == 0); test_errors (fd, buffer); close (fd); } #elif defined _AIX /* AIX has BSD-style /dev/ptyp[0-9a-f] files, but the modern way to open a pty is to go through /dev/ptc. */ { int fd; char buffer[256]; int result; /* Open a pty master. */ fd = open ("/dev/ptc", O_RDWR | O_NOCTTY); if (fd < 0) { fprintf (stderr, "Skipping test: cannot open pseudo-terminal\n"); return 77; } result = ptsname_r (fd, buffer, sizeof buffer); ASSERT (result == 0); ASSERT (memcmp (buffer, "/dev/pts/", 9) == 0); test_errors (fd, buffer); /* This call hangs on AIX. */ close (fd); } #else /* Try various master names of Mac OS X: /dev/pty[p-w][0-9a-f] */ { int char1; int char2; for (char1 = 'p'; char1 <= 'w'; char1++) for (char2 = '0'; char2 <= 'f'; (char2 == '9' ? char2 = 'a' : char2++)) { char master_name[32]; int fd; sprintf (master_name, "/dev/pty%c%c", char1, char2); fd = open (master_name, O_RDONLY); if (fd >= 0) { char buffer[256]; int result; char slave_name[32]; result = ptsname_r (fd, buffer, sizeof buffer); ASSERT (result == 0); sprintf (slave_name, "/dev/tty%c%c", char1, char2); ASSERT (same_slave (buffer, slave_name)); test_errors (fd, buffer); /* This call hangs on AIX. */ close (fd); } } } /* Try various master names of *BSD: /dev/pty[p-sP-S][0-9a-v] */ { int upper; int char1; int char2; for (upper = 0; upper <= 1; upper++) for (char1 = (upper ? 'P' : 'p'); char1 <= (upper ? 'S' : 's'); char1++) for (char2 = '0'; char2 <= 'v'; (char2 == '9' ? char2 = 'a' : char2++)) { char master_name[32]; int fd; sprintf (master_name, "/dev/pty%c%c", char1, char2); fd = open (master_name, O_RDONLY); if (fd >= 0) { char buffer[256]; int result; char slave_name[32]; result = ptsname_r (fd, buffer, sizeof buffer); ASSERT (result == 0); sprintf (slave_name, "/dev/tty%c%c", char1, char2); ASSERT (same_slave (buffer, slave_name)); test_errors (fd, buffer); close (fd); } } } #endif return 0; }
inline void error_impl(char const * msg, char const * file, int line, char const * function) { std::cerr << file << "(" << line << "): " << msg << " in function '" << function << "'" << std::endl; ++test_errors(); }
int main(int argc, char **argv) { const char *error_msg; parse_command_line(argc, argv); // also load data error_msg = check_parameter(prob,¶m); if(error_msg) { fprintf(stderr,"Error: %s\n",error_msg); exit(1); } std::vector< std::pair<double, double> > test_errors(nb_runs); std::vector< std::pair<double, double> > train_errors(nb_runs); double trn_mean=0; double tst_mean=0; double mse_trn_mean=0; double mse_tst_mean=0; int *start = NULL; // perform runs for (int run=0; run<nb_runs; run++) { if ((trnsz>=prob->l) || (trnsz<=0)) { fprintf(stderr,"\nRun %d (from 0 to %d)\n", run, prob->l-1); //train model_=train(prob, ¶m); // test test_errors[run]=do_predict(tprob, model_); train_errors[run]=do_predict(prob, model_); } else { // select all the splits before optimizing if(run == 0) { start = Malloc(int,nb_runs); for (int run2=0; run2<nb_runs; run2++) start[run2] = (rand() % (prob->l-trnsz)); } // select examples fprintf(stderr,"\nRun %d (from %d to %d)\n", run, start[run], start[run]+trnsz-1); struct problem* subprob=extract_subprob(prob, start[run], trnsz); //train model_=train(subprob, ¶m); // test test_errors[run]=do_predict(tprob, model_); train_errors[run]=do_predict(subprob, model_); free(subprob->y); free(subprob->x); } tst_mean+=test_errors[run].first; printf("Test classification ERROR = %g\n",test_errors[run].first); trn_mean+=train_errors[run].first; printf("Train classification ERROR = %g\n",train_errors[run].first); mse_tst_mean+=test_errors[run].second; printf("Test normalized ACCURACY (ET requirement) = %g\n",test_errors[run].second); mse_trn_mean+=train_errors[run].second; printf("Train normalized ACCURACY (ET requirement) = %g\n",train_errors[run].second); //destroy model free_and_destroy_model(&model_); destroy_param(¶m); }
int main() { #define NELEM 9 char ok[] = "", mismatch[] = " (WARNING, mismatch)", *s; int i, k, lat, lng, nFail1 = 0, nFail2 = 0, stat[361], status; double freq, img[361][NELEM], lat1, lng1, phi[361], pixel1[361][NELEM], pixel2[361][NELEM], r, resid, residmax, theta[361], time, world1[361][NELEM], world2[361][NELEM]; struct wcsprm *wcs; printf("Testing closure of WCSLIB world coordinate transformation " "routines (twcs.c)\n" "----------------------------------------------------------" "-----------------\n"); /* List status return messages. */ printf("\nList of wcs status return values:\n"); for (status = 1; status <= 13; status++) { printf("%4d: %s.\n", status, wcs_errmsg[status]); } printf("\nSize of data types (bytes):\n"); printf(" char:%5"MODZ"u\n", sizeof(char)); printf(" short int:%5"MODZ"u\n", sizeof(short int)); printf(" int:%5"MODZ"u\n", sizeof(int)); printf(" long int:%5"MODZ"u\n", sizeof(long int)); printf(" float:%5"MODZ"u\n", sizeof(float)); printf(" double:%5"MODZ"u\n", sizeof(double)); printf(" char *:%5"MODZ"u\n", sizeof(char *)); printf(" char (*)[72]:%5"MODZ"u\n", sizeof(char (*)[72])); printf(" int *:%5"MODZ"u\n", sizeof(int *)); printf(" float *:%5"MODZ"u\n", sizeof(float *)); printf(" double *:%5"MODZ"u\n", sizeof(double *)); printf("struct pvcard *:%5"MODZ"u\n", sizeof(struct pvcard *)); printf("struct pscard *:%5"MODZ"u\n", sizeof(struct pscard *)); printf("\nSize of structs (bytes/ints):\n"); s = (sizeof(struct celprm) == sizeof(int)*CELLEN) ? ok : mismatch; printf(" celprm:%5"MODZ"u /%4"MODZ"u%s\n", sizeof(struct celprm), CELLEN, s); s = (sizeof(struct fitskey) == sizeof(int)*KEYLEN) ? ok : mismatch; printf(" fitskey:%5"MODZ"u /%4"MODZ"u%s\n", sizeof(struct fitskey), KEYLEN, s); s = (sizeof(struct fitskeyid) == sizeof(int)*KEYIDLEN) ? ok : mismatch; printf(" fitskeyid:%5"MODZ"u /%4"MODZ"u%s\n", sizeof(struct fitskeyid), KEYIDLEN, s); s = (sizeof(struct linprm) == sizeof(int)*LINLEN) ? ok : mismatch; printf(" linprm:%5"MODZ"u /%4"MODZ"u%s\n", sizeof(struct linprm), LINLEN, s); s = (sizeof(struct prjprm) == sizeof(int)*PRJLEN) ? ok : mismatch; printf(" prjprm:%5"MODZ"u /%4"MODZ"u%s\n", sizeof(struct prjprm), PRJLEN, s); s = (sizeof(struct spcprm) == sizeof(int)*SPCLEN) ? ok : mismatch; printf(" spcprm:%5"MODZ"u /%4"MODZ"u%s\n", sizeof(struct spcprm), SPCLEN, s); s = (sizeof(struct spxprm) == sizeof(int)*SPXLEN) ? ok : mismatch; printf(" spxprm:%5"MODZ"u /%4"MODZ"u%s\n", sizeof(struct spxprm), SPXLEN, s); s = (sizeof(struct tabprm) == sizeof(int)*TABLEN) ? ok : mismatch; printf(" tabprm:%5"MODZ"u /%4"MODZ"u%s\n", sizeof(struct tabprm), TABLEN, s); s = (sizeof(struct wcserr) == sizeof(int)*ERRLEN) ? ok : mismatch; printf(" wcserr:%5"MODZ"u /%4"MODZ"u%s\n", sizeof(struct wcserr), ERRLEN, s); s = (sizeof(struct wcsprm) == sizeof(int)*WCSLEN) ? ok : mismatch; printf(" wcsprm:%5"MODZ"u /%4"MODZ"u%s\n", sizeof(struct wcsprm), WCSLEN, s); /* Set the PVi_ma keyvalues for the longitude axis. */ /*----------------------------------------------------------*/ /* For test purposes, these are set so that the fiducial */ /* native coordinates are at the native pole, i.e. so that */ /* (phi0,theta0) = (0,90), but without any fiducial offset, */ /* i.e. iwith PVi_0a == 0 (by default). */ /*----------------------------------------------------------*/ PV[0].i = 4; /* Longitude is on axis 4. */ PV[0].m = 1; /* Parameter number 1. */ PV[0].value = 0.0; /* Fiducial native longitude. */ PV[1].i = 4; /* Longitude is on axis 4. */ PV[1].m = 2; /* Parameter number 2. */ PV[1].value = 90.0; /* Fiducial native latitude. */ /* Set the PVi_m keyvaluess for the latitude axis. */ PV[2].i = 2; /* Latitude is on axis 2. */ PV[2].m = 1; /* Parameter number 1. */ PV[2].value = -30.0; /* PVi_1. */ /* The following routine simulates the actions of a FITS header parser. */ wcs = malloc(sizeof(struct wcsprm)); wcs->flag = -1; parser(wcs); printf("\nReporting tolerance %5.1g pixel.\n", tol); /* Initialize non-celestial world coordinates. */ time = 1.0; freq = 1.42040595e9 - 180.0 * 62500.0; for (k = 0; k < 361; k++) { world1[k][0] = 0.0; world1[k][1] = 0.0; world1[k][2] = 0.0; world1[k][3] = 0.0; world1[k][2] = time; time *= 1.01; world1[k][wcs->spec] = 2.99792458e8 / freq; freq += 62500.0; } residmax = 0.0; for (lat = 90; lat >= -90; lat--) { lat1 = (double)lat; for (lng = -180, k = 0; lng <= 180; lng++, k++) { lng1 = (double)lng; world1[k][wcs->lng] = lng1; world1[k][wcs->lat] = lat1; } if (wcss2p(wcs, 361, NELEM, world1[0], phi, theta, img[0], pixel1[0], stat)) { printf(" At wcss2p#1 with lat1 == %f\n", lat1); wcsperr(wcs, " "); continue; } if (wcsp2s(wcs, 361, NELEM, pixel1[0], img[0], phi, theta, world2[0], stat)) { printf(" At wcsp2s with lat1 == %f\n", lat1); wcsperr(wcs, " "); continue; } if (wcss2p(wcs, 361, NELEM, world2[0], phi, theta, img[0], pixel2[0], stat)) { printf(" At wcss2p#2 with lat1 == %f\n", lat1); wcsperr(wcs, " "); continue; } for (k = 0; k < 361; k++) { resid = 0.0; for (i = 0; i < NAXIS; i++) { r = pixel2[k][i] - pixel1[k][i]; resid += r*r; } resid = sqrt(resid); if (resid > residmax) residmax = resid; if (resid > tol) { nFail1++; printf("\nClosure error:\n" "world1:%18.12f%18.12f%18.12f%18.12f\n" "pixel1:%18.12f%18.12f%18.12f%18.12f\n" "world2:%18.12f%18.12f%18.12f%18.12f\n" "pixel2:%18.12f%18.12f%18.12f%18.12f\n", world1[k][0], world1[k][1], world1[k][2], world1[k][3], pixel1[k][0], pixel1[k][1], pixel1[k][2], pixel1[k][3], world2[k][0], world2[k][1], world2[k][2], world2[k][3], pixel2[k][0], pixel2[k][1], pixel2[k][2], pixel2[k][3]); } } } printf("wcsp2s/wcss2p: Maximum closure residual = %.1e pixel.\n", residmax); /* Test wcserr and wcsprintf() as well. */ nFail2 = 0; wcsprintf_set(stdout); wcsprintf("\n\nIGNORE messages marked with 'OK', they test wcserr " "(and wcsprintf):\n"); wcserr_enable(1); /* Test 1. */ wcs->pv[2].value = UNDEFINED; status = wcsset(wcs); nFail2 += check_error(wcs, status, WCSERR_BAD_PARAM, "Invalid parameter value"); nFail2 += test_errors(); if (nFail1 || nFail2) { if (nFail1) { printf("\nFAIL: %d closure residuals exceed reporting tolerance.\n", nFail1); } if (nFail2) { printf("FAIL: %d error messages differ from that expected.\n", nFail2); } } else { printf("\nPASS: All closure residuals are within reporting tolerance.\n"); printf("PASS: All error messages reported as expected.\n"); } /* Clean up. */ wcsfree(wcs); free(wcs); return nFail1 + nFail2; }
void test_all_with_impl(FormattedOutputFunction& output, char const * file, int line, char const * function, InputIterator1 first_begin, InputIterator1 first_end, InputIterator2 second_begin, InputIterator2 second_end, BinaryPredicate predicate) { InputIterator1 first_it = first_begin; InputIterator2 second_it = second_begin; typename std::iterator_traits<InputIterator1>::difference_type first_index = 0; typename std::iterator_traits<InputIterator2>::difference_type second_index = 0; std::size_t error_count = 0; const std::size_t max_count = 8; do { while ((first_it != first_end) && (second_it != second_end) && predicate(*first_it, *second_it)) { ++first_it; ++second_it; ++first_index; ++second_index; } if ((first_it == first_end) || (second_it == second_end)) { break; // do-while } if (error_count == 0) { output << file << "(" << line << "): Container contents differ in function '" << function << "':"; } else if (error_count >= max_count) { output << " ..."; break; } output << " [" << first_index << "]"; ++first_it; ++second_it; ++first_index; ++second_index; ++error_count; } while (first_it != first_end); first_index += std::distance(first_it, first_end); second_index += std::distance(second_it, second_end); if (first_index != second_index) { if (error_count == 0) { output << file << "(" << line << "): Container sizes differ in function '" << function << "': size(" << first_index << ") != size(" << second_index << ")"; } else { output << " [*] size(" << first_index << ") != size(" << second_index << ")"; } ++error_count; } if (error_count == 0) { report_errors_remind(); } else { output << std::endl; ++test_errors(); } }
static void test_group(void) { test_basics(); test_errors(); }