NOX::Abstract::Group::ReturnType NOX::Belos::Group::applyJacobianInverseMultiVector( NOX::Parameter::List& params, const NOX::Abstract::MultiVector& input, NOX::Abstract::MultiVector& result) const { // Cast away const on input NOX::Abstract::MultiVector& nonConstInput = const_cast<NOX::Abstract::MultiVector&>(input); // Create Belos Jacobian Operator NOX::Belos::JacobianOperator belosJacOp(*grpPtr); // Create Belos Preconditioner Operator NOX::Belos::PreconditionOperator belosPrecOp(*grpPtr, params); // Create Belos MultiVec's for input, result NOX::Belos::MultiVector belosInput(nonConstInput); NOX::Belos::MultiVector belosResult(result); // Create LinearProblemManager ::Belos::LinearProblemManager<double> belosProblem(&belosJacOp, &belosResult, &belosInput); belosProblem.SetRightPrec(&belosPrecOp); // Parse parameter list int maxits = params.getParameter("Max Iterations", 400); double tol = params.getParameter("Tolerance", 1.0e-6); int length = params.getParameter("Size of Krylov Subspace", 300); int numrestarts = params.getParameter("Number of Restarts", 20); int maxblocksize = params.getParameter("Maximum block size", 10); std::string method = params.getParameter("Belos Solver", "GMRES"); int verbLevel = params.getParameter("Verbosity Level", 1); // Create status tests ::Belos::StatusTestMaxIters<double> test1(maxits); ::Belos::StatusTestMaxRestarts<double> test2(numrestarts); ::Belos::StatusTestCombo<double> belosTest( ::Belos::StatusTestCombo<double>::OR, test1, test2 ); ::Belos::StatusTestResNorm<double> test3( tol ); test3.DefineScaleForm(::Belos::StatusTestResNorm<double>::NormOfPrecInitRes, ::Belos::TwoNorm ); belosTest.AddStatusTest( test3 ); // Set block size int blocksize = input.numVectors(); if (blocksize > maxblocksize) blocksize = maxblocksize; belosProblem.SetBlockSize(blocksize); // Create output manager ::Belos::OutputManager<double> belosOutputManager(myPID, verbLevel); if (method == "GMRES") { ::Belos::BlockGmres<double> belosGMRES(belosProblem, belosTest, belosOutputManager, length); belosGMRES.Solve(); } else if (method == "CG") { ::Belos::BlockCG<double> belosCG(belosProblem, belosTest, belosOutputManager); belosCG.Solve(); } else { std::cout << "ERROR: NOX::Belos::Group::applyJacobianInverseMultiVector" << std::endl << "\"Belos Solver\" parameter \"" << method << "\" is invalid!" << std::endl; throw "NOX Error"; } ::Belos::StatusType status = belosTest.GetStatus(); if (status == ::Belos::Unconverged) return NOX::Abstract::Group::NotConverged; else if (status == ::Belos::Converged) return NOX::Abstract::Group::Ok; else return NOX::Abstract::Group::Failed; }
NOMIPS16 int main () { v2sf a, b, c, d; int i, j; /* c.eq.ps */ a = (v2sf) {11, 22}; b = (v2sf) {33, 44}; c = (v2sf) {55, 66}; d = (v2sf) {77, 88}; i = 0; j = 0; if (__builtin_mips_any_c_eq_4s(a, b, c, d) != i) abort (); if (__builtin_mips_all_c_eq_4s(a, b, c, d) != j) abort (); /* c.eq.ps */ a = (v2sf) {11, 22}; b = (v2sf) {11, 44}; c = (v2sf) {55, 66}; d = (v2sf) {77, 88}; i = 1; j = 0; if (__builtin_mips_any_c_eq_4s(a, b, c, d) != i) abort (); if (__builtin_mips_all_c_eq_4s(a, b, c, d) != j) abort (); /* c.eq.ps */ a = (v2sf) {11, 22}; b = (v2sf) {33, 22}; c = (v2sf) {55, 66}; d = (v2sf) {77, 88}; i = 1; j = 0; if (__builtin_mips_any_c_eq_4s(a, b, c, d) != i) abort (); if (__builtin_mips_all_c_eq_4s(a, b, c, d) != j) abort (); /* c.eq.ps */ a = (v2sf) {11, 22}; b = (v2sf) {33, 44}; c = (v2sf) {55, 66}; d = (v2sf) {55, 88}; i = 1; j = 0; if (__builtin_mips_any_c_eq_4s(a, b, c, d) != i) abort (); if (__builtin_mips_all_c_eq_4s(a, b, c, d) != j) abort (); /* c.eq.ps */ a = (v2sf) {11, 22}; b = (v2sf) {33, 44}; c = (v2sf) {55, 66}; d = (v2sf) {77, 66}; i = 1; j = 0; if (__builtin_mips_any_c_eq_4s(a, b, c, d) != i) abort (); if (__builtin_mips_all_c_eq_4s(a, b, c, d) != j) abort (); /* c.eq.ps */ a = (v2sf) {11, 22}; b = (v2sf) {11, 22}; c = (v2sf) {55, 66}; d = (v2sf) {55, 66}; i = 1; j = 1; if (__builtin_mips_any_c_eq_4s(a, b, c, d) != i) abort (); if (__builtin_mips_all_c_eq_4s(a, b, c, d) != j) abort (); /* Test all comparisons */ a = (v2sf) {11, 33}; b = (v2sf) {33, 11}; c = (v2sf) {55, 66}; d = (v2sf) {55, 88}; i = test0 (a, b, c, d); if (i != 0) abort (); i = test1 (a, b, c, d); if (i != 0) abort (); i = test2 (a, b, c, d); if (i != 0) abort (); i = test3 (a, b, c, d); if (i != 0) abort (); i = test4 (a, b, c, d); if (i != 1) abort (); i = test5 (a, b, c, d); if (i != 0) abort (); i = test6 (a, b, c, d); if (i != 1) abort (); i = test7 (a, b, c, d); if (i != 0) abort (); i = test8 (a, b, c, d); if (i != 1) abort (); i = test9 (a, b, c, d); if (i != 0) abort (); i = test10 (a, b, c, d); if (i != 1) abort (); i = test11 (a, b, c, d); if (i != 0) abort (); i = test12 (a, b, c, d); if (i != 1) abort (); i = test13 (a, b, c, d); if (i != 0) abort (); i = test14 (a, b, c, d); if (i != 1) abort (); i = test15 (a, b, c, d); if (i != 0) abort (); i = test16 (a, b, c, d); if (i != 0) abort (); i = test17 (a, b, c, d); if (i != 0) abort (); i = test18 (a, b, c, d); if (i != 0) abort (); i = test19 (a, b, c, d); if (i != 0) abort (); i = test20 (a, b, c, d); if (i != 1) abort (); i = test21 (a, b, c, d); if (i != 0) abort (); i = test22 (a, b, c, d); if (i != 1) abort (); i = test23 (a, b, c, d); if (i != 0) abort (); i = test24 (a, b, c, d); if (i != 1) abort (); i = test25 (a, b, c, d); if (i != 0) abort (); i = test26 (a, b, c, d); if (i != 1) abort (); i = test27 (a, b, c, d); if (i != 0) abort (); i = test28 (a, b, c, d); if (i != 1) abort (); i = test29 (a, b, c, d); if (i != 0) abort (); i = test30 (a, b, c, d); if (i != 1) abort (); i = test31 (a, b, c, d); if (i != 0) abort (); /* Reversed arguments */ i = test0 (b, a, d, c); if (i != 0) abort (); i = test1 (b, a, d, c); if (i != 0) abort (); i = test2 (b, a, d, c); if (i != 0) abort (); i = test3 (b, a, d, c); if (i != 0) abort (); i = test4 (b, a, d, c); if (i != 1) abort (); i = test5 (b, a, d, c); if (i != 0) abort (); i = test6 (b, a, d, c); if (i != 1) abort (); i = test7 (b, a, d, c); if (i != 0) abort (); i = test8 (b, a, d, c); if (i != 1) abort (); i = test9 (b, a, d, c); if (i != 0) abort (); i = test10 (b, a, d, c); if (i != 1) abort (); i = test11 (b, a, d, c); if (i != 0) abort (); i = test12 (b, a, d, c); if (i != 1) abort (); i = test13 (b, a, d, c); if (i != 0) abort (); i = test14 (b, a, d, c); if (i != 1) abort (); i = test15 (b, a, d, c); if (i != 0) abort (); i = test16 (b, a, d, c); if (i != 0) abort (); i = test17 (b, a, d, c); if (i != 0) abort (); i = test18 (b, a, d, c); if (i != 0) abort (); i = test19 (b, a, d, c); if (i != 0) abort (); i = test20 (b, a, d, c); if (i != 1) abort (); i = test21 (b, a, d, c); if (i != 0) abort (); i = test22 (b, a, d, c); if (i != 1) abort (); i = test23 (b, a, d, c); if (i != 0) abort (); i = test24 (b, a, d, c); if (i != 1) abort (); i = test25 (b, a, d, c); if (i != 0) abort (); i = test26 (b, a, d, c); if (i != 1) abort (); i = test27 (b, a, d, c); if (i != 0) abort (); i = test28 (b, a, d, c); if (i != 1) abort (); i = test29 (b, a, d, c); if (i != 0) abort (); i = test30 (b, a, d, c); if (i != 1) abort (); i = test31 (b, a, d, c); if (i != 0) abort (); #ifndef __FAST_MATH__ /* Test all comparisons */ a = (v2sf) {qnan, qnan}; b = (v2sf) {33, 11}; c = (v2sf) {qnan, qnan}; d = (v2sf) {55, 88}; i = test0 (a, b, c, d); if (i != 0) abort (); i = test1 (a, b, c, d); if (i != 0) abort (); i = test2 (a, b, c, d); if (i != 1) abort (); i = test3 (a, b, c, d); if (i != 1) abort (); i = test4 (a, b, c, d); if (i != 0) abort (); i = test5 (a, b, c, d); if (i != 0) abort (); i = test6 (a, b, c, d); if (i != 1) abort (); i = test7 (a, b, c, d); if (i != 1) abort (); i = test8 (a, b, c, d); if (i != 0) abort (); i = test9 (a, b, c, d); if (i != 0) abort (); i = test10 (a, b, c, d); if (i != 1) abort (); i = test11 (a, b, c, d); if (i != 1) abort (); i = test12 (a, b, c, d); if (i != 0) abort (); i = test13 (a, b, c, d); if (i != 0) abort (); i = test14 (a, b, c, d); if (i != 1) abort (); i = test15 (a, b, c, d); if (i != 1) abort (); i = test16 (a, b, c, d); if (i != 0) abort (); i = test17 (a, b, c, d); if (i != 0) abort (); i = test18 (a, b, c, d); if (i != 1) abort (); i = test19 (a, b, c, d); if (i != 1) abort (); i = test20 (a, b, c, d); if (i != 0) abort (); i = test21 (a, b, c, d); if (i != 0) abort (); i = test22 (a, b, c, d); if (i != 1) abort (); i = test23 (a, b, c, d); if (i != 1) abort (); i = test24 (a, b, c, d); if (i != 0) abort (); i = test25 (a, b, c, d); if (i != 0) abort (); i = test26 (a, b, c, d); if (i != 1) abort (); i = test27 (a, b, c, d); if (i != 1) abort (); i = test28 (a, b, c, d); if (i != 0) abort (); i = test29 (a, b, c, d); if (i != 0) abort (); i = test30 (a, b, c, d); if (i != 1) abort (); i = test31 (a, b, c, d); if (i != 1) abort (); #endif printf ("Test Passes\n"); exit (0); }
int main (int argc, char* argv[]) { opal_init(&argc, &argv); test_out = stderr; /* run the tests */ fprintf(test_out, "executing test1\n"); if (test1()) { fprintf(test_out, "Test1 succeeded\n"); } else { fprintf(test_out, "Test1 failed\n"); } fprintf(test_out, "executing test2\n"); if (test2()) { fprintf(test_out, "Test2 succeeded\n"); } else { fprintf(test_out, "Test2 failed\n"); } fprintf(test_out, "executing test3\n"); if (test3()) { fprintf(test_out, "Test3 succeeded\n"); } else { fprintf(test_out, "Test3 failed\n"); } fprintf(test_out, "executing test4\n"); if (test4()) { fprintf(test_out, "Test4 succeeded\n"); } else { fprintf(test_out, "Test4 failed\n"); } fprintf(test_out, "executing test5\n"); if (test5()) { fprintf(test_out, "Test5 succeeded\n"); } else { fprintf(test_out, "Test5 failed\n"); } fprintf(test_out, "executing test6\n"); if (test6()) { fprintf(test_out, "Test6 succeeded\n"); } else { fprintf(test_out, "Test6 failed\n"); } fprintf(test_out, "executing test7\n"); if (test7()) { fprintf(test_out, "Test7 succeeded\n"); } else { fprintf(test_out, "Test7 failed\n"); } fprintf(test_out, "executing test8\n"); if (test8()) { fprintf(test_out, "Test8 succeeded\n"); } else { fprintf(test_out, "Test8 failed\n"); } fprintf(test_out, "executing test9\n"); if (test9()) { fprintf(test_out, "Test9 succeeded\n"); } else { fprintf(test_out, "opal_dss test9 failed\n"); } fprintf(test_out, "executing test11\n"); if (test11()) { fprintf(test_out, "Test11 succeeded\n"); } else { fprintf(test_out, "opal_dss test11 failed\n"); } fprintf(test_out, "executing test12\n"); if (test12()) { fprintf(test_out, "Test12 succeeded\n"); } else { fprintf(test_out, "opal_dss test12 failed\n"); } fprintf(test_out, "executing test13\n"); if (test13()) { fprintf(test_out, "Test13 succeeded\n"); } else { fprintf(test_out, "opal_dss test13 failed\n"); } fclose(test_out); opal_finalize(); return(0); }
int main(){ long start, end, total; double each; long record[8]; puts(" --- [ Benchmarking Procedure Call ] --- "); total = 0; puts(" - Running with 0 argument"); for (int i = 0; i < TIMES; i++){ start = rdtsc(); test0(); end = rdtsc(); total += end - start; } each = total * 1.0 / TIMES ; printf(" Time to run %d iteration : %ld \n", TIMES, total); printf(" Average ReadOverhead : %f \n", each); record[0] = each; total = 0; puts(" - Running with 1 argument"); for (int i = 0; i < TIMES; i++){ start = rdtsc(); test1(0); end = rdtsc(); total += end - start; } each = total * 1.0 / TIMES ; printf(" Time to run %d iteration : %ld \n", TIMES, total); printf(" Average ReadOverhead : %f \n", each); record[1] = each; total = 0; puts(" - Running with 2 argument"); for (int i = 0; i < TIMES; i++){ start = rdtsc(); test2(0, 0); end = rdtsc(); total += end - start; } each = total * 1.0 / TIMES ; printf(" Time to run %d iteration : %ld \n", TIMES, total); printf(" Average ReadOverhead : %f \n", each); record[2] = each; total = 0; puts(" - Running with 3 argument"); for (int i = 0; i < TIMES; i++){ start = rdtsc(); test3(0, 0, 0); end = rdtsc(); total += end - start; } each = total * 1.0 / TIMES ; printf(" Time to run %d iteration : %ld \n", TIMES, total); printf(" Average ReadOverhead : %f \n", each); record[3] = each; total = 0; puts(" - Running with 4 argument"); for (int i = 0; i < TIMES; i++){ start = rdtsc(); test4(0, 0, 0, 0); end = rdtsc(); total += end - start; } each = total * 1.0 / TIMES ; printf(" Time to run %d iteration : %ld \n", TIMES, total); printf(" Average ReadOverhead : %f \n", each); record[4] = each; total = 0; puts(" - Running with 5 argument"); for (int i = 0; i < TIMES; i++){ start = rdtsc(); test5(0, 0, 0, 0, 0); end = rdtsc(); total += end - start; } each = total * 1.0 / TIMES ; printf(" Time to run %d iteration : %ld \n", TIMES, total); printf(" Average ReadOverhead : %f \n", each); record[5] = each; total = 0; puts(" - Running with 6 argument"); for (int i = 0; i < TIMES; i++){ start = rdtsc(); test6(0, 0, 0, 0, 0, 0); end = rdtsc(); total += end - start; } each = total * 1.0 / TIMES ; printf(" Time to run %d iteration : %ld \n", TIMES, total); printf(" Average ReadOverhead : %f \n", each); record[6] = each; total = 0; puts(" - Running with 7 argument"); for (int i = 0; i < TIMES; i++){ start = rdtsc(); test7(0, 0, 0, 0, 0, 0, 0); end = rdtsc(); total += end - start; } each = total * 1.0 / TIMES ; printf(" Time to run %d iteration : %ld \n", TIMES, total); printf(" Average ReadOverhead : %f \n", each); record[7] = each; puts(" - Final ... "); }
int main(void) { srand(time(NULL)); test3(); return 0; }
void ElGamal_TestInstantiations() { ElGamalEncryptor test1(1, 1, 1); ElGamalDecryptor test2(NullRNG(), 123); ElGamalEncryptor test3(test2); }
int main(int argc, const char* argv[]) { int n = 0; #if 0 { HANDLE out = GetStdHandle(STD_OUTPUT_HANDLE); DuplicateHandle(GetCurrentProcess(), out, GetCurrentProcess(), &out, 0, FALSE, DUPLICATE_SAME_ACCESS | DUPLICATE_CLOSE_SOURCE); SetStdHandle(STD_OUTPUT_HANDLE, out); } { HANDLE out = GetStdHandle(STD_ERROR_HANDLE); DuplicateHandle(GetCurrentProcess(), out, GetCurrentProcess(), &out, 0, FALSE, DUPLICATE_SAME_ACCESS | DUPLICATE_CLOSE_SOURCE); SetStdHandle(STD_ERROR_HANDLE, out); } #endif if(argc == 2) { n = atoi(argv[1]); } else if(argc == 3 && strcmp(argv[1], "run") == 0) { n = atoi(argv[2]); } /* Check arguments. */ if(((n >= 1 && n <= 8) || n == 108) && argc == 3) { /* This is the child process for a requested test number. */ switch (n) { case 1: return test1(argc, argv); case 2: return test2(argc, argv); case 3: return test3(argc, argv); case 4: return test4(argc, argv); case 5: return test5(argc, argv); case 6: test6(argc, argv); return 0; case 7: return test7(argc, argv); case 8: return test8(argc, argv); case 108: return test8_grandchild(argc, argv); } fprintf(stderr, "Invalid test number %d.\n", n); return 1; } else if(n >= 1 && n <= 8) { /* This is the parent process for a requested test number. */ int states[8] = { kwsysProcess_State_Exited, kwsysProcess_State_Exited, kwsysProcess_State_Expired, kwsysProcess_State_Exception, kwsysProcess_State_Exited, kwsysProcess_State_Expired, kwsysProcess_State_Exited, kwsysProcess_State_Exited }; int exceptions[8] = { kwsysProcess_Exception_None, kwsysProcess_Exception_None, kwsysProcess_Exception_None, kwsysProcess_Exception_Fault, kwsysProcess_Exception_None, kwsysProcess_Exception_None, kwsysProcess_Exception_None, kwsysProcess_Exception_None }; int values[8] = {0, 123, 1, 1, 0, 0, 0, 0}; int outputs[8] = {1, 1, 1, 1, 1, 0, 1, 1}; int delays[8] = {0, 0, 0, 0, 0, 1, 0, 0}; double timeouts[8] = {10, 10, 10, 30, 30, 10, -1, 10}; int polls[8] = {0, 0, 0, 0, 0, 0, 1, 0}; int repeat[8] = {2, 1, 1, 1, 1, 1, 1, 1}; int r; const char* cmd[4]; #ifdef _WIN32 char* argv0 = 0; if(n == 0 && (argv0 = strdup(argv[0]))) { /* Try converting to forward slashes to see if it works. */ char* c; for(c=argv0; *c; ++c) { if(*c == '\\') { *c = '/'; } } cmd[0] = argv0; } else { cmd[0] = argv[0]; } #else cmd[0] = argv[0]; #endif cmd[1] = "run"; cmd[2] = argv[1]; cmd[3] = 0; fprintf(stdout, "Output on stdout before test %d.\n", n); fprintf(stderr, "Output on stderr before test %d.\n", n); fflush(stdout); fflush(stderr); r = runChild(cmd, states[n-1], exceptions[n-1], values[n-1], 0, outputs[n-1], delays[n-1], timeouts[n-1], polls[n-1], repeat[n-1], 0); fprintf(stdout, "Output on stdout after test %d.\n", n); fprintf(stderr, "Output on stderr after test %d.\n", n); fflush(stdout); fflush(stderr); #if _WIN32 if(argv0) { free(argv0); } #endif return r; } else if(argc > 2 && strcmp(argv[1], "0") == 0) { /* This is the special debugging test to run a given command line. */ const char** cmd = argv+2; int state = kwsysProcess_State_Exited; int exception = kwsysProcess_Exception_None; int value = 0; double timeout = 0; int r = runChild(cmd, state, exception, value, 0, 1, 0, timeout, 0, 1, 0); return r; } else { /* Improper usage. */ fprintf(stdout, "Usage: %s <test number>\n", argv[0]); return 1; } }
int main (void) { mp_rnd_t rnd; mp_prec_t p; MPFR_TEST_USE_RANDS (); tests_start_mpfr (); p = (randlimb () % 200)+ MPFR_PREC_MIN; RND_LOOP (rnd) { test3 (mpfr_add, "mpfr_add", p, rnd); test3 (mpfr_sub, "mpfr_sub", p, rnd); test3 (mpfr_mul, "mpfr_mul", p, rnd); test3 (mpfr_div, "mpfr_div", p, rnd); test3 (mpfr_agm, "mpfr_agm", p, rnd); test3 (mpfr_min, "mpfr_min", p, rnd); test3 (mpfr_max, "mpfr_max", p, rnd); test3 (reldiff_wrapper, "mpfr_reldiff", p, rnd); test2a (mpfr_round, "mpfr_round", p); test2a (mpfr_ceil, "mpfr_ceil", p); test2a (mpfr_floor, "mpfr_floor", p); test2a (mpfr_trunc, "mpfr_trunc", p); test2ui (mpfr_add_ui, "mpfr_add_ui", p, rnd); test2ui (mpfr_mul_2exp, "mpfr_mul_2exp", p, rnd); test2ui (mpfr_mul_ui, "mpfr_mul_ui", p, rnd); test2ui (mpfr_pow_ui, "mpfr_pow_ui", p, rnd); test2ui (mpfr_sub_ui, "mpfr_sub_ui", p, rnd); test2ui (mpfr_div_2exp, "mpfr_div_2exp", p, rnd); test2ui (mpfr_div_ui, "mpfr_div_ui", p, rnd); testui2 (mpfr_ui_div, "mpfr_ui_div", p, rnd); testui2 (mpfr_ui_sub, "mpfr_ui_sub", p, rnd); testui2 (mpfr_ui_pow, "mpfr_ui_pow", p, rnd); test2 (mpfr_sqr, "mpfr_sqr", p, rnd); test2 (mpfr_sqrt, "mpfr_sqrt", p, rnd); test2 (mpfr_abs, "mpfr_abs", p, rnd); test2 (mpfr_neg, "mpfr_neg", p, rnd); test2 (mpfr_log, "mpfr_log", p, rnd); test2 (mpfr_log2, "mpfr_log2", p, rnd); test2 (mpfr_log10, "mpfr_log10", p, rnd); test2 (mpfr_log1p, "mpfr_log1p", p, rnd); test2 (mpfr_exp, "mpfr_exp", p, rnd); test2 (mpfr_exp2, "mpfr_exp2", p, rnd); test2 (mpfr_exp10, "mpfr_exp10", p, rnd); test2 (mpfr_expm1, "mpfr_expm1", p, rnd); test2 (mpfr_eint, "mpfr_eint", p, rnd); test2 (mpfr_sinh, "mpfr_sinh", p, rnd); test2 (mpfr_cosh, "mpfr_cosh", p, rnd); test2 (mpfr_tanh, "mpfr_tanh", p, rnd); test2 (mpfr_asinh, "mpfr_asinh", p, rnd); test2 (mpfr_acosh, "mpfr_acosh", p, rnd); test2 (mpfr_atanh, "mpfr_atanh", p, rnd); test2 (mpfr_asin, "mpfr_asin", p, rnd); test2 (mpfr_acos, "mpfr_acos", p, rnd); test2 (mpfr_atan, "mpfr_atan", p, rnd); test2 (mpfr_cos, "mpfr_cos", p, rnd); test2 (mpfr_sin, "mpfr_sin", p, rnd); test2 (mpfr_tan, "mpfr_tan", p, rnd); test2 (mpfr_sec, "mpfr_sec", p, rnd); test2 (mpfr_csc, "mpfr_csc", p, rnd); test2 (mpfr_cot, "mpfr_cot", p, rnd); test2 (mpfr_erf, "mpfr_erf", p, rnd); test2 (mpfr_erfc, "mpfr_erfc", p, rnd); test2 (mpfr_j0, "mpfr_j0", p, rnd); test2 (mpfr_j1, "mpfr_j1", p, rnd); test2 (mpfr_zeta, "mpfr_zeta", p, rnd); test2 (mpfr_gamma, "mpfr_gamma", p, rnd); test2 (mpfr_rint, "mpfr_rint", p, rnd); test2 (mpfr_frac, "mpfr_frac", p, rnd); test3 (mpfr_pow, "mpfr_pow", p, rnd); test3 (mpfr_atan2, "mpfr_atan2", p, rnd); test4 (mpfr_fma, "mpfr_fma", p, rnd); } tests_end_mpfr (); return 0; }
void test3(unsigned sx,unsigned sy) { for(unsigned y=1; y<=sy ;y++) test3(sx,sy,y); }
int main() { char line[256]; char args[4][64]; /* It mainly calls ComputerThink(maxdepth) to calculate to desired ply */ char s[256]; int from; int dest; int i; hashRndInit(); startgame (); maxDepth = 6; /* Max depth to search */ MOVE moveBuf[200]; MOVE theBest; int movecnt; /* Belka */ puts (" \n Kitteneitor version June 5th 2013 by Emilio Diaz \n =================================================\n\n"); puts (" Help overview:"); puts (" making a move: e.g. e2e4, c7c5, a7a8q, e1g1 etc."); puts (" d ............ displaying current board"); puts (" on ........... forcing the engine to move"); puts (" sd <n> ....... setting depth to <n> plies"); puts (" undo ......... taking back last move (ply)"); puts (" quit ......... quit console application \n\n"); /* Belka */ side = WHITE; computerSide = BLACK; /* Human is white side */ hdp = 0; /* Current move order */ for (;;) { fflush (stdout); if (side == computerSide) { /* Computer's turn */ theBest = ComputerThink (maxDepth); if (theBest.type_of_move > 8) printf ("type of move the best %d \n", theBest.type_of_move); makeMove (theBest); /* Just the move without pawn crown */ printf("move %c%d%c%d", 'a' + COL(theBest.from), 8 - ROW(theBest.from), 'a' + COL(theBest.dest), 8 - ROW(theBest.dest)); /* Check whether it's a crown */ switch (theBest.type_of_move) { case MOVE_TYPE_PROMOTION_TO_QUEEN: printf("q\n"); break; case MOVE_TYPE_PROMOTION_TO_ROOK: printf("r\n"); break; case MOVE_TYPE_PROMOTION_TO_BISHOP: printf("b\n"); break; case MOVE_TYPE_PROMOTION_TO_KNIGHT: printf("n\n"); break; default: printf("\n"); } /* end switch */ printBoard (); printf ("Castle rights: %d\n", castle); fflush (stdout); continue; } printf ("k> "); /* Get user input */ if (!fgets (line, 256, stdin)) return 0; if (line[0] == '\n') continue; sscanf (line, "%s", s); // if (scanf ("%s", s) == EOF) /* Shut down the program */ // return 0; if (!strcmp (s, "d")) { printBoard (); continue; } if (!strcmp (s, "test1")) { test1 (); printBoard(); continue; } if (!strcmp (s, "test2")) { test2 (); printBoard(); continue; } if (!strcmp (s, "test3")) { test3 (); printBoard(); continue; } if (!strcmp (s, "test4")) { test4 (); printBoard(); continue; } if (!strcmp (s, "test5")) { test5 (); printBoard(); continue; } if (!strcmp (s, "test6")) { test6 (); printBoard(); continue; } if (!strcmp (s, "test7")) { test7 (); printBoard(); continue; } if (!strcmp (s, "test8")) { test8 (); printBoard(); continue; } if (!strcmp (s, "test9")) { test9 (); printBoard(); continue; } if (!strcmp (s, "test10")) { test10 (); printBoard(); continue; } if (!strcmp (s, "test11")) { test11 (); printBoard(); continue; } if (!strcmp (s, "test12")) { test12 (); printBoard(); continue; } if (!strcmp (s, "test13")) { test13 (); printBoard(); continue; } if (!strcmp (s, "test14")) { test14 (); printBoard(); continue; } if (!strcmp (s, "testMoveGen")) //Belka: McKenzie test position { testMoveGen(); printBoard(); continue; } if (!strcmp (s, "testEvalSym")) //Belka: McKenzie test position { testEvalSym(); continue; } if (!strcmp (s, "countNodes")) { countNodes(); continue; } if (!strcmp (s, "testWhitePassedPawns")) { testWhitePassedPawns (); continue; } if (!strcmp (s, "testBlackPassedPawns")) { testBlackPassedPawns (); continue; } if (!strcmp (s, "testWhiteDoubledPawns")) { testWhiteDoubledPawns (); continue; } if (!strcmp (s, "testBlackDoubledPawns")) { testBlackDoubledPawns (); continue; } if (!strcmp (s, "testIsIsolatedPawnWhite")) { testIsIsolatedPawnWhite (); continue; } if (!strcmp (s, "testIsIsolatedPawnBlack")) { testIsIsolatedPawnBlack (); continue; } if (!strcmp (s, "showPawnsInfo")) { showPawnsInfo (); continue; } if (!strcmp (s, "testisSqProtectedByAPawn")) { testisSqProtectedByAPawn(); continue; } // if (!strcmp (s, "testIsSqProtectedByAKnight")) // { // testIsSqProtectedByAKnight(); // continue; // } // if (!strcmp (s, "testIsSqProtectedByABishop")) // { // testIsSqProtectedByABishop(); // continue; // } if (!strcmp (s, "testOpenCols")) { testOpenCols(); continue; } if (!strcmp (s, "undo")) { takeBack (); printBoard (); computerSide = (WHITE + BLACK) - computerSide; continue; } if (!strcmp(s,"setboard")) { strcpy(fenBuf, ""); sscanf(line, "setboard %s %s %s %s", args[0],args[1],args[2],args[3]); strcat(fenBuf, args[0]); strcat(fenBuf, args[1]); strcat(fenBuf, args[2]); strcat(fenBuf, args[3]); setBoard(fenBuf); continue; } if (!strcmp (s, "xboard")) { xboard (); return 0; } if (!strcmp (s, "on")) { computerSide = side; continue; } if (!strcmp (s, "pass")) { side = (WHITE + BLACK) - side; computerSide = (WHITE + BLACK) - side; continue; } if (!strcmp (s, "sd")) { sscanf (line, "sd %d", &maxDepth); continue; } // if (!strcmp (s, "fen")) // { // strcpy (fenstring, ""); // sscanf (linea, "fen %s %s %s %s", args[0], args[1], args[2], // args[3]); // strcat (fenstring, args[0]); // strcat (fenstring, args[1]); // strcat (fenstring, args[2]); // strcat (fenstring, args[3]); // fen (fenstring); // } if (!strcmp (s, "perft")) { sscanf (line, "perft %d", &maxDepth); clock_t start; clock_t stop; double t = 0.0; /* Start timer */ start = clock (); U64 count = perft (maxDepth); /* Stop timer */ stop = clock (); t = (double) (stop - start) / CLOCKS_PER_SEC; // printf ("nodes = %'llu\n", count); printf ("nodes = %8" PRId64 "\n", count); // Belka printf ("time = %.2f s\n", t); continue; } if (!strcmp (s, "quit")) { printf ("Good bye!\n"); return 0; } /* Maybe the user entered a move? */ from = s[0] - 'a'; from += 8 * (8 - (s[1] - '0')); dest = s[2] - 'a'; dest += 8 * (8 - (s[3] - '0')); ply = 0; movecnt = genMoves (side, moveBuf); /* Loop through the moves to see whether it's legal */ for (i = 0; i < movecnt; i++) if (moveBuf[i].from == from && moveBuf[i].dest == dest) { /* Promotion move? */ if (piece[from] == PAWN && (dest < 8 || dest > 55)) { switch (s[4]) { case 'q': moveBuf[i].type_of_move = MOVE_TYPE_PROMOTION_TO_QUEEN; break; case 'r': moveBuf[i].type_of_move = MOVE_TYPE_PROMOTION_TO_ROOK; break; case 'b': moveBuf[i].type_of_move = MOVE_TYPE_PROMOTION_TO_BISHOP; break; case 'n': moveBuf[i].type_of_move = MOVE_TYPE_PROMOTION_TO_KNIGHT; break; default: puts("Promoting to a McGuffin..., I'll give you a queen"); moveBuf[i].type_of_move = MOVE_TYPE_PROMOTION_TO_QUEEN; } } if (!makeMove (moveBuf[i])) { takeBack (); printf ("Illegal move.\n"); } break; } printBoard (); } }
int main(int argc, char *argv[]) { { AdvancedStringContainer a; a << AdvancedString(""); std::vector<AdvancedStringContainer> res; AdvancedStringContainer e; e << AdvancedString(""); res.push_back(e); test1(a, res, 1); } { AdvancedStringContainer a; a << AdvancedString(" what"); std::vector<AdvancedStringContainer> res; AdvancedStringContainer e; e << AdvancedString(" what"); res.push_back(e); test1(a, res, 2); } { AdvancedStringContainer a; a << AdvancedString("foo \n"); std::vector<AdvancedStringContainer> res; AdvancedStringContainer e, e2; e << AdvancedString("foo "); res.push_back(e); e << AdvancedString(""); res.push_back(e2); test1(a, res, 3); } { AdvancedStringContainer a; a << AdvancedString("\n1\n\n1\n1\n1\n1\n"); a << AdvancedString("\n\n1\n\n\n\n1"); std::vector<AdvancedStringContainer> res; AdvancedStringContainer e; e << AdvancedString(""); AdvancedStringContainer e1; e1 << AdvancedString("1"); res.push_back(e); res.push_back(e1); res.push_back(e); res.push_back(e1); res.push_back(e1); res.push_back(e1); res.push_back(e1); res.push_back(e); res.push_back(e); res.push_back(e1); res.push_back(e); res.push_back(e); res.push_back(e); res.push_back(e1); test1(a, res, 4); } { AdvancedStringContainer a; a << AdvancedString("\n1\n\n1\n1\n1\n1\n\n\n1\n\n\n\n1"); std::vector<AdvancedStringContainer> res; AdvancedStringContainer e; e << AdvancedString(""); AdvancedStringContainer e1; e1 << AdvancedString("1"); res.push_back(e); res.push_back(e1); res.push_back(e); res.push_back(e1); res.push_back(e1); res.push_back(e1); res.push_back(e1); res.push_back(e); res.push_back(e); res.push_back(e1); res.push_back(e); res.push_back(e); res.push_back(e); res.push_back(e1); test1(a, res, 5); } { AdvancedStringContainer a; a << AdvancedString("hello\nworld"); std::vector<AdvancedStringContainer> res; AdvancedStringContainer e; e << AdvancedString("hello"); AdvancedStringContainer e1; e1 << AdvancedString("world"); res.push_back(e); res.push_back(e1); test1(a, res, 6); } { AdvancedStringContainer a; a << AdvancedString("\nhelloworld"); std::vector<AdvancedStringContainer> res; AdvancedStringContainer e; e << AdvancedString(""); AdvancedStringContainer e1; e1 << AdvancedString("helloworld"); res.push_back(e); res.push_back(e1); test1(a, res, 7); } { AdvancedStringContainer a; a << AdvancedString("\n11akf__\n__jaffka22") << AdvancedString("33akfkafk44\n55asdkfasdfk66") << AdvancedString("\n77afafaf88\n\n\nf"); std::vector<AdvancedStringContainer> res; AdvancedStringContainer e, e1, e2, e3, e4, e5, e6, e7; e << AdvancedString(""); res.push_back(e); e1 << AdvancedString("11akf__"); res.push_back(e1); e2 << AdvancedString("__jaffka2233akfkafk44"); res.push_back(e2); e3 << AdvancedString("55asdkfasdfk66"); res.push_back(e3); e4 << AdvancedString("77afafaf88"); res.push_back(e4); e5 << AdvancedString(""); res.push_back(e5); e6 << AdvancedString(""); res.push_back(e6); e7 << AdvancedString("f"); res.push_back(e7); test1(a, res,8); } { AdvancedStringContainer a; a << AdvancedString("\n"); std::vector<AdvancedStringContainer> res; AdvancedStringContainer e, e2; e << AdvancedString(""); res.push_back(e); e << AdvancedString(""); res.push_back(e2); test1(a, res, 9); } { AdvancedStringContainer a; a << AdvancedString("\n"); std::vector<AdvancedStringContainer> res; AdvancedStringContainer e; e << AdvancedString(""); res.push_back(e); res.push_back(e); test1(a, res, 10); } { AdvancedStringContainer a; a << AdvancedString("**this should be colored in MAGENTA**\n", COLOR_MAGENTA); a << AdvancedString("**this should be colored in GREEN**\n", COLOR_GREEN); a << AdvancedString("----------------------1111111111111111111111111122222222222222222222222222222222233333333333333333333333333333333334444444\n", COLOR_GREEN); a << AdvancedString("\n\na"); std::vector<AdvancedStringContainer> res; AdvancedStringContainer e, e1, e2, e3, e4; e << AdvancedString("**this should be colored in MAGENTA**"); res.push_back(e); e1 << AdvancedString("**this should be colored in GREEN**"); res.push_back(e1); e2 << AdvancedString("----------------------1111111111111111111111111122222222222222222222222222222222233333333333333333333333333333333334444444"); res.push_back(e2); e3 << AdvancedString(""); res.push_back(e3); res.push_back(e3); e4 << AdvancedString("a"); res.push_back(e4); test1(a, res, 11); } { AdvancedStringContainer a; a << AdvancedString(" foo\n"); a << AdvancedString(" bar "); a << AdvancedString(" "); std::vector<AdvancedStringContainer> res; AdvancedStringContainer e,e1; e << AdvancedString(" foo"); res.push_back(e); e1 << AdvancedString(" bar "); e1 << AdvancedString(" "); res.push_back(e1); test1(a, res, 12); } { AdvancedStringContainer b; b << AdvancedString("linux "); b << AdvancedString("for \n the "); b << AdvancedString("ppl "); std::vector<AdvancedStringContainer> res; AdvancedStringContainer e,e1; e << AdvancedString("linux for"); e1 << AdvancedString(" the ppl"); res.push_back(e); res.push_back(e1); test2(b, res, 50); } { AdvancedStringContainer b; b << AdvancedString(""); std::vector<AdvancedStringContainer> res; AdvancedStringContainer e; e << AdvancedString(""); res.push_back(e); test2(b, res, 51); } { AdvancedStringContainer b; b << AdvancedString(" "); std::vector<AdvancedStringContainer> res; AdvancedStringContainer e; e << AdvancedString(""); res.push_back(e); test2(b, res, 52); } { AdvancedStringContainer b; b << AdvancedString(" "); b << AdvancedString(""); b << AdvancedString(""); b << AdvancedString(" "); std::vector<AdvancedStringContainer> res; AdvancedStringContainer e; e << AdvancedString(""); res.push_back(e); test2(b, res, 53); } { AdvancedStringContainer b; b << AdvancedString(" "); b << AdvancedString(" \n "); b << AdvancedString(" foo\n"); b << AdvancedString(" bar "); std::vector<AdvancedStringContainer> res; AdvancedStringContainer e,e1,e2,e3; e << AdvancedString(""); res.push_back(e); e1 << AdvancedString(" foo"); res.push_back(e1); e2 << AdvancedString(" bar"); res.push_back(e2); test2(b, res, 54); } { AdvancedStringContainer b; b << AdvancedString("**this should be colored in MAGENTA**\n", COLOR_MAGENTA); b << AdvancedString("**this should be colored in GREEN**\n", COLOR_GREEN); b << AdvancedString("----------------------1111111111111111111111111122222222222222222222222222222222233333333333333333333333333333333334444444\n", COLOR_GREEN); b << AdvancedString("\n\na"); std::vector<AdvancedStringContainer> res; AdvancedStringContainer e,e1,e2,e3,e4; e << AdvancedString("**this should be colored in MAGENTA**"); res.push_back(e); e1 << AdvancedString("**this should be colored in GREEN**"); res.push_back(e1); e2 << AdvancedString("----------------------1111111111111111111111111122222222222222222222222222222222233333333333333333333333333333333334444444"); res.push_back(e2); e3 << AdvancedString(""); res.push_back(e3); res.push_back(e3); e4 << AdvancedString("a"); res.push_back(e4); test2(b, res, 55); } { AdvancedStringContainer b; b << AdvancedString(" foo\n"); b << AdvancedString(" bar "); b << AdvancedString(" "); std::vector<AdvancedStringContainer> res; AdvancedStringContainer e1,e2; e1 << AdvancedString(" foo"); res.push_back(e1); e2 << AdvancedString(" bar"); res.push_back(e2); test2(b, res, 56); } { AdvancedStringContainer b; b << AdvancedString("123 \n"); b << AdvancedString(" \n"); b << AdvancedString("1lk2j312k3j"); std::vector<AdvancedStringContainer> res; AdvancedStringContainer e1,e2,e3; e1 << AdvancedString("123"); res.push_back(e1); e2 << AdvancedString(""); res.push_back(e2); e3 << AdvancedString("1lk2j312k3j"); res.push_back(e3); test2(b, res, 57); } ////////////////////////// terminal_rasterize /////////////////////// { AdvancedStringContainer c; c << AdvancedString("\nhello worldhow are you today?"); c << AdvancedString("this is funny stuff\n"); c << AdvancedString("bye bye world"); std::vector<AdvancedStringContainer> res; AdvancedStringContainer e, e0, e1, e2, e3; e << AdvancedString(std::string(17, ' ')); res.push_back(e); e0 << AdvancedString("hello worldhow ar"); res.push_back(e0); e1 << AdvancedString("e you today?this "); res.push_back(e1); e2 << AdvancedString("is funny stuff "); res.push_back(e2); e3 << AdvancedString("bye bye world "); res.push_back(e3); test3(c, res, 17, 71); } { AdvancedStringContainer c; c << AdvancedString("\n\nmore and more\n questions arise?"); c << AdvancedString("due to broken code\n\n"); c << AdvancedString("so \nbye bye world\n"); std::vector<AdvancedStringContainer> res; AdvancedStringContainer e, e0, e1, e2, e3, e4, e5; e << AdvancedString(std::string(17, ' ')); res.push_back(e); res.push_back(e); e0 << AdvancedString("more and more "); res.push_back(e0); e1 << AdvancedString(" questions arise?"); res.push_back(e1); e2 << AdvancedString("due to broken cod"); res.push_back(e2); e3 << AdvancedString("e "); res.push_back(e3); res.push_back(e); e4 << AdvancedString("so "); res.push_back(e4); e5 << AdvancedString("bye bye world "); res.push_back(e5); // res.push_back(e); test3(c, res, 17, 72); } { AdvancedStringContainer c; c << AdvancedString("**this should be colored in MAGENTA**\n", COLOR_MAGENTA); c << AdvancedString("**this should be colored in GREEN**\n", COLOR_GREEN); c << AdvancedString("----------------------1111111111111111111111111122222222222222222222222222222222233333333333333333333333333333333334444444\n", COLOR_GREEN); c << AdvancedString("\n\na"); std::vector<AdvancedStringContainer> res; AdvancedStringContainer e,e0,e1,e2,e3,e4,e5; e << AdvancedString(std::string(50, ' ')); e0 << AdvancedString("**this should be colored in MAGENTA** "); res.push_back(e0); e1 << AdvancedString("**this should be colored in GREEN** "); res.push_back(e1); e2 << AdvancedString("----------------------1111111111111111111111111122"); res.push_back(e2); e3 << AdvancedString("22222222222222222222222222222223333333333333333333"); res.push_back(e3); e4 << AdvancedString("3333333333333334444444 "); res.push_back(e4); res.push_back(e); res.push_back(e); e5 << AdvancedString("a "); res.push_back(e5); test3(c, res, 50, 73); std::vector<AdvancedStringContainer> buf; // AdvancedStringContainer::trimEndAndRemoveNewlineChars(buf, c); // std::cout << "==== NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN: ====" << std::endl; // for (int i=0; i < buf.size(); ++i) { // std::cout << "'" << YELLOW << buf[i].str() << RESET << "'" << std::endl; // } } ////////////////////////// AdvancedString::substr ////////////////////// { AdvancedString c("hello world"); AdvancedString res("hello"); test4(c, res, 0, 5, 90); } { AdvancedString c("hello world"); AdvancedString res(""); test4(c, res, 0, 0, 91); } { AdvancedString c("hello world"); AdvancedString res(" world"); test4(c, res, 5, 55, 92); } { AdvancedString c("hello world"); AdvancedString res(""); test4(c, res, 55, 55, 93); } { AdvancedString c(""); AdvancedString res(""); test4(c, res, 55, 55, 94); } { AdvancedString c("123"); AdvancedString res("2"); test4(c, res, 1, 1, 95); } //////////////////// AdvancedStringContainer::substr /////////////////// { AdvancedStringContainer c; c << "hello world" << ", how are " << "you"; AdvancedStringContainer res; res << "hello world"; test5(c, res, 0, 11, 110); } { AdvancedStringContainer c; c << "hello world" << ", how are " << "you"; AdvancedStringContainer res; res << "llo world, how"; test5(c, res, 2, 14, 111); } { AdvancedStringContainer c; c << "hello world" << ", how are " << "you"; AdvancedStringContainer res; res << "llo world, how are y"; test5(c, res, 2, 20, 112); } { AdvancedStringContainer c; c << "" << "hello world" << "" << ", how are " << "you"; AdvancedStringContainer res; res << "llo world, how are y"; test5(c, res, 2, 20, 113); } { AdvancedStringContainer c; c << ""; AdvancedStringContainer res; // should be empty test5(c, res, 0, 11, 114); } { AdvancedStringContainer c; c << "" << "" << ""; AdvancedStringContainer res; // should be empty test5(c, res, 0, 11, 115); } { AdvancedStringContainer c; c << "" << "" << "" << "f" << ""; AdvancedStringContainer res; res << "f"; test5(c, res, 0, 1, 116); } exit(0); }
int main(int argc, char** argv) { // Execute the tests only if trace calls are included #ifdef PEGASUS_REMOVE_TRACE cout << argv[0] << " +++++ passed all tests" << endl; return 0; #else const char* tmpDir = getenv ("PEGASUS_TMP"); if (tmpDir == NULL) { tmpDir = "."; } String f1 (tmpDir); f1.append("/testtracer1.trace"); FILE1 = f1.getCString(); String f2 (tmpDir); f2.append("/testtracer2.trace"); FILE2 = f2.getCString(); String f3 (tmpDir); f3.append("/testtracer3.trace"); FILE3 = f3.getCString(); String f4 (tmpDir); f4.append("/testtracer4.trace"); FILE4 = f4.getCString(); System::removeFile(FILE1); System::removeFile(FILE2); System::removeFile(FILE3); System::removeFile(FILE4); if (test1() == 0) { cout << "Tracer test (test1) failed" << endl; exit(1); } if (test2() == 0) { cout << "Tracer test (test2) failed" << endl; exit(1); } if (test3() == 0) { cout << "Tracer test (test3) failed" << endl; exit(1); } if (test4() != 0) { cout << "Tracer test (test4) failed" << endl; exit(1); } if (test5() != 0) { cout << "Tracer test (test5) failed" << endl; exit(1); } if (test6() != 0) { cout << "Tracer test (test6) failed" << endl; exit(1); } if (test7() != 0) { cout << "Tracer test (test7) failed" << endl; exit(1); } if (test8() != 0) { cout << "Tracer test (test8) failed" << endl; exit(1); } if (test9() != 0) { cout << "Tracer test (test9) failed" << endl; exit(1); } if (test10() != 0) { cout << "Tracer test (test10) failed" << endl; exit(1); } if (test11() != 0) { cout << "Tracer test (test11) failed" << endl; exit(1); } if (test12() != 0) { cout << "Tracer test (test12) failed" << endl; exit(1); } if (test13() != 0) { cout << "Tracer test (test13) failed" << endl; exit(1); } if (test14() != 0) { cout << "Tracer test (test14) failed" << endl; exit(1); } if (test15() != 0) { cout << "Tracer test (test15) failed" << endl; exit(1); } if (test16() != 0) { cout << "Tracer test (test16) failed" << endl; exit(1); } if (test17() != 0) { cout << "Tracer test (test17) failed" << endl; exit(1); } if (test18() != 0) { cout << "Tracer test (test18) failed" << endl; exit(1); } if (test19() != 0) { cout << "Tracer test (test19) failed" << endl; exit(1); } if (test20() != 0) { cout << "Tracer test (test20) failed" << endl; exit(1); } if (test21() != 0) { cout << "Tracer test (test21) failed" << endl; exit(1); } if (test22() != 0) { cout << "Tracer test (test22) failed" << endl; exit(1); } cout << argv[0] << " +++++ passed all tests" << endl; System::removeFile(FILE1); System::removeFile(FILE2); System::removeFile(FILE3); System::removeFile(FILE4); return 0; #endif }
//////////////////////////////////////////////////////////// /// Entry point of application /// /// \return Application exit code /// //////////////////////////////////////////////////////////// int main() { // Create the main window sf::RenderWindow App(sf::VideoMode(800, 600, 32), "SFML OpenGL"); // Create a clock for measuring time elapsed sf::Clock Clock; // Set color and depth clear value glClearDepth(1.f); glClearColor(0.f, 0.f, 0.f, 0.f); // Enable Z-buffer read and write glEnable(GL_DEPTH_TEST); glDepthMask(GL_TRUE); // Setup a perspective projection glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(90.f, 800.0f/600.0f, 1.f, 500.f); // set FPS limit to 60 App.SetFramerateLimit(60); // Preserve OpenGl States App.PreserveOpenGLStates(true); // Create Cube Cube c; // Create design ygui::DesignButton d(200.0, 50.0); ygui::DesignButton d1(200.0, 50.0); ygui::DesignButton d2(50.0, 200.0); ygui::DesignButton d3(50.0, 200.0); // Create Button CubeButtonUp test(d, &c); CubeButtonDown test1(d1, &c); CubeButtonLeft test2(d2, &c); CubeButtonRight test3(d3, &c); // Create scene ygui::Scene scene; // Set button setting test.setX(300.0); test.setY(50.0); test.setText("Up"); test.setTextColor(0, 0, 0); test.setTextY(3.0); test.setTextX(80.0); test1.setX(300.0); test1.setY(500.0); test1.setText("Down"); test1.setTextColor(0, 0, 0); test1.setTextY(3.0); test1.setTextX(65.0); test2.setX(50.0); test2.setY(200.0); test2.setText("Left"); test2.setTextColor(0, 0, 0); test2.setTextX(5.0); test2.setTextY(125.0); test2.setTextRotation(90.0f); test3.setX(700.0); test3.setY(200.0); test3.setText("Right"); test3.setTextColor(0, 0, 0); test3.setTextX(45.0); test3.setTextY(55.0); test3.setTextRotation(270.0f); scene.addObject("1", &test); scene.addObject("2", &test1); scene.addObject("3", &test2); scene.addObject("4", &test3); // Start game loop while (App.IsOpened()) { // Process events sf::Event Event; while (App.GetEvent(Event)) { // Close window : exit if (Event.Type == sf::Event::Closed) App.Close(); // Escape key : exit if ((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Key::Escape)) App.Close(); // Resize event : adjust viewport if (Event.Type == sf::Event::Resized) glViewport(0, 0, Event.Size.Width, Event.Size.Height); } // Set the active window before using OpenGL commands // It's useless here because active window is always the same, // but don't forget it if you use multiple windows or controls App.Clear(); App.SetActive(); // Clear color and depth buffer glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Apply some transformations glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glTranslatef(0.f, 0.f, -200.f); c.draw(Clock); scene.draw(App); // Finally, display rendered frame on screen App.Display(); } return EXIT_SUCCESS; }
int main( int argc, char** argv ) { int ok = 0; DtMmdbInit(); if ( argc == 1 || 0==isdigit((unsigned char) argv[1][0]) ) { usage(argc, argv); } else switch ( atoi(argv[1]) ) { case 0: test0(argc, argv); break; case 1: test1(argc, argv); break; case 2: test2(argc, argv); break; case 3: test3(argc, argv); break; case 4: test4(argc, argv); break; case 5: test_loc1(argc, argv); break; /* case 6: test_loc2(argc, argv); break; */ case 7: test_graphic1(argc, argv); break; case 8: test_graphic2(argc, argv); break; case 9: test_ss1(argc, argv); break; case 10: test_ss2(argc, argv); break; case 11: test_dlp(argc, argv); break; case 12: test_book1(argc, argv); break; case 13: test_book2(argc, argv); break; case 14: test_book3(argc, argv); break; case 15: ok = auto_test_c_api(argc, argv); break; default: usage(argc, argv); } DtMmdbQuit(); exit(ok); }
NOMIPS16 int main () { double a, b; int i; /* cabs.eq.d */ a = 12; b = -56; i = 0; if (__builtin_mips_cabs_eq_d(a, b) != i) abort (); /* cabs.eq.d */ a = 12; b = -12; i = 1; if (__builtin_mips_cabs_eq_d(a, b) != i) abort (); /* Test all operators */ a = 1984.0; b = 1984.0; i = test0 (a, b); if (i != 0) abort (); i = test1 (a, b); if (i != 0) abort (); i = test2 (a, b); if (i != 1) abort (); i = test3 (a, b); if (i != 1) abort (); i = test4 (a, b); if (i != 0) abort (); i = test5 (a, b); if (i != 0) abort (); i = test6 (a, b); if (i != 1) abort (); i = test7 (a, b); if (i != 1) abort (); i = test8 (a, b); if (i != 0) abort (); i = test9 (a, b); if (i != 0) abort (); i = test10 (a, b); if (i != 1) abort (); i = test11 (a, b); if (i != 1) abort (); i = test12 (a, b); if (i != 0) abort (); i = test13 (a, b); if (i != 0) abort (); i = test14 (a, b); if (i != 1) abort (); i = test15 (a, b); if (i != 1) abort (); /* Reverse arguments */ i = test0 (b, a); if (i != 0) abort (); i = test1 (b, a); if (i != 0) abort (); i = test2 (b, a); if (i != 1) abort (); i = test3 (b, a); if (i != 1) abort (); i = test4 (b, a); if (i != 0) abort (); i = test5 (b, a); if (i != 0) abort (); i = test6 (b, a); if (i != 1) abort (); i = test7 (b, a); if (i != 1) abort (); i = test8 (b, a); if (i != 0) abort (); i = test9 (b, a); if (i != 0) abort (); i = test10 (b, a); if (i != 1) abort (); i = test11 (b, a); if (i != 1) abort (); i = test12 (b, a); if (i != 0) abort (); i = test13 (b, a); if (i != 0) abort (); i = test14 (b, a); if (i != 1) abort (); i = test15 (b, a); if (i != 1) abort (); #ifndef __FAST_MATH__ /* Test all operators */ a = 1.0/0.0 - 1.0/0.0; // QNaN b = 1.0/0.0 - 1.0/0.0; // QNaN i = test0 (a, b); if (i != 0) abort (); i = test1 (a, b); if (i != 1) abort (); i = test2 (a, b); if (i != 0) abort (); i = test3 (a, b); if (i != 1) abort (); i = test4 (a, b); if (i != 0) abort (); i = test5 (a, b); if (i != 1) abort (); i = test6 (a, b); if (i != 0) abort (); i = test7 (a, b); if (i != 1) abort (); i = test8 (a, b); if (i != 0) abort (); i = test9 (a, b); if (i != 1) abort (); i = test10 (a, b); if (i != 0) abort (); i = test11 (a, b); if (i != 1) abort (); i = test12 (a, b); if (i != 0) abort (); i = test13 (a, b); if (i != 1) abort (); i = test14 (a, b); if (i != 0) abort (); i = test15 (a, b); if (i != 1) abort (); #endif printf ("Test Passes\n"); exit (0); }
int main(int argc, const char * argv[]) { test3(); return 0; }
GLDEF_C TInt E32Main() // // Test the Array classes. // { test.Title(); __UHEAP_MARK; test.Start(_L("class CArrayFixFlat")); CArrayFixFlat<TBuf<0x10> >* pFixFlat=new CArrayFixFlat<TBuf<0x10> >(KTestGranularity); if (pFixFlat==NULL) test.Panic(_L("Allocating array")); testFix(*pFixFlat); delete pFixFlat; CArrayFixFlat<TText>* pFixFlatChar=new CArrayFixFlat<TText>(KTestGranularity); test1(*pFixFlatChar); delete pFixFlatChar; CArrayFixFlat<TArr<TText,4> >* pFixFlatArr=new CArrayFixFlat<TArr<TText,4> >(KTestGranularity); test2(*pFixFlatArr); delete pFixFlatArr; CArrayFixFlat<TInt>* pFixFlatInt=new CArrayFixFlat<TInt>(KTestGranularity); test3(*pFixFlatInt); delete pFixFlatInt; CArrayFixFlat<TUid>* pFixFlatTUid=new CArrayFixFlat<TUid>(KTestGranularity); if (pFixFlatTUid==NULL) { test.Panic(_L("Allocating array of TUid")); } delete pFixFlatTUid; test.Next(_L("class CArrayPtrFlat of CBase")); CArrayPtrFlat<MyCBase>* pPtrFlatCBase=new CArrayPtrFlat<MyCBase>(KTestGranularity); if (pPtrFlatCBase==NULL) test.Panic(_L("Allocating array of CBase*")); MyCBase* c1 = new MyCBase(); pPtrFlatCBase->InsertL(0,&c1,1); pPtrFlatCBase->ResetAndDestroy(); // test(pFixFlatCBase->iBase==0); pPtrFlatCBase->ResetAndDestroy(); delete pPtrFlatCBase; test.Next(_L("class CArrayFixFlat of CBase")); CArrayFixFlat<MyCBase>* pFixFlatCBase=new CArrayFixFlat<MyCBase>(KTestGranularity); if (pFixFlatCBase==NULL) test.Panic(_L("Allocating array of CBase")); delete pFixFlatCBase; test.Next(_L("class CArrayFixSeg")); CArrayFixSeg<TBuf<0x10> >* pFixSeg=new CArrayFixSeg<TBuf<0x10> >(KTestGranularity); if (pFixSeg==NULL) test.Panic(_L("Allocating array")); testFix(*pFixSeg); delete pFixSeg; CArrayFixSeg<TText>* pFixSegChar=new CArrayFixSeg<TText>(KTestGranularity); test1(*pFixSegChar); delete pFixSegChar; CArrayFixSeg<TArr<TText,4> >* pFixSegArr=new CArrayFixSeg<TArr<TText,4> >(KTestGranularity); test2(*pFixSegArr); delete pFixSegArr; CArrayFixSeg<TInt>* pFixSegInt=new CArrayFixSeg<TInt>(KTestGranularity); test3(*pFixSegInt); delete pFixSegInt; test.End(); __UHEAP_MARKEND; return(0); }
int main ( int argc, char* argv[] ) { // test1 ( ); test2 ( ); test3 ( ); test4 ( ); }
NOMIPS16 int main () { float f1; v2sf a, b, c, d, e, f; /* Case 1 {diff, diff} */ /* movt.ps */ a = (v2sf) {5, 12}; b = (v2sf) {9, 6}; c = (v2sf) {33, 123}; d = (v2sf) {8, 78}; e = __builtin_mips_movt_c_eq_ps (a, b, c, d); f = (v2sf) {33, 123}; if (!__builtin_mips_upper_c_eq_ps (e, f) || !__builtin_mips_lower_c_eq_ps (e, f)) abort (); /* movf.ps */ e = __builtin_mips_movf_c_eq_ps (a, b, c, d); f = (v2sf) {8, 78}; if (!__builtin_mips_upper_c_eq_ps (e, f) || !__builtin_mips_lower_c_eq_ps (e, f)) abort (); /* Case 2 {same, diff} */ /* movt.ps */ a = (v2sf) {5, 12}; b = (v2sf) {5, 6}; c = (v2sf) {33, 123}; d = (v2sf) {8, 78}; e = __builtin_mips_movt_c_eq_ps (a, b, c, d); f = (v2sf) {8, 123}; if (!__builtin_mips_upper_c_eq_ps (e, f) || !__builtin_mips_lower_c_eq_ps (e, f)) abort (); /* movf.ps */ e = __builtin_mips_movf_c_eq_ps (a, b, c, d); f = (v2sf) {33, 78}; if (!__builtin_mips_upper_c_eq_ps (e, f) || !__builtin_mips_lower_c_eq_ps (e, f)) abort (); /* Case 3 {diff, same} */ /* movt.ps */ a = (v2sf) {5, 12}; b = (v2sf) {9, 12}; c = (v2sf) {33, 123}; d = (v2sf) {8, 78}; e = __builtin_mips_movt_c_eq_ps (a, b, c, d); f = (v2sf) {33, 78}; if (!__builtin_mips_upper_c_eq_ps (e, f) || !__builtin_mips_lower_c_eq_ps (e, f)) abort (); /* movf.ps */ e = __builtin_mips_movf_c_eq_ps (a, b, c, d); f = (v2sf) {8, 123}; if (!__builtin_mips_upper_c_eq_ps (e, f) || !__builtin_mips_lower_c_eq_ps (e, f)) abort (); /* Case 4 {same, same} */ /* movt.ps */ a = (v2sf) {5, 12}; b = (v2sf) {5, 12}; c = (v2sf) {33, 123}; d = (v2sf) {8, 78}; e = __builtin_mips_movt_c_eq_ps (a, b, c, d); f = (v2sf) {8, 78}; if (!__builtin_mips_upper_c_eq_ps (e, f) || !__builtin_mips_lower_c_eq_ps (e, f)) abort (); /* movf.ps */ e = __builtin_mips_movf_c_eq_ps (a, b, c, d); f = (v2sf) {33, 123}; if (!__builtin_mips_upper_c_eq_ps (e, f) || !__builtin_mips_lower_c_eq_ps (e, f)) abort (); /* Test all 16 operators */ a = (v2sf) {123, 123}; b = (v2sf) {1000, 1000}; c = (v2sf) {33, 123}; d = (v2sf) {8, 78}; e = test0 (a, b, c, d); if (!__builtin_mips_upper_c_eq_ps (e, c) || !__builtin_mips_lower_c_eq_ps (e, c)) abort (); e = test1 (a, b, c, d); if (!__builtin_mips_upper_c_eq_ps (e, d) || !__builtin_mips_lower_c_eq_ps (e, d)) abort (); e = test2 (a, b, c, d); if (!__builtin_mips_upper_c_eq_ps (e, c) || !__builtin_mips_lower_c_eq_ps (e, c)) abort (); e = test3 (a, b, c, d); if (!__builtin_mips_upper_c_eq_ps (e, d) || !__builtin_mips_lower_c_eq_ps (e, d)) abort (); e = test4 (a, b, c, d); if (!__builtin_mips_upper_c_eq_ps (e, c) || !__builtin_mips_lower_c_eq_ps (e, c)) abort (); e = test5 (a, b, c, d); if (!__builtin_mips_upper_c_eq_ps (e, d) || !__builtin_mips_lower_c_eq_ps (e, d)) abort (); e = test6 (a, b, c, d); if (!__builtin_mips_upper_c_eq_ps (e, c) || !__builtin_mips_lower_c_eq_ps (e, c)) abort (); e = test7 (a, b, c, d); if (!__builtin_mips_upper_c_eq_ps (e, d) || !__builtin_mips_lower_c_eq_ps (e, d)) abort (); e = test8 (a, b, c, d); if (!__builtin_mips_upper_c_eq_ps (e, d) || !__builtin_mips_lower_c_eq_ps (e, d)) abort (); e = test9 (a, b, c, d); if (!__builtin_mips_upper_c_eq_ps (e, c) || !__builtin_mips_lower_c_eq_ps (e, c)) abort (); e = test10 (a, b, c, d); if (!__builtin_mips_upper_c_eq_ps (e, d) || !__builtin_mips_lower_c_eq_ps (e, d)) abort (); e = test11 (a, b, c, d); if (!__builtin_mips_upper_c_eq_ps (e, c) || !__builtin_mips_lower_c_eq_ps (e, c)) abort (); e = test12 (a, b, c, d); if (!__builtin_mips_upper_c_eq_ps (e, d) || !__builtin_mips_lower_c_eq_ps (e, d)) abort (); e = test13 (a, b, c, d); if (!__builtin_mips_upper_c_eq_ps (e, c) || !__builtin_mips_lower_c_eq_ps (e, c)) abort (); e = test14 (a, b, c, d); if (!__builtin_mips_upper_c_eq_ps (e, d) || !__builtin_mips_lower_c_eq_ps (e, d)) abort (); e = test15 (a, b, c, d); if (!__builtin_mips_upper_c_eq_ps (e, c) || !__builtin_mips_lower_c_eq_ps (e, c)) abort (); e = test16 (a, b, c, d); if (!__builtin_mips_upper_c_eq_ps (e, c) || !__builtin_mips_lower_c_eq_ps (e, c)) abort (); e = test17 (a, b, c, d); if (!__builtin_mips_upper_c_eq_ps (e, d) || !__builtin_mips_lower_c_eq_ps (e, d)) abort (); e = test18 (a, b, c, d); if (!__builtin_mips_upper_c_eq_ps (e, c) || !__builtin_mips_lower_c_eq_ps (e, c)) abort (); e = test19 (a, b, c, d); if (!__builtin_mips_upper_c_eq_ps (e, d) || !__builtin_mips_lower_c_eq_ps (e, d)) abort (); e = test20 (a, b, c, d); if (!__builtin_mips_upper_c_eq_ps (e, c) || !__builtin_mips_lower_c_eq_ps (e, c)) abort (); e = test21 (a, b, c, d); if (!__builtin_mips_upper_c_eq_ps (e, d) || !__builtin_mips_lower_c_eq_ps (e, d)) abort (); e = test22 (a, b, c, d); if (!__builtin_mips_upper_c_eq_ps (e, c) || !__builtin_mips_lower_c_eq_ps (e, c)) abort (); e = test23 (a, b, c, d); if (!__builtin_mips_upper_c_eq_ps (e, d) || !__builtin_mips_lower_c_eq_ps (e, d)) abort (); e = test24 (a, b, c, d); if (!__builtin_mips_upper_c_eq_ps (e, d) || !__builtin_mips_lower_c_eq_ps (e, d)) abort (); e = test25 (a, b, c, d); if (!__builtin_mips_upper_c_eq_ps (e, c) || !__builtin_mips_lower_c_eq_ps (e, c)) abort (); e = test26 (a, b, c, d); if (!__builtin_mips_upper_c_eq_ps (e, d) || !__builtin_mips_lower_c_eq_ps (e, d)) abort (); e = test27 (a, b, c, d); if (!__builtin_mips_upper_c_eq_ps (e, c) || !__builtin_mips_lower_c_eq_ps (e, c)) abort (); e = test28 (a, b, c, d); if (!__builtin_mips_upper_c_eq_ps (e, d) || !__builtin_mips_lower_c_eq_ps (e, d)) abort (); e = test29 (a, b, c, d); if (!__builtin_mips_upper_c_eq_ps (e, c) || !__builtin_mips_lower_c_eq_ps (e, c)) abort (); e = test30 (a, b, c, d); if (!__builtin_mips_upper_c_eq_ps (e, d) || !__builtin_mips_lower_c_eq_ps (e, d)) abort (); e = test31 (a, b, c, d); if (!__builtin_mips_upper_c_eq_ps (e, c) || !__builtin_mips_lower_c_eq_ps (e, c)) abort (); /* Test all 16 operators with (b, a) */ a = (v2sf) {123, 123}; b = (v2sf) {1000, 1000}; c = (v2sf) {33, 123}; d = (v2sf) {8, 78}; e = test0 (b, a, c, d); if (!__builtin_mips_upper_c_eq_ps (e, c) || !__builtin_mips_lower_c_eq_ps (e, c)) abort (); e = test1 (b, a, c, d); if (!__builtin_mips_upper_c_eq_ps (e, d) || !__builtin_mips_lower_c_eq_ps (e, d)) abort (); e = test2 (b, a, c, d); if (!__builtin_mips_upper_c_eq_ps (e, c) || !__builtin_mips_lower_c_eq_ps (e, c)) abort (); e = test3 (b, a, c, d); if (!__builtin_mips_upper_c_eq_ps (e, d) || !__builtin_mips_lower_c_eq_ps (e, d)) abort (); e = test4 (b, a, c, d); if (!__builtin_mips_upper_c_eq_ps (e, c) || !__builtin_mips_lower_c_eq_ps (e, c)) abort (); e = test5 (b, a, c, d); if (!__builtin_mips_upper_c_eq_ps (e, d) || !__builtin_mips_lower_c_eq_ps (e, d)) abort (); e = test6 (b, a, c, d); if (!__builtin_mips_upper_c_eq_ps (e, c) || !__builtin_mips_lower_c_eq_ps (e, c)) abort (); e = test7 (b, a, c, d); if (!__builtin_mips_upper_c_eq_ps (e, d) || !__builtin_mips_lower_c_eq_ps (e, d)) abort (); e = test8 (b, a, c, d); if (!__builtin_mips_upper_c_eq_ps (e, c) || !__builtin_mips_lower_c_eq_ps (e, c)) abort (); e = test9 (b, a, c, d); if (!__builtin_mips_upper_c_eq_ps (e, d) || !__builtin_mips_lower_c_eq_ps (e, d)) abort (); e = test10 (b, a, c, d); if (!__builtin_mips_upper_c_eq_ps (e, c) || !__builtin_mips_lower_c_eq_ps (e, c)) abort (); e = test11 (b, a, c, d); if (!__builtin_mips_upper_c_eq_ps (e, d) || !__builtin_mips_lower_c_eq_ps (e, d)) abort (); e = test12 (b, a, c, d); if (!__builtin_mips_upper_c_eq_ps (e, c) || !__builtin_mips_lower_c_eq_ps (e, c)) abort (); e = test13 (b, a, c, d); if (!__builtin_mips_upper_c_eq_ps (e, d) || !__builtin_mips_lower_c_eq_ps (e, d)) abort (); e = test14 (b, a, c, d); if (!__builtin_mips_upper_c_eq_ps (e, c) || !__builtin_mips_lower_c_eq_ps (e, c)) abort (); e = test15 (b, a, c, d); if (!__builtin_mips_upper_c_eq_ps (e, d) || !__builtin_mips_lower_c_eq_ps (e, d)) abort (); e = test16 (b, a, c, d); if (!__builtin_mips_upper_c_eq_ps (e, c) || !__builtin_mips_lower_c_eq_ps (e, c)) abort (); e = test17 (b, a, c, d); if (!__builtin_mips_upper_c_eq_ps (e, d) || !__builtin_mips_lower_c_eq_ps (e, d)) abort (); e = test18 (b, a, c, d); if (!__builtin_mips_upper_c_eq_ps (e, c) || !__builtin_mips_lower_c_eq_ps (e, c)) abort (); e = test19 (b, a, c, d); if (!__builtin_mips_upper_c_eq_ps (e, d) || !__builtin_mips_lower_c_eq_ps (e, d)) abort (); e = test20 (b, a, c, d); if (!__builtin_mips_upper_c_eq_ps (e, c) || !__builtin_mips_lower_c_eq_ps (e, c)) abort (); e = test21 (b, a, c, d); if (!__builtin_mips_upper_c_eq_ps (e, d) || !__builtin_mips_lower_c_eq_ps (e, d)) abort (); e = test22 (b, a, c, d); if (!__builtin_mips_upper_c_eq_ps (e, c) || !__builtin_mips_lower_c_eq_ps (e, c)) abort (); e = test23 (b, a, c, d); if (!__builtin_mips_upper_c_eq_ps (e, d) || !__builtin_mips_lower_c_eq_ps (e, d)) abort (); e = test24 (b, a, c, d); if (!__builtin_mips_upper_c_eq_ps (e, c) || !__builtin_mips_lower_c_eq_ps (e, c)) abort (); e = test25 (b, a, c, d); if (!__builtin_mips_upper_c_eq_ps (e, d) || !__builtin_mips_lower_c_eq_ps (e, d)) abort (); e = test26 (b, a, c, d); if (!__builtin_mips_upper_c_eq_ps (e, c) || !__builtin_mips_lower_c_eq_ps (e, c)) abort (); e = test27 (b, a, c, d); if (!__builtin_mips_upper_c_eq_ps (e, d) || !__builtin_mips_lower_c_eq_ps (e, d)) abort (); e = test28 (b, a, c, d); if (!__builtin_mips_upper_c_eq_ps (e, c) || !__builtin_mips_lower_c_eq_ps (e, c)) abort (); e = test29 (b, a, c, d); if (!__builtin_mips_upper_c_eq_ps (e, d) || !__builtin_mips_lower_c_eq_ps (e, d)) abort (); e = test30 (b, a, c, d); if (!__builtin_mips_upper_c_eq_ps (e, c) || !__builtin_mips_lower_c_eq_ps (e, c)) abort (); e = test31 (b, a, c, d); if (!__builtin_mips_upper_c_eq_ps (e, d) || !__builtin_mips_lower_c_eq_ps (e, d)) abort (); #ifndef __FAST_MATH__ /* Test with NaN */ a = (v2sf) {qnan, qnan}; b = (v2sf) {1000, 1000}; c = (v2sf) {33, 123}; d = (v2sf) {8, 78}; e = test0 (a, b, c, d); if (!__builtin_mips_upper_c_eq_ps (e, c) || !__builtin_mips_lower_c_eq_ps (e, c)) abort (); e = test1 (a, b, c, d); if (!__builtin_mips_upper_c_eq_ps (e, d) || !__builtin_mips_lower_c_eq_ps (e, d)) abort (); e = test2 (a, b, c, d); if (!__builtin_mips_upper_c_eq_ps (e, d) || !__builtin_mips_lower_c_eq_ps (e, d)) abort (); e = test3 (a, b, c, d); if (!__builtin_mips_upper_c_eq_ps (e, c) || !__builtin_mips_lower_c_eq_ps (e, c)) abort (); e = test4 (a, b, c, d); if (!__builtin_mips_upper_c_eq_ps (e, c) || !__builtin_mips_lower_c_eq_ps (e, c)) abort (); e = test5 (a, b, c, d); if (!__builtin_mips_upper_c_eq_ps (e, d) || !__builtin_mips_lower_c_eq_ps (e, d)) abort (); e = test6 (a, b, c, d); if (!__builtin_mips_upper_c_eq_ps (e, d) || !__builtin_mips_lower_c_eq_ps (e, d)) abort (); e = test7 (a, b, c, d); if (!__builtin_mips_upper_c_eq_ps (e, c) || !__builtin_mips_lower_c_eq_ps (e, c)) abort (); e = test8 (a, b, c, d); if (!__builtin_mips_upper_c_eq_ps (e, c) || !__builtin_mips_lower_c_eq_ps (e, c)) abort (); e = test9 (a, b, c, d); if (!__builtin_mips_upper_c_eq_ps (e, d) || !__builtin_mips_lower_c_eq_ps (e, d)) abort (); e = test10 (a, b, c, d); if (!__builtin_mips_upper_c_eq_ps (e, d) || !__builtin_mips_lower_c_eq_ps (e, d)) abort (); e = test11 (a, b, c, d); if (!__builtin_mips_upper_c_eq_ps (e, c) || !__builtin_mips_lower_c_eq_ps (e, c)) abort (); e = test12 (a, b, c, d); if (!__builtin_mips_upper_c_eq_ps (e, c) || !__builtin_mips_lower_c_eq_ps (e, c)) abort (); e = test13 (a, b, c, d); if (!__builtin_mips_upper_c_eq_ps (e, d) || !__builtin_mips_lower_c_eq_ps (e, d)) abort (); e = test14 (a, b, c, d); if (!__builtin_mips_upper_c_eq_ps (e, d) || !__builtin_mips_lower_c_eq_ps (e, d)) abort (); e = test15 (a, b, c, d); if (!__builtin_mips_upper_c_eq_ps (e, c) || !__builtin_mips_lower_c_eq_ps (e, c)) abort (); e = test16 (a, b, c, d); if (!__builtin_mips_upper_c_eq_ps (e, c) || !__builtin_mips_lower_c_eq_ps (e, c)) abort (); e = test17 (a, b, c, d); if (!__builtin_mips_upper_c_eq_ps (e, d) || !__builtin_mips_lower_c_eq_ps (e, d)) abort (); e = test18 (a, b, c, d); if (!__builtin_mips_upper_c_eq_ps (e, d) || !__builtin_mips_lower_c_eq_ps (e, d)) abort (); e = test19 (a, b, c, d); if (!__builtin_mips_upper_c_eq_ps (e, c) || !__builtin_mips_lower_c_eq_ps (e, c)) abort (); e = test20 (a, b, c, d); if (!__builtin_mips_upper_c_eq_ps (e, c) || !__builtin_mips_lower_c_eq_ps (e, c)) abort (); e = test21 (a, b, c, d); if (!__builtin_mips_upper_c_eq_ps (e, d) || !__builtin_mips_lower_c_eq_ps (e, d)) abort (); e = test22 (a, b, c, d); if (!__builtin_mips_upper_c_eq_ps (e, d) || !__builtin_mips_lower_c_eq_ps (e, d)) abort (); e = test23 (a, b, c, d); if (!__builtin_mips_upper_c_eq_ps (e, c) || !__builtin_mips_lower_c_eq_ps (e, c)) abort (); e = test24 (a, b, c, d); if (!__builtin_mips_upper_c_eq_ps (e, c) || !__builtin_mips_lower_c_eq_ps (e, c)) abort (); e = test25 (a, b, c, d); if (!__builtin_mips_upper_c_eq_ps (e, d) || !__builtin_mips_lower_c_eq_ps (e, d)) abort (); e = test26 (a, b, c, d); if (!__builtin_mips_upper_c_eq_ps (e, d) || !__builtin_mips_lower_c_eq_ps (e, d)) abort (); e = test27 (a, b, c, d); if (!__builtin_mips_upper_c_eq_ps (e, c) || !__builtin_mips_lower_c_eq_ps (e, c)) abort (); e = test28 (a, b, c, d); if (!__builtin_mips_upper_c_eq_ps (e, c) || !__builtin_mips_lower_c_eq_ps (e, c)) abort (); e = test29 (a, b, c, d); if (!__builtin_mips_upper_c_eq_ps (e, d) || !__builtin_mips_lower_c_eq_ps (e, d)) abort (); e = test30 (a, b, c, d); if (!__builtin_mips_upper_c_eq_ps (e, d) || !__builtin_mips_lower_c_eq_ps (e, d)) abort (); e = test31 (a, b, c, d); if (!__builtin_mips_upper_c_eq_ps (e, c) || !__builtin_mips_lower_c_eq_ps (e, c)) abort (); #endif printf ("Test Passes\n"); exit (0); }
int main() { programme.time_reset(); test3(); programme.print_time(); }
int main(int argc, char* argv[]) { orte_proc_info(); /* initialize proc info structure */ orte_process_info.my_name = (orte_process_name_t*)malloc(sizeof(orte_process_name_t)); orte_process_info.my_name->cellid = 0; orte_process_info.my_name->jobid = 0; orte_process_info.my_name->vpid = 0; test_init("orte_session_dir_t"); test_out = fopen( "test_session_dir_out", "w+" ); if( test_out == NULL ) { test_failure("test_session_dir couldn't open test file failed"); test_finalize(); exit(1); } fprintf(test_out, "running test1\n"); if (test1()) { test_success(); } else { test_failure("orte_session_dir_t test1 failed"); } fprintf(test_out, "running test2\n"); if (test2()) { test_success(); } else { test_failure("orte_session_dir_t test2 failed"); } fprintf(test_out, "running test3\n"); if (test3()) { test_success(); } else { test_failure("orte_session_dir_t test3 failed"); } fprintf(test_out, "running test4\n"); if (test4()) { test_success(); } else { test_failure("orte_session_dir_t test4 failed"); } fprintf(test_out, "running test5\n"); if (test5()) { test_success(); } else { test_failure("orte_session_dir_t test5 failed"); } fprintf(test_out, "running test6\n"); if (test6()) { test_success(); } else { test_failure("orte_session_dir_t test6 failed"); } fprintf(test_out, "running test7\n"); if (test7()) { test_success(); } else { test_failure("orte_session_dir_t test7 failed"); } fprintf(test_out, "running test8\n"); if (test8()) { test_success(); } else { test_failure("orte_session_dir_t test8 failed"); } fprintf(test_out, "completed all tests\n"); fclose(test_out); /* clean up */ orte_proc_info_finalize(); test_finalize(); return 0; }
NOMIPS16 int main () { float a, b; int i; /* cabs.eq.s */ a = 12; b = -56; i = 0; if (__builtin_mips_cabs_eq_s(a, b) != i) abort (); /* cabs.eq.s */ a = 12; b = -12; i = 1; if (__builtin_mips_cabs_eq_s(a, b) != i) abort (); /* Test all comparisons */ a = 10.58; b = 567.345; i = test0 (a, b); if (i != 0) abort (); i = test1 (a, b); if (i != 0) abort (); i = test2 (a, b); if (i != 0) abort (); i = test3 (a, b); if (i != 0) abort (); i = test4 (a, b); if (i != 1) abort (); i = test5 (a, b); if (i != 1) abort (); i = test6 (a, b); if (i != 1) abort (); i = test7 (a, b); if (i != 1) abort (); i = test8 (a, b); if (i != 0) abort (); i = test9 (a, b); if (i != 0) abort (); i = test10 (a, b); if (i != 0) abort (); i = test11 (a, b); if (i != 0) abort (); i = test12 (a, b); if (i != 1) abort (); i = test13 (a, b); if (i != 1) abort (); i = test14 (a, b); if (i != 1) abort (); i = test15 (a, b); if (i != 1) abort (); /* Reversed arguments */ i = test0 (b, a); if (i != 0) abort (); i = test1 (b, a); if (i != 0) abort (); i = test2 (b, a); if (i != 0) abort (); i = test3 (b, a); if (i != 0) abort (); i = test4 (b, a); if (i != 0) abort (); i = test5 (b, a); if (i != 0) abort (); i = test6 (b, a); if (i != 0) abort (); i = test7 (b, a); if (i != 0) abort (); i = test8 (b, a); if (i != 0) abort (); i = test9 (b, a); if (i != 0) abort (); i = test10 (b, a); if (i != 0) abort (); i = test11 (b, a); if (i != 0) abort (); i = test12 (b, a); if (i != 0) abort (); i = test13 (b, a); if (i != 0) abort (); i = test14 (b, a); if (i != 0) abort (); i = test15 (b, a); if (i != 0) abort (); #ifndef __FAST_MATH__ /* Test all comparisons */ a = 1.0f/0.0f - 1.0f/0.0f; // QNaN b = 567.345; i = test0 (a, b); if (i != 0) abort (); i = test1 (a, b); if (i != 1) abort (); i = test2 (a, b); if (i != 0) abort (); i = test3 (a, b); if (i != 1) abort (); i = test4 (a, b); if (i != 0) abort (); i = test5 (a, b); if (i != 1) abort (); i = test6 (a, b); if (i != 0) abort (); i = test7 (a, b); if (i != 1) abort (); i = test8 (a, b); if (i != 0) abort (); i = test9 (a, b); if (i != 1) abort (); i = test10 (a, b); if (i != 0) abort (); i = test11 (a, b); if (i != 1) abort (); i = test12 (a, b); if (i != 0) abort (); i = test13 (a, b); if (i != 1) abort (); i = test14 (a, b); if (i != 0) abort (); i = test15 (a, b); if (i != 1) abort (); #endif printf ("Test Passes\n"); exit (0); }
/***********************************************************************//** * @brief Test matrix operations * * Tests matrix*vector and matrix*matrix multiplication operations. ***************************************************************************/ void TestGMatrixSparse::matrix_operations(void) { // Perform vector multiplication GVector test1 = m_test * v_test; // Check result GVector ref1(g_rows); for (int i = 0; i < g_elements; ++i) { ref1[g_row[i]] += g_matrix[i] * v_test[g_col[i]]; } bool result = true; for (int i = 0; i < g_rows; ++i) { if (ref1[i] != test1[i]) { result = false; break; } } // Test if original matrix and result vector are correct test_assert(check_matrix(m_test), "Test source matrix"); test_assert(result, "Test matrix*vector multiplication", "Found:\n"+test1.print()+"\nExpected:\n"+ref1.print()); // Test incompatible vector multiplication test_try("Test incompatible matrix*vector multiplication"); try { GVector test2 = m_bigger * v_test; test_try_failure("Expected GException::matrix_vector_mismatch exception."); } catch (GException::matrix_vector_mismatch &e) { test_try_success(); } catch (std::exception &e) { test_try_failure(e); } // Test matrix multiplication GMatrixSparse test3 = m_test * m_test.transpose(); // Check if the result matrix is as expected GMatrixSparse ref3(g_rows, g_rows); for (int row = 0; row < g_rows; ++row) { for (int col = 0; col < g_rows; ++col) { double value = 0.0; for (int i = 0; i < g_cols; ++i) { double ref_value_1 = 0.0; double ref_value_2 = 0.0; for (int k = 0; k < g_elements; ++k) { if (g_row[k] == row && g_col[k] == i) { ref_value_1 = g_matrix[k]; break; } } for (int k = 0; k < g_elements; ++k) { if (g_row[k] == col && g_col[k] == i) { ref_value_2 = g_matrix[k]; break; } } value += ref_value_1 * ref_value_2; } ref3(row,col) = value; if (test3(row,col) != value) { result = false; break; } } } // Test if original matrix and result matrix are correct test_assert(check_matrix(m_test), "Test source matrix"); test_assert(result, "Test matrix multiplication", "Found:\n"+test3.print()+"\nExpected:\n"+ref3.print()); test_value(test3.rows(), g_rows, "Test number of rows of result matrix"); test_value(test3.columns(), g_rows, "Test number of columns of result matrix"); // Test incompatible matrix multiplication test_try("Test incompatible matrix multiplication"); try { GMatrixSparse test4 = m_bigger * m_test; test_try_failure("Expected GException::matrix_mismatch exception."); } catch (GException::matrix_mismatch &e) { test_try_success(); } catch (std::exception &e) { test_try_failure(e); } // Test another incompatible matrix multiplication test_try("Test incompatible matrix multiplication"); try { GMatrixSparse test5 = m_bigger * m_test; test_try_failure("Expected GException::matrix_mismatch exception."); } catch (GException::matrix_mismatch &e) { test_try_success(); } catch (std::exception &e) { test_try_failure(e); } // Return return; }
static void mcd_poll(unsigned long dummy) { int st; if (mcd_error) { if (mcd_error & 0xA5) { printk(KERN_ERR "mcd: I/O error 0x%02x", mcd_error); if (mcd_error & 0x80) printk(" (Door open)"); if (mcd_error & 0x20) printk(" (Disk changed)"); if (mcd_error & 0x04) { printk(" (Read error)"); /* Bitch about the problem. */ /* Time to get fancy! If at 2x speed and 1 error, drop to 1x speed! */ /* Interesting how it STAYS at MCD_RETRY_ATTEMPTS on first error! */ /* But I find that rather HANDY!!! */ /* Neat! it REALLY WORKS on those LOW QUALITY CD's!!! Smile! :) */ /* AJK [06/17/95] */ /* Slap the CD down to single speed! */ if (mcdDouble == 1 && McdTries == MCD_RETRY_ATTEMPTS && MCMD_DATA_READ == MCMD_2X_READ) { MCMD_DATA_READ = MCMD_PLAY_READ; /* Uhhh, Ummmm, muhuh-huh! */ mcd1xhold = SINGLE_HOLD_SECTORS; /* Hey Beavis! */ printk(" Speed now 1x"); /* Pull my finger! */ } } printk("\n"); mcd_invalidate_buffers(); #ifdef WARN_IF_READ_FAILURE if (McdTries == MCD_RETRY_ATTEMPTS) printk(KERN_ERR "mcd: read of block %d failed\n", mcd_next_bn); #endif if (!McdTries--) { /* Nuts! This cd is ready for recycling! */ /* When WAS the last time YOU cleaned it CORRECTLY?! */ printk(KERN_ERR "mcd: read of block %d failed, giving up\n", mcd_next_bn); if (mcd_transfer_is_active) { McdTries = 0; goto ret; } if (CURRENT_VALID) end_request(0); McdTries = MCD_RETRY_ATTEMPTS; } } mcd_error = 0; mcd_state = MCD_S_STOP; } /* Switch back to Double speed if enough GOOD sectors were read! */ /* Are we a double speed with a crappy CD?! */ if (mcdDouble == 1 && McdTries == MCD_RETRY_ATTEMPTS && MCMD_DATA_READ == MCMD_PLAY_READ) { /* We ARE a double speed and we ARE bitching! */ if (mcd1xhold == 0) { /* Okay, Like are we STILL at single speed? *//* We need to switch back to double speed now... */ MCMD_DATA_READ = MCMD_2X_READ; /* Uhhh... BACK You GO! */ printk(KERN_INFO "mcd: Switching back to 2X speed!\n"); /* Tell 'em! */ } else mcd1xhold--; /* No?! Count down the good reads some more... */ /* and try, try again! */ } immediately: switch (mcd_state) { case MCD_S_IDLE: test3(printk("MCD_S_IDLE\n")); goto out; case MCD_S_START: test3(printk("MCD_S_START\n")); outb(MCMD_GET_STATUS, MCDPORT(0)); mcd_state = mcd_mode == 1 ? MCD_S_READ : MCD_S_MODE; McdTimeout = 3000; break; case MCD_S_MODE: test3(printk("MCD_S_MODE\n")); if ((st = mcdStatus()) != -1) { if (st & MST_DSK_CHG) { mcdDiskChanged = 1; tocUpToDate = 0; mcd_invalidate_buffers(); } set_mode_immediately: if ((st & MST_DOOR_OPEN) || !(st & MST_READY)) { mcdDiskChanged = 1; tocUpToDate = 0; if (mcd_transfer_is_active) { mcd_state = MCD_S_START; goto immediately; } printk(KERN_INFO); printk((st & MST_DOOR_OPEN) ? "mcd: door open\n" : "mcd: disk removed\n"); mcd_state = MCD_S_IDLE; while (CURRENT_VALID) end_request(0); goto out; } outb(MCMD_SET_MODE, MCDPORT(0)); outb(1, MCDPORT(0)); mcd_mode = 1; mcd_state = MCD_S_READ; McdTimeout = 3000; } break; case MCD_S_READ: test3(printk("MCD_S_READ\n")); if ((st = mcdStatus()) != -1) { if (st & MST_DSK_CHG) { mcdDiskChanged = 1; tocUpToDate = 0; mcd_invalidate_buffers(); } read_immediately: if ((st & MST_DOOR_OPEN) || !(st & MST_READY)) { mcdDiskChanged = 1; tocUpToDate = 0; if (mcd_transfer_is_active) { mcd_state = MCD_S_START; goto immediately; } printk(KERN_INFO); printk((st & MST_DOOR_OPEN) ? "mcd: door open\n" : "mcd: disk removed\n"); mcd_state = MCD_S_IDLE; while (CURRENT_VALID) end_request(0); goto out; } if (CURRENT_VALID) { struct mcd_Play_msf msf; mcd_next_bn = CURRENT->sector / 4; hsg2msf(mcd_next_bn, &msf.start); msf.end.min = ~0; msf.end.sec = ~0; msf.end.frame = ~0; sendMcdCmd(MCMD_DATA_READ, &msf); mcd_state = MCD_S_DATA; McdTimeout = READ_TIMEOUT; } else { mcd_state = MCD_S_STOP; goto immediately; } } break; case MCD_S_DATA: test3(printk("MCD_S_DATA\n")); st = inb(MCDPORT(1)) & (MFL_STATUSorDATA); data_immediately: test5(printk("Status %02x\n", st)) switch (st) { case MFL_DATA: #ifdef WARN_IF_READ_FAILURE if (McdTries == 5) printk(KERN_WARNING "mcd: read of block %d failed\n", mcd_next_bn); #endif if (!McdTries--) { printk(KERN_ERR "mcd: read of block %d failed, giving up\n", mcd_next_bn); if (mcd_transfer_is_active) { McdTries = 0; break; } if (CURRENT_VALID) end_request(0); McdTries = 5; } mcd_state = MCD_S_START; McdTimeout = READ_TIMEOUT; goto immediately; case MFL_STATUSorDATA: break; default: McdTries = 5; if (!CURRENT_VALID && mcd_buf_in == mcd_buf_out) { mcd_state = MCD_S_STOP; goto immediately; } mcd_buf_bn[mcd_buf_in] = -1; insb(MCDPORT(0), mcd_buf + 2048 * mcd_buf_in, 2048); mcd_buf_bn[mcd_buf_in] = mcd_next_bn++; if (mcd_buf_out == -1) mcd_buf_out = mcd_buf_in; mcd_buf_in = mcd_buf_in + 1 == MCD_BUF_SIZ ? 0 : mcd_buf_in + 1; if (!mcd_transfer_is_active) { while (CURRENT_VALID) { mcd_transfer(); if (CURRENT->nr_sectors == 0) end_request(1); else break; } } if (CURRENT_VALID && (CURRENT->sector / 4 < mcd_next_bn || CURRENT->sector / 4 > mcd_next_bn + 16)) { mcd_state = MCD_S_STOP; goto immediately; } McdTimeout = READ_TIMEOUT; { int count = QUICK_LOOP_COUNT; while (count--) { QUICK_LOOP_DELAY; if ((st = (inb(MCDPORT(1))) & (MFL_STATUSorDATA)) != (MFL_STATUSorDATA)) { test4(printk(" %d ", QUICK_LOOP_COUNT - count)); goto data_immediately; } } test4(printk("ended ")); } break; } break; case MCD_S_STOP: test3(printk("MCD_S_STOP\n")); if (!mitsumi_bug_93_wait) goto do_not_work_around_mitsumi_bug_93_1; McdTimeout = mitsumi_bug_93_wait; mcd_state = 9 + 3 + 1; break; case 9 + 3 + 1: if (McdTimeout) break; do_not_work_around_mitsumi_bug_93_1: outb(MCMD_STOP, MCDPORT(0)); if ((inb(MCDPORT(1)) & MFL_STATUSorDATA) == MFL_STATUS) { int i = 4096; do { inb(MCDPORT(0)); } while ((inb(MCDPORT(1)) & MFL_STATUSorDATA) == MFL_STATUS && --i); outb(MCMD_STOP, MCDPORT(0)); if ((inb(MCDPORT(1)) & MFL_STATUSorDATA) == MFL_STATUS) { i = 4096; do { inb(MCDPORT(0)); } while ((inb(MCDPORT(1)) & MFL_STATUSorDATA) == MFL_STATUS && --i); outb(MCMD_STOP, MCDPORT(0)); } } mcd_state = MCD_S_STOPPING; McdTimeout = 1000; break; case MCD_S_STOPPING: test3(printk("MCD_S_STOPPING\n")); if ((st = mcdStatus()) == -1 && McdTimeout) break; if ((st != -1) && (st & MST_DSK_CHG)) { mcdDiskChanged = 1; tocUpToDate = 0; mcd_invalidate_buffers(); } if (!mitsumi_bug_93_wait) goto do_not_work_around_mitsumi_bug_93_2; McdTimeout = mitsumi_bug_93_wait; mcd_state = 9 + 3 + 2; break; case 9 + 3 + 2: if (McdTimeout) break; st = -1; do_not_work_around_mitsumi_bug_93_2: test3(printk("CURRENT_VALID %d mcd_mode %d\n", CURRENT_VALID, mcd_mode)); if (CURRENT_VALID) { if (st != -1) { if (mcd_mode == 1) goto read_immediately; else goto set_mode_immediately; } else { mcd_state = MCD_S_START; McdTimeout = 1; } } else { mcd_state = MCD_S_IDLE; goto out; } break; default: printk(KERN_ERR "mcd: invalid state %d\n", mcd_state); goto out; } ret: if (!McdTimeout--) { printk(KERN_WARNING "mcd: timeout in state %d\n", mcd_state); mcd_state = MCD_S_STOP; } mcd_timer.function = mcd_poll; mod_timer(&mcd_timer, jiffies + 1); out: return; }
int main(int argc, char **argv) { //return test1(argc, argv); //return test2(argc, argv); return test3(argc, argv); }
int main() { uint32_t w; init_tokens(); printf("\nNo truncate, height = %"PRIu32", width = %"PRIu32"\n", display.height, display.width); init_pp(&pp, &converter, stdout, &display, PP_HMODE, 0); test1(&pp); test2(&pp); test3(&pp); test4(&pp); delete_pp(&pp); display.truncate = true; for (w = 20; w<50; w++) { display.width = w; printf("\n\nTruncate, height = %"PRIu32", width = %"PRIu32"\n", display.height, display.width); init_pp(&pp, &converter, stdout, &display, PP_HMODE, 0); test1(&pp); test2(&pp); test3(&pp); test4(&pp); delete_pp(&pp); } // tests with height = 4 // initial mode = PP_VMODE display.height = 4; display.width = 20; display.truncate = false; printf("\nNo truncate, height = %"PRIu32", width = %"PRIu32"\n", display.height, display.width); init_pp(&pp, &converter, stdout, &display, PP_VMODE, 0); test1(&pp); test2(&pp); test3(&pp); test4(&pp); delete_pp(&pp); display.truncate = true; for (w = 4; w<50; w++) { display.width = w; printf("\n\nTruncate, height = %"PRIu32", width = %"PRIu32"\n", display.height, display.width); init_pp(&pp, &converter, stdout, &display, PP_VMODE, 0); test1(&pp); test2(&pp); test3(&pp); test4(&pp); delete_pp(&pp); } display.truncate = false; for (w = 4; w<50; w++) { display.width = w; printf("\n\nNo truncate, height = %"PRIu32", width = %"PRIu32"\n", display.height, display.width); init_pp(&pp, &converter, stdout, &display, PP_VMODE, 0); test1(&pp); test2(&pp); test3(&pp); test4(&pp); delete_pp(&pp); } return 0; }
int main() { const int rhb = 10; const int lhb = 22; typedef fixed_Point<rhb, lhb> fixed_Point_def; const fixed_Point_def fp1( 6.375f ); const fixed_Point_def fp2( -4.0f ); // ------------------------------------------------------------------------- EXPECT_EQ( 6 , int(fp1) ); EXPECT_EQ( -4 , int(fp2) ); EXPECT_EQ( fp1 , abs(fp1) ); EXPECT_EQ( -fp2 , abs(fp2) ); // ------------------------------------------------------------------------- // comparison and ordering assert( fp1 == fixed_Point_def(6.375f) ); assert( fp2 != fp1 ); assert( fp2 < fp1 ); assert( fp1 > fp2 ); assert( fp2 <= fp1 ); assert( fp1 >= fp2 ); // ------------------------------------------------------------------------- // arithmetics EXPECT_EQ( fixed_Point_def( 2.375f ) , fp1 + fp2 ); EXPECT_EQ( fixed_Point_def( 10.375f ) , fp1 - fp2 ); EXPECT_EQ( fixed_Point_def(-25.5f ) , fp1 * fp2 ); EXPECT_EQ( fixed_Point_def(-1.59375f) , fp1 / fp2 ); // ------------------------------------------------------------------------- // arithmetics assignment fixed_Point_def fp3 = fp1; fp3 += fp2; EXPECT_EQ( fixed_Point_def( 2.375f ) , fp3 ); fp3 = fp1; fp3 -= fp2; EXPECT_EQ( fixed_Point_def( 10.375f ) , fp3 ); fp3 = fp1; fp3 *= fp2; EXPECT_EQ( fixed_Point_def(-25.5f ) , fp3 ); fp3 = fp1; fp3 /= fp2; EXPECT_EQ( fixed_Point_def(-1.59375f) , fp3 ); // ------------------------------------------------------------------------- // pre/post - increment/decrement fp3 = fp1; EXPECT_EQ( fixed_Point_def(7.375f) , ++fp3 ); fp3 = fp1; EXPECT_EQ( fixed_Point_def(5.375f) , --fp3 ); fp3 = fp1; EXPECT_EQ( fixed_Point_def(6.375f) , fp3++ ); EXPECT_EQ( fixed_Point_def(7.375f) , fp3 ); fp3 = fp1; EXPECT_EQ( fixed_Point_def(6.375f) , fp3-- ); EXPECT_EQ( fixed_Point_def(5.375f) , fp3 ); // ------------------------------------------------------------------------- // trigonometric functions EXPECT_CLOSE( fixed_Point_def(std::sin(0.5f)) , sin(fixed_Point_def(0.5f)) , fixed_Point_def(0.01f) ); EXPECT_CLOSE( fixed_Point_def(std::cos(0.5f)) , cos(fixed_Point_def(0.5f)) , fixed_Point_def(0.01f) ); fixed_Point<8,2> test(16.f); fixed_Point<40,2> test2(16.f); fixed_Point<3,2> test3(1.f); std::cout << sizeof(test) * 8 << std::endl; std::cout << sizeof(test2) * 8 << std::endl; std::cout << sizeof(test3) * 8 << std::endl; return 0; }
int main (void) { int rnd; mpfr_prec_t p; tests_start_mpfr (); p = (randlimb () % 200) + MPFR_PREC_MIN; RND_LOOP (rnd) { test2a (mpfr_round, "mpfr_round", p); test2a (mpfr_ceil, "mpfr_ceil", p); test2a (mpfr_floor, "mpfr_floor", p); test2a (mpfr_trunc, "mpfr_trunc", p); test2ui (mpfr_add_ui, "mpfr_add_ui", p, (mpfr_rnd_t) rnd); test2ui (mpfr_div_2exp, "mpfr_div_2exp", p, (mpfr_rnd_t) rnd); test2ui (mpfr_div_ui, "mpfr_div_ui", p, (mpfr_rnd_t) rnd); test2ui (mpfr_mul_2exp, "mpfr_mul_2exp", p, (mpfr_rnd_t) rnd); test2ui (mpfr_mul_ui, "mpfr_mul_ui", p, (mpfr_rnd_t) rnd); test2ui (mpfr_pow_ui, "mpfr_pow_ui", p, (mpfr_rnd_t) rnd); test2ui (mpfr_sub_ui, "mpfr_sub_ui", p, (mpfr_rnd_t) rnd); testui2 (mpfr_ui_div, "mpfr_ui_div", p, (mpfr_rnd_t) rnd); testui2 (mpfr_ui_sub, "mpfr_ui_sub", p, (mpfr_rnd_t) rnd); testui2 (mpfr_ui_pow, "mpfr_ui_pow", p, (mpfr_rnd_t) rnd); test2 (mpfr_sqr, "mpfr_sqr", p, (mpfr_rnd_t) rnd); test2 (mpfr_sqrt, "mpfr_sqrt", p, (mpfr_rnd_t) rnd); test2 (mpfr_abs, "mpfr_abs", p, (mpfr_rnd_t) rnd); test2 (mpfr_neg, "mpfr_neg", p, (mpfr_rnd_t) rnd); test2 (mpfr_log, "mpfr_log", p, (mpfr_rnd_t) rnd); test2 (mpfr_log2, "mpfr_log2", p, (mpfr_rnd_t) rnd); test2 (mpfr_log10, "mpfr_log10", p, (mpfr_rnd_t) rnd); test2 (mpfr_log1p, "mpfr_log1p", p, (mpfr_rnd_t) rnd); test2 (mpfr_exp, "mpfr_exp", p, (mpfr_rnd_t) rnd); test2 (mpfr_exp2, "mpfr_exp2", p, (mpfr_rnd_t) rnd); test2 (mpfr_exp10, "mpfr_exp10", p, (mpfr_rnd_t) rnd); test2 (mpfr_expm1, "mpfr_expm1", p, (mpfr_rnd_t) rnd); test2 (mpfr_eint, "mpfr_eint", p, (mpfr_rnd_t) rnd); test2 (mpfr_sinh, "mpfr_sinh", p, (mpfr_rnd_t) rnd); test2 (mpfr_cosh, "mpfr_cosh", p, (mpfr_rnd_t) rnd); test2 (mpfr_tanh, "mpfr_tanh", p, (mpfr_rnd_t) rnd); test2 (mpfr_asinh, "mpfr_asinh", p, (mpfr_rnd_t) rnd); test2 (mpfr_acosh, "mpfr_acosh", p, (mpfr_rnd_t) rnd); test2 (mpfr_atanh, "mpfr_atanh", p, (mpfr_rnd_t) rnd); test2 (mpfr_sech, "mpfr_sech", p, (mpfr_rnd_t) rnd); test2 (mpfr_csch, "mpfr_csch", p, (mpfr_rnd_t) rnd); test2 (mpfr_coth, "mpfr_coth", p, (mpfr_rnd_t) rnd); test2 (mpfr_asin, "mpfr_asin", p, (mpfr_rnd_t) rnd); test2 (mpfr_acos, "mpfr_acos", p, (mpfr_rnd_t) rnd); test2 (mpfr_atan, "mpfr_atan", p, (mpfr_rnd_t) rnd); test2 (mpfr_cos, "mpfr_cos", p, (mpfr_rnd_t) rnd); test2 (mpfr_sin, "mpfr_sin", p, (mpfr_rnd_t) rnd); test2 (mpfr_tan, "mpfr_tan", p, (mpfr_rnd_t) rnd); test2 (mpfr_sec, "mpfr_sec", p, (mpfr_rnd_t) rnd); test2 (mpfr_csc, "mpfr_csc", p, (mpfr_rnd_t) rnd); test2 (mpfr_cot, "mpfr_cot", p, (mpfr_rnd_t) rnd); test2 (mpfr_erf, "mpfr_erf", p, (mpfr_rnd_t) rnd); test2 (mpfr_erfc, "mpfr_erfc", p, (mpfr_rnd_t) rnd); test2 (mpfr_j0, "mpfr_j0", p, (mpfr_rnd_t) rnd); test2 (mpfr_j1, "mpfr_j1", p, (mpfr_rnd_t) rnd); test2 (mpfr_y0, "mpfr_y0", p, (mpfr_rnd_t) rnd); test2 (mpfr_y1, "mpfr_y1", p, (mpfr_rnd_t) rnd); test2 (mpfr_zeta, "mpfr_zeta", p, (mpfr_rnd_t) rnd); test2 (mpfr_gamma, "mpfr_gamma", p, (mpfr_rnd_t) rnd); test2 (mpfr_lngamma, "mpfr_lngamma", p, (mpfr_rnd_t) rnd); test2 (mpfr_rint, "mpfr_rint", p, (mpfr_rnd_t) rnd); test2 (mpfr_rint_ceil, "mpfr_rint_ceil", p, (mpfr_rnd_t) rnd); test2 (mpfr_rint_floor, "mpfr_rint_floor", p, (mpfr_rnd_t) rnd); test2 (mpfr_rint_round, "mpfr_rint_round", p, (mpfr_rnd_t) rnd); test2 (mpfr_rint_trunc, "mpfr_rint_trunc", p, (mpfr_rnd_t) rnd); test2 (mpfr_frac, "mpfr_frac", p, (mpfr_rnd_t) rnd); test3 (mpfr_add, "mpfr_add", p, (mpfr_rnd_t) rnd); test3 (mpfr_sub, "mpfr_sub", p, (mpfr_rnd_t) rnd); test3 (mpfr_mul, "mpfr_mul", p, (mpfr_rnd_t) rnd); test3 (mpfr_div, "mpfr_div", p, (mpfr_rnd_t) rnd); test3 (mpfr_agm, "mpfr_agm", p, (mpfr_rnd_t) rnd); test3 (mpfr_min, "mpfr_min", p, (mpfr_rnd_t) rnd); test3 (mpfr_max, "mpfr_max", p, (mpfr_rnd_t) rnd); test3 (reldiff_wrapper, "mpfr_reldiff", p, (mpfr_rnd_t) rnd); test3 (mpfr_dim, "mpfr_dim", p, (mpfr_rnd_t) rnd); test3 (mpfr_remainder, "mpfr_remainder", p, (mpfr_rnd_t) rnd); test3 (mpfr_pow, "mpfr_pow", p, (mpfr_rnd_t) rnd); pow_int ((mpfr_rnd_t) rnd); test3 (mpfr_atan2, "mpfr_atan2", p, (mpfr_rnd_t) rnd); test3 (mpfr_hypot, "mpfr_hypot", p, (mpfr_rnd_t) rnd); test3a (mpfr_sin_cos, "mpfr_sin_cos", p, (mpfr_rnd_t) rnd); test4 (mpfr_fma, "mpfr_fma", p, (mpfr_rnd_t) rnd); test4 (mpfr_fms, "mpfr_fms", p, (mpfr_rnd_t) rnd); #if MPFR_VERSION >= MPFR_VERSION_NUM(2,4,0) test2 (mpfr_li2, "mpfr_li2", p, (mpfr_rnd_t) rnd); test2 (mpfr_rec_sqrt, "mpfr_rec_sqrt", p, (mpfr_rnd_t) rnd); test3 (mpfr_fmod, "mpfr_fmod", p, (mpfr_rnd_t) rnd); test3a (mpfr_modf, "mpfr_modf", p, (mpfr_rnd_t) rnd); test3a (mpfr_sinh_cosh, "mpfr_sinh_cosh", p, (mpfr_rnd_t) rnd); #endif } tests_end_mpfr (); return 0; }
int main() { test1(); test2(); test3(); }
void TestSuite::TestWriter(void){ UnitTest::SetPrefix("Writing"); #ifdef JSON_LIBRARY #define assertWrite(node, func, expected)\ {\ json_char * _temp = func(node);\ assertCStringSame(_temp, expected);\ json_free(_temp);\ } JSONNODE * test1 = json_new(JSON_NODE); assertWrite(test1, json_write, JSON_TEXT("{}")); json_push_back(test1, json_new_a(JSON_TEXT("Hello"), JSON_TEXT("World"))); json_push_back(test1, json_new_b(JSON_TEXT("libjson"), true)); assertWrite(test1, json_write, JSON_TEXT("{\"Hello\":\"World\",\"libjson\":true}")); #ifdef JSON_NEWLINE assertEquals(JSON_NEWLINE, JSON_TEXT("\r\n")); #ifdef JSON_INDENT assertEquals(JSON_INDENT, JSON_TEXT(" ")) assertWrite(test1, json_write_formatted, JSON_TEXT("{\r\n \"Hello\" : \"World\",\r\n \"libjson\" : true\r\n}")); #else assertWrite(test1, json_write_formatted, JSON_TEXT("{\r\n\t\"Hello\" : \"World\",\r\n\t\"libjson\" : true\r\n}")); #endif #else #ifdef JSON_INDENT assertEquals(JSON_INDENT, JSON_TEXT(" ")) assertWrite(test1, json_write_formatted, JSON_TEXT("{\n \"Hello\" : \"World\",\n \"libjson\" : true\n}")); #else assertWrite(test1, json_write_formatted, JSON_TEXT("{\n\t\"Hello\" : \"World\",\n\t\"libjson\" : true\n}")); #endif #endif json_delete(test1); JSONNODE * test2 = json_new(JSON_ARRAY); assertWrite(test2, json_write, JSON_TEXT("[]")); json_delete(test2); JSONNODE * card = json_new(JSON_ARRAY); JSONNODE *c = json_new(JSON_ARRAY); json_push_back(c, json_new_a(JSON_TEXT("name"), JSON_TEXT("Entrée Audio Intégrée 1"))); json_push_back(c, json_new_i(NULL, 0)); json_push_back(card, c); #ifdef JSON_UNICODE assertWrite(card, json_write, JSON_TEXT("[[\"Entr\\u00E9e Audio Int\\u00E9gr\\u00E9e 1\",0]]")) JSONNODE * ass = json_parse(JSON_TEXT("[[\"Entr\\u00E9e Audio Int\\u00E9gr\\u00E9e 1\",0]]")); JSONNODE * item = json_at(json_at(ass, 0), 0); assertWrite(item, json_as_string, JSON_TEXT("Entrée Audio Intégrée 1")); #else assertWrite(card, json_write, JSON_TEXT("[[\"Entr\\u00C3\\u00A9e Audio Int\\u00C3\\u00A9gr\\u00C3\\u00A9e 1\",0]]")) JSONNODE * ass = json_parse(JSON_TEXT("[[\"Entr\\u00C3\\u00A9e Audio Int\\u00C3\\u00A9gr\\u00C3\\u00A9e 1\",0]]")); JSONNODE * item = json_at(json_at(ass, 0), 0); assertWrite(item, json_as_string, JSON_TEXT("Entrée Audio Intégrée 1")); #endif json_delete(card); json_delete(ass); #ifdef JSON_COMMENTS JSONNODE * test3 = json_new(JSON_NODE); json_push_back(test3, json_new_a(JSON_TEXT("Hi"), JSON_TEXT("There"))); json_push_back(test3, json_new_a(JSON_TEXT("Hello"), JSON_TEXT("World"))); json_set_comment(json_at(test3, 0), JSON_TEXT("Testing stuff")); json_set_comment(json_at(test3, 1), JSON_TEXT("Multi\r\nLine\nUnix and Windows")); assertWrite(test3, json_write, JSON_TEXT("{\"Hi\":\"There\",\"Hello\":\"World\"}")); #if !defined( JSON_INDENT) && !defined(JSON_NEWLINE) #ifdef JSON_WRITE_BASH_COMMENTS assertWrite(test3, json_write_formatted, JSON_TEXT("{\n\t\n\t#Testing stuff\n\t\"Hi\" : \"There\",\n\t\n\t#Multi\n\t#Line\n\t#Unix and Windows\n\t\"Hello\" : \"World\"\n}")); #elif defined(JSON_WRITE_SINGLE_LINE_COMMENTS) assertWrite(test3, json_write_formatted, JSON_TEXT("{\n\t\n\t//Testing stuff\n\t\"Hi\" : \"There\",\n\t\n\t//Multi\n\t//Line\n\t//Unix and Windows\n\t\"Hello\" : \"World\"\n}")); #else assertWrite(test3, json_write_formatted, JSON_TEXT("{\n\t\n\t//Testing stuff\n\t\"Hi\" : \"There\",\n\t\n\t/*\n\t\tMulti\n\t\tLine\n\t\tUnix and Windows\n\t*/\n\t\"Hello\" : \"World\"\n}")); #endif #endif json_delete(test3); #endif #else JSONNode test1(JSON_NODE); assertEquals(test1.write(), JSON_TEXT("{}")); test1.push_back(JSONNode(JSON_TEXT("Hello"), JSON_TEXT("World"))); test1.push_back(JSONNode(JSON_TEXT("libjson"), true)); assertEquals(test1.write(), JSON_TEXT("{\"Hello\":\"World\",\"libjson\":true}")); #ifdef JSON_NEWLINE assertEquals(JSON_NEWLINE, JSON_TEXT("\r\n")); #ifdef JSON_INDENT assertEquals(JSON_INDENT, JSON_TEXT(" ")) assertEquals(test1.write_formatted(), JSON_TEXT("{\r\n \"Hello\" : \"World\",\r\n \"libjson\" : true\r\n}")); #else assertEquals(test1.write_formatted(), JSON_TEXT("{\r\n\t\"Hello\" : \"World\",\r\n\t\"libjson\" : true\r\n}")); #endif #else #ifdef JSON_INDENT assertEquals(JSON_INDENT, JSON_TEXT(" ")) assertEquals(test1.write_formatted(), JSON_TEXT("{\n \"Hello\" : \"World\",\n \"libjson\" : true\n}")); #else assertEquals(test1.write_formatted(), JSON_TEXT("{\n\t\"Hello\" : \"World\",\n\t\"libjson\" : true\n}")); #endif #endif JSONNode test2(JSON_ARRAY); assertEquals(test2.write(), JSON_TEXT("[]")); #ifdef JSON_COMMENTS JSONNode test3(JSON_NODE); test3.push_back(JSONNode(JSON_TEXT("Hi"), JSON_TEXT("There"))); test3.push_back(JSONNode(JSON_TEXT("Hello"), JSON_TEXT("World"))); test3[0].set_comment(JSON_TEXT("Testing stuff")); test3[1].set_comment(JSON_TEXT("Multi\r\nLine\nUnix and Windows")); assertEquals(test3.write(), JSON_TEXT("{\"Hi\":\"There\",\"Hello\":\"World\"}")); #if !defined( JSON_INDENT) && !defined(JSON_NEWLINE) #ifdef JSON_WRITE_BASH_COMMENTS assertEquals(test3.write_formatted(), JSON_TEXT("{\n\t\n\t#Testing stuff\n\t\"Hi\" : \"There\",\n\t\n\t#Multi\n\t#Line\n\t#Unix and Windows\n\t\"Hello\" : \"World\"\n}")); #elif defined(JSON_WRITE_SINGLE_LINE_COMMENTS) assertEquals(test3.write_formatted(), JSON_TEXT("{\n\t\n\t//Testing stuff\n\t\"Hi\" : \"There\",\n\t\n\t//Multi\n\t//Line\n\t//Unix and Windows\n\t\"Hello\" : \"World\"\n}")); #else assertEquals(test3.write_formatted(), JSON_TEXT("{\n\t\n\t//Testing stuff\n\t\"Hi\" : \"There\",\n\t\n\t/*\n\t\tMulti\n\t\tLine\n\t\tUnix and Windows\n\t*/\n\t\"Hello\" : \"World\"\n}")); #endif #endif #endif #endif }