int main (void)
{
  test_c ('?');
  test_d_i (0xdeadbeef, 0xdeadbeefL);
  test_x ('?', 0xdead, 0xdeadbeef);

  test_a_double (0.0);
  test_e_double (0.0);
  test_f_double (0.0);
  test_g_double (0.0);

  test_a_long_double ();
  test_e_long_double (0.0);
  test_f_long_double ();
  test_g_long_double ();

  test_s (0);

  test_n ();

  test_percent ();

  if (nfails)
    {
      __builtin_printf ("%u out of %u tests failed\n", nfails, ntests);
      __builtin_abort ();
    }

  return 0;
}
示例#2
0
int main(int argc, char **args) {
    (void) argc; (void) args;

    test_s();
    test_S();
    test1();

    return 0;
}
示例#3
0
RealMat derivative4order(const PetscReal r, const PetscReal s, const PetscReal t,
                         const PetscInt order) {

  PetscInt size = (order + 1) * (order + 1) * (order + 1);
  RealVec test_r(size), test_s(size), test_t(size);

  if (order == 1) {
    interpolate_r_derivative_order1_hex(s, t, test_r.data());
    interpolate_s_derivative_order1_hex(r, t, test_s.data());
    interpolate_t_derivative_order1_hex(r, s, test_t.data());
  } else if (order == 2) {
    interpolate_r_derivative_order2_hex(r, s, t, test_r.data());
    interpolate_s_derivative_order2_hex(r, s, t, test_s.data());
    interpolate_t_derivative_order2_hex(r, s, t, test_t.data());
  } else if (order == 3) {
    interpolate_r_derivative_order3_hex(r, s, t, test_r.data());
    interpolate_s_derivative_order3_hex(r, s, t, test_s.data());
    interpolate_t_derivative_order3_hex(r, s, t, test_t.data());
  } else if (order == 4) {
    interpolate_r_derivative_order4_hex(r, s, t, test_r.data());
    interpolate_s_derivative_order4_hex(r, s, t, test_s.data());
    interpolate_t_derivative_order4_hex(r, s, t, test_t.data());
  } else if (order == 5) {
    interpolate_r_derivative_order5_hex(r, s, t, test_r.data());
    interpolate_s_derivative_order5_hex(r, s, t, test_s.data());
    interpolate_t_derivative_order5_hex(r, s, t, test_t.data());
  } else if (order == 6) {
    interpolate_r_derivative_order6_hex(r, s, t, test_r.data());
    interpolate_s_derivative_order6_hex(r, s, t, test_s.data());
    interpolate_t_derivative_order6_hex(r, s, t, test_t.data());
  } else if (order == 7) {
    interpolate_r_derivative_order7_hex(r, s, t, test_r.data());
    interpolate_s_derivative_order7_hex(r, s, t, test_s.data());
    interpolate_t_derivative_order7_hex(r, s, t, test_t.data());
  }
  #if HEX_MAX_ORDER > 7
  else if (order == 8) {
    interpolate_r_derivative_order8_hex(r, s, t, test_r.data());
    interpolate_s_derivative_order8_hex(r, s, t, test_s.data());
    interpolate_t_derivative_order8_hex(r, s, t, test_t.data());
  } else if (order == 9) {
    interpolate_r_derivative_order9_hex(r, s, t, test_r.data());
    interpolate_s_derivative_order9_hex(r, s, t, test_s.data());
    interpolate_t_derivative_order9_hex(r, s, t, test_t.data());
  }
  #endif
  else {
    ERROR() << "Order " << order << " not supported";
  }
  RealMat ret(size, 3);
  ret.col(0) = test_r; ret.col(1) = test_s; ret.col(2) = test_t;
  return ret;
}
示例#4
0
/**
    Run all tests on format library.
**/
static void run_tests( void )
{
    test();
    test_pc();
    test_cC();
    test_n();
    test_s();
    test_p();
    test_di();
    test_bouxX();
    test_eEfFgG();
    test_asterisk();
    test_cont();

    printf( "-----------------------\n"
            "Overall: %s\n", f ? "FAIL" : "PASS" );
}
示例#5
0
/**
    Run all tests on format library.
**/
static void run_tests( void )
{
    test();
    test_pc();
    test_cC();
    test_n();
    test_s();
    test_p();
    test_di();
    test_bouxX();
    test_eEfFgG();
    test_k();
    test_asterisk();
    test_cont();

    printf( "-----------------------\n"
            "Summary: %s (%u failures)\n", f ? "FAIL" : "PASS", f );
}
示例#6
0
static void TestS(void)
{
    static char *strs[] = {
	"",
	"a",
	"abc",
	"abcde",
	"abcdefABCDEF",
	"abcdefghijklmnopqrstuvwxyz0123456789!@#$"
	    "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$"
	    "abcdefghijklmnopqrstuvwxyz0123456789!@#$",
    };
    /* '0' is not relevant to printing strings */
    static char *signs[] = {
	"",
	"-",	"+",	" ",
	"-+",	"- ",	"+-",	"+ ",	" -",	" +",
	"-+ ",	"- +",	"+- ",	"+ -",	" -+",	" +-",
    };
    static char *precs[] = {
	"", "3", "5", "43",
	".3", ".43",
	"7.3", "7.5", "7.11", "7.43",
    };
    static char *formats[] = { "s" };
    int f, s, n, p;
    char fmt[40];

    for (f = 0; f < countof(formats); f++) {
	for (s = 0; s < countof(signs); s++) {
	    for (p = 0; p < countof(precs); p++) {
		fmt[0] = '%';
		fmt[1] = 0;
		if (signs[s]) strcat(fmt+strlen(fmt), signs[s]);
		if (precs[p]) strcat(fmt+strlen(fmt), precs[p]);
		if (formats[f]) strcat(fmt+strlen(fmt), formats[f]);
		for (n = 0; n < countof(strs); n++) {
		    test_s(fmt, strs[n]);
		}
	    }
	}
    }
}
示例#7
0
文件: join.cpp 项目: yekm/sandbox
int main(int argc, const char *argv[])
{
    size_t sum = 0;
    common::Timer t1;
    for (int i=0; i<1e4; ++i)
        sum += test_v(1000).size();
    std::cout << sum << " "<< t1 << "\n";

    sum=0;
    t1.restart();
    for (int i=0; i<1e4; ++i)
        sum += test_a(1000).size();
    std::cout << sum << " "<< t1 << "\n";

    sum=0;
    t1.restart();
    for (int i=0; i<1e4; ++i)
        sum += test_s(1000).size();
    std::cout << sum << " "<< t1 << "\n";

    return 0;
}