void Test_Variant::run() { test_int(); test_float(); test_double(); test_string(); }
int main() { test_int() ; test_double() ; return 0 ; }
static int test_doubles(void) { plan(27); header(); test_double((double) 1.0, "\xcb\x3f\xf0\x00\x00\x00\x00\x00\x00", 9); test_double((double) 3.141592653589793, "\xcb\x40\x09\x21\xfb\x54\x44\x2d\x18", 9); test_double((double) -1e99, "\xcb\xd4\x7d\x42\xae\xa2\x87\x9f\x2e", 9); footer(); return check_plan(); }
int main () { test_float (); test_double (); test_long_double (); return 0; }
void test_leak() { for (;;) { test_int(); test_double(); test_charP(); test_String(); } }
TEST(test_encode_decode, test_double) { test_double(0.0, "0000000000000000"); test_double(-1.0, "000000000000f0bf"); test_double(3.14159265359, "ea2e4454fb210940"); test_double(std::numeric_limits<double>::infinity(), "000000000000f07f"); test_double(-std::numeric_limits<double>::infinity(), "000000000000f0ff"); test_double(std::numeric_limits<double>::quiet_NaN(), "000000000000f87f"); test_double(std::numeric_limits<double>::signaling_NaN(), "000000000000f47f"); }
int main(int argc, char **argv) { test_basic(); test_many_chars(); test_uint(); test_char_array(); test_double(); test_vec(); test_vec_array(); return 0; }
int main (void) { START("CoolQueue"); test_int(); test_double(); test_charP(); test_String(); #if LEAK test_leak(); #endif SUMMARY(); return 0; }
int main() { test_char(); test_uchar(); test_short(); test_ushort(); test_int(); test_uint(); test_long(); test_ulong(); test_float(); test_double(); return 0; }
int main() { int i, j; if ((i = test_single())) printf("WARNING: Single-precision " "floating point math might be broken\n"); if ((j = test_double())) printf("WARNING: Double-precision " "floating point math might be broken\n"); i += j; if (i == 0) printf("floating point math appears to work\n"); return i; }
int main(int, char**) { plan_tests(69); test_integrals(); test_strings(); test_pointers(); test_double(); test_concat(); test_suffix(); test_to(); test_path_cat(); test_basename_dirname(); test_operator(); test_split(); return exit_status(); }
int main (void) { err = 0; test_float (); test_double (); test_long_double (); test_int (); test_long_int (); if (err != 0) abort (); return 0; }
int main () { test_float (); test_double (); { DECL_LONG_DOUBLE_ROUNDING BEGIN_LONG_DOUBLE_ROUNDING (); test_long_double (); END_LONG_DOUBLE_ROUNDING (); } return 0; }
int main (int , char **) { test_vector (); test_map (); test_integer_vector (); test_double_vector (); test_string_vector (); test_integer (); test_double (); test_map_exchanges (); test_vector_exchanges (); test_native_vectors (); test_queue (); test_vector_transfer (); test_flex_map (); test_collection (); return 0; }
int main(int argc, char** argv) { printf("TRIE TESTS\n"); printf("==================\n\n"); init (argc, argv); test_minimaltrie(); test_simple(); test_iterate(); test_reviterate(); test_moreiterate(); test_revmoreiterate(); test_umlauts(); test_endings(); test_root(); test_double(); test_emptyvalues(); printf("\ntest_trie RESULTS: %d test(s) done. %d error(s).\n", nbTest, nbError); return nbError; }
static int do_test (void) { void *buf; unsigned int j; int result = 0; buf = mmap64 (0, CONST_10G, PROT_READ, MAP_ANONYMOUS | MAP_PRIVATE, -1, 0); if (buf == MAP_FAILED) { puts ("Could not allocate 10 GB via mmap, skipping test."); return 0; } for (j = 0; j < sizeof (test_data) / sizeof (struct test_data_s); j++) { if (test_single (buf, test_data[j].len, test_data[j].ref)) result = 1; if (test_double (buf, test_data[j].len, test_data[j].ref)) result = 1; } return result; }
int main( int argc , char ** argv) { test_int(); test_double(); test_float(); exit(0); }
void piglit_init(int argc, char **argv) { bool pass = true; int gl_version; int glsl_major; int glsl_minor; int glsl_version; const char *version_for_float_shader = NULL; const char *version_for_double_shader = NULL; const char *version_for_int_shader = NULL; GLint context_flags = 0; piglit_require_vertex_shader(); piglit_require_extension("GL_ARB_separate_shader_objects"); gl_version = piglit_get_gl_version(); if (gl_version >= 30) glGetIntegerv(GL_CONTEXT_FLAGS, &context_flags); piglit_get_glsl_version(NULL, &glsl_major, &glsl_minor); glsl_version = (glsl_major * 100) + glsl_minor; /* Select a shading language version string based on the GL version * and whether or not we're running in a core profile. */ switch (gl_version / 10) { case 1: case 2: /* Selecting 1.20 will enable the non-square matrix tests. */ version_for_float_shader = (glsl_version >= 120) ? "#version 120\n" : "#version 110\n"; if (glsl_version >= 130) version_for_int_shader = "#version 130\n"; break; case 3: /* OpenGL 3.0 deprecated GLSL 1.10 and 1.20. OpenGL 3.1 * removed almost all deprecated features. * Forworad-compatible contexts remove all deprecated * features. */ if (gl_version == 30) { version_for_float_shader = (context_flags & GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT) ? "#version 130\n" : "#version 120\n"; version_for_int_shader = "#version 130\n"; } else { /* Section 1.6.1 (OpenGL Shading Language) of the * OpenGL 3.1 spec says: * * "OpenGL 3.1 implementations are guaranteed to * support at least version 1.30 of the shading * language." * * This is likely a copy-and-paste error from version * 3.0. This should be 1.40. * * Section 1.6.1 (OpenGL Shading Language) of the * OpenGL 3.2 spec says: * * "OpenGL 3.2 implementations are guaranteed to * support versions 1.40 and 1.50 of the OpenGL * Shading Language." * * Section 1.7.1 (OpenGL Shading Language) of the * OpenGL 3.3 spec says: * * "OpenGL 3.3 implementations are guaranteed to * support version 3.30 of the OpenGL Shading * Language." * * Based on all of this, pick version 1.40 for OpenGL * versions before 3.3, and version 3.30 for version * 3.3. */ if (gl_version < 33) { version_for_float_shader = "#version 140\n"; version_for_int_shader = "#version 140\n"; } else { version_for_float_shader = "#version 330 core\n"; version_for_int_shader = "#version 330 core\n"; } if (piglit_is_extension_supported("GL_ARB_gpu_shader_fp64")) { /* The GL_ARB_gpu_shader_fp64 extensions spec * says: * * "OpenGL 3.2 and GLSL 1.50 are required." */ version_for_double_shader = "#version 150 core\n" "#extension GL_ARB_gpu_shader_fp64: require\n" ; } } break; case 4: /* Section 1.7.1 (OpenGL Shading Language) of the * OpenGL 4.0 spec says: * * "OpenGL 4.0 implementations are guaranteed to support * version 4.00 of the OpenGL Shading Language." * * Section 1.7.1 (OpenGL Shading Language) of the * OpenGL 4.1 spec says: * * "OpenGL 4.1 implementations are guaranteed to support * version 4.10 of the OpenGL Shading Language." * * Section 1.7.1 (OpenGL Shading Language) of the * OpenGL 4.2 spec says: * * "OpenGL 4.2 implementations are guaranteed to support * version 4.20 of the OpenGL Shading Language....The core * profile of OpenGL 4.2 is also guaranteed to support all * previous versions of the OpenGL Shading Language back * to version 1.40." * * Section 1.3.1 (OpenGL Shading Language) of the * OpenGL 4.3 spec says: * * "OpenGL 4.3 implementations are guaranteed to support * version 4.30 of the OpenGL Shading Language....The core * profile of OpenGL 4.3 is also guaranteed to support all * previous versions of the OpenGL Shading Language back * to version 1.40." * * Section 1.3.1 (OpenGL Shading Language) of the * OpenGL 4.4 spec says: * * "OpenGL 4.4 implementations are guaranteed to support * version 4.40 of the OpenGL Shading Language....The core * profile of OpenGL 4.4 is also guaranteed to support all * previous versions of the OpenGL Shading Language back * to version 1.40." * * Even though 4.1 doesn't say anything about GLSL 4.00, the * inference is that the addition starting in 4.2 was a * clarification. */ version_for_float_shader = "#version 400 core\n"; version_for_double_shader = "#version 400 core\n"; version_for_int_shader = "#version 400 core\n"; break; default: fprintf(stderr, "Unknown GL version!\n"); piglit_report_result(PIGLIT_FAIL); } pass = test_float(version_for_float_shader) && pass; pass = test_square_mat(version_for_float_shader) && pass; pass = test_nonsquare_mat(version_for_float_shader) && pass; pass = test_int(version_for_int_shader) && pass; pass = test_uint(version_for_int_shader) && pass; pass = test_double(version_for_double_shader) && pass; pass = test_dmat(version_for_double_shader) && pass; piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL); }
void xml_test() { FILE *f = fopen("test.xml", "w"); if (!f) asfPrintError("Failed to open test.xml.\n"); fprintf(f, "%s", "<CornerReflectorCoordinateListDelta>" "<CornerReflectorDescriptor>\n" " <ReflectorNumber type=\"string\">DJ1</ReflectorNumber>\n" " <RespOrbDir>DESCENDING</RespOrbDir>\n" " <StartDate>19920313</StartDate>\n" " <EndDate>19971103</EndDate>\n" " <SiteName>Gerstle_River</SiteName>\n" " <Notes>NULL</Notes>\n" " <UTM_North>7077183.015</UTM_North>\n" " <UTM_East>598098.981</UTM_East>\n" " <UTM_Zone>6</UTM_Zone>\n" " <GeographicLat>63.80829694</GeographicLat>\n" " <GeographicLon>-145.007776389</GeographicLon>\n" " <Height>452.1</Height>\n" " <RefEllipsoid>WGS84</RefEllipsoid>\n" " <TestingAttributes attr=\"testattrvalue\">Val</TestingAttributes>" "</CornerReflectorDescriptor>" "<CornerReflectorDescriptor>" " <ReflectorNumber>DJ2</ReflectorNumber>" " <RespOrbDir>ASCENDING</RespOrbDir>" " <StartDate>19920709</StartDate>" " <EndDate>19970714</EndDate>" " <SiteName>Gerstle_River</SiteName>" " <Notes>NULL</Notes>" " <UTM_North>7077022.411</UTM_North>" " <UTM_East>598411.301</UTM_East>" " <UTM_Zone>6</UTM_Zone>" " <GeographicLat>63.806769</GeographicLat>" " <GeographicLon>-145.00154028</GeographicLon>" " <Height>451.9</Height>" " <RefEllipsoid>WGS84</RefEllipsoid>" " <NestedListTest>" " <ListItem id=\"1\">" " <A>A1</A>" " <AA>AA1</AA>" " <Bb>1_Bb</Bb>" " <BB bb=\"bb1\">1_BB</BB>" " </ListItem>" " <ListItem id=\"2\" attr2=\"oops\">" " <A>A2</A>" " <AA>AA2</AA>" " <Bb dbl=\"17.818\">2_Bb</Bb>" " <BB bb=\"bb2\">2_BB</BB>" " </ListItem>" " </NestedListTest>" "</CornerReflectorDescriptor>" "<CornerReflectorDescriptor>" " <ReflectorNumber>DJ3</ReflectorNumber>" " <RespOrbDir>DESCENDING</RespOrbDir>" " <StartDate>19920116</StartDate>" " <EndDate>19960125</EndDate>" " <SiteName>UAF_Ag_Farm</SiteName>" " <Notes>NULL</Notes>" " <UTM_North>7090249.346</UTM_North>" " <UTM_East>581677.867</UTM_East>" " <UTM_Zone>6</UTM_Zone>" " <GeographicLat>63.92972</GeographicLat>" " <GeographicLon>-145.33415</GeographicLon>" " <Height>375.1</Height>" " <RefEllipsoid>WGS84</RefEllipsoid>" "</CornerReflectorDescriptor>" "<CornerReflectorDescriptor>" " <ReflectorNumber>DJ4</ReflectorNumber>" " <RespOrbDir>ASCENDING</RespOrbDir>" " <StartDate>19951010</StartDate>" " <EndDate>19971006</EndDate>" " <SiteName>UAF_Ag_Farm</SiteName>" " <Notes>NULL</Notes>" " <UTM_North>7089984.631</UTM_North>" " <UTM_East>582207.175</UTM_East>" " <UTM_Zone>6</UTM_Zone>" " <GeographicLat>63.9272208</GeographicLat>" " <GeographicLon>-145.3235</GeographicLon>" " <Height>376.3</Height>" " <RefEllipsoid>WGS84</RefEllipsoid>" "</CornerReflectorDescriptor>" "</CornerReflectorCoordinateListDelta>" ); fclose(f); xmlDoc *doc = xmlReadFile("test.xml", NULL, 0); if (!doc) asfPrintError("Could not read 'test.xml'\n"); test_string(doc, TOP "." DESC "[0].ReflectorNumber", "DJ1"); test_string2(doc, "DJ1", TOP "." DESC "[%d].ReflectorNumber", 0); test_string(doc, TOP "." DESC "[1].ReflectorNumber", "DJ2"); test_string2(doc, "DJ2", TOP "." DESC "[%d].ReflectorNumber", 1); test_string(doc, TOP "." DESC "[2].ReflectorNumber", "DJ3"); test_string(doc, TOP "." DESC "[3].ReflectorNumber", "DJ4"); test_string(doc, TOP "." DESC "[4].ReflectorNumber", MAGIC_UNSET_STRING); test_string(doc, TOP "." DESC "[0].RespOrbDir", "DESCENDING"); test_string2(doc, "DESCENDING", TOP "." DESC "[%d].RespOrbDir", 0); test_string(doc, TOP "." DESC "[1].RespOrbDir", "ASCENDING"); test_string(doc, TOP "." DESC "[0].SiteName", "Gerstle_River"); test_int(doc, TOP "." DESC "[0].StartDate", 19920313); test_int(doc, TOP "." DESC "[0].EndDate", 19971103); test_double(doc, TOP "." DESC "[0].GeographicLat", 63.80829694); test_double(doc, TOP "." DESC "[0].GeographicLon", -145.007776389); test_double(doc, TOP "." DESC "[0].Height", 452.1); test_string(doc, TOP "." DESC "[0].RefEllipsoid", "WGS84"); test_string(doc, TOP "." DESC "[0].TestingAttributes", "Val"); test_int(doc, TOP "." DESC "[0].UTM_Zone", 6); test_string(doc, TOP "." DESC "[1].SiteName", "Gerstle_River"); test_int(doc, TOP "." DESC "[1].StartDate", 19920709); test_int(doc, TOP "." DESC "[1].EndDate", 19970714); test_double(doc, TOP "." DESC "[1].GeographicLat", 63.806769); test_double(doc, TOP "." DESC "[1].GeographicLon", -145.00154028); test_double(doc, TOP "." DESC "[1].Height", 451.9); test_string(doc, TOP "." DESC "[1].RefEllipsoid", "WGS84"); test_string(doc, TOP "." DESC "[2].SiteName", "UAF_Ag_Farm"); test_int(doc, TOP "." DESC "[2].StartDate", 19920116); test_int(doc, TOP "." DESC "[2].EndDate", 19960125); test_double(doc, TOP "." DESC "[2].GeographicLat", 63.92972); test_double(doc, TOP "." DESC "[2].GeographicLon", -145.33415); test_double(doc, TOP "." DESC "[2].Height", 375.1); test_string(doc, TOP "." DESC "[2].RefEllipsoid", "WGS84"); test_string(doc, TOP "." DESC "[3].SiteName", "UAF_Ag_Farm"); test_int(doc, TOP "." DESC "[3].StartDate", 19951010); test_int(doc, TOP "." DESC "[3].EndDate", 19971006); test_double(doc, TOP "." DESC "[3].GeographicLat", 63.9272208); test_double(doc, TOP "." DESC "[3].GeographicLon", -145.3235); test_double(doc, TOP "." DESC "[3].Height", 376.3); test_string(doc, TOP "." DESC "[3].RefEllipsoid", "WGS84"); test_string(doc, TOP "." DESC "[4].SiteName", MAGIC_UNSET_STRING); test_string(doc, TOP "." DESC "[1].NestedListTest.ListItem[0].A", "A1"); test_string3(doc, "A1", TOP "." DESC "[%d].NestedListTest.ListItem[%d].A", 1, 0); test_string(doc, TOP "." DESC "[1].NestedListTest.ListItem[1].A", "A2"); test_string3(doc, "A2", TOP "." DESC "[%d].NestedListTest.ListItem[%d].A", 1, 1); test_string(doc, TOP "." DESC "[1].NestedListTest.ListItem[0].AA", "AA1"); test_string(doc, TOP "." DESC "[1].NestedListTest.ListItem[1].AA", "AA2"); test_string(doc, TOP "." DESC "[1].NestedListTest.ListItem[0].Bb", "1_Bb"); test_string3(doc, "1_Bb", TOP "." DESC "[%d].NestedListTest.ListItem[%d].Bb", 1, 0); test_string(doc, TOP "." DESC "[1].NestedListTest.ListItem[1].Bb", "2_Bb"); test_string(doc, TOP "." DESC "[1].NestedListTest.ListItem[0].BB", "1_BB"); test_string(doc, TOP "." DESC "[1].NestedListTest.ListItem[1].BB", "2_BB"); test_string3(doc, "2_BB", TOP "." DESC "[%d].NestedListTest.ListItem[%d].BB", 1, 1); // some failure testing char *us = MAGIC_UNSET_STRING; test_string(doc, TOP "." DESC "[2].NestedListTest.ListItem[1].BB", us); test_string(doc, TOP "." DESC "[25].NestedListTest.ListItem[1].BB", us); test_string3(doc, us, TOP "." DESC "[%d].NestedListTest.ListItem[%d].BB", 25, 1); test_string(doc, TOP "." DESC "[1].NestedListTest.ListItem[4].BB", us); test_string(doc, TOP "." DESC "[1].NestedListTest.ListItem[2].A", us); test_string(doc, TOP "." DESC "[1].NestedListTest.ListItem[200].AA", us); test_string(doc, TOP "." DESC "[1].NestedListTest.ListItem[0].Arrg", us); test_string(doc, TOP "." DESC "[1].NestedListTest.ListItem.A", "A1"); test_string(doc, TOP "." DESC "[1].SiteNameXXX", us); test_int(doc, TOP "." DESC "[1].StortDate", MAGIC_UNSET_INT); test_string(doc, TOP "." DESC "[1].StortDate", us); test_double(doc, TOP "." DESC "[1].Heigth", MAGIC_UNSET_DOUBLE); test_string(doc, TOP "." DESC "[1].Heigth", us); // testing attributes test_string_attr(doc, TOP "." DESC "[0].ReflectorNumber.type", "string"); test_string_attr(doc, TOP "." DESC "[0].TestingAttributes.attr", "testattrvalue"); test_string_attr(doc, TOP "." DESC "[1].ReflectorNumber.type", us); test_int_attr(doc, TOP "." DESC "[1].NestedListTest.ListItem[0].id", 1); test_string_attr(doc, TOP "." DESC "[1].NestedListTest.ListItem[1].attr2", "oops"); test_string_attr(doc, TOP "." DESC "[1].NestedListTest.ListItem[0].BB.bb", "bb1"); test_string_attr(doc, TOP "." DESC "[1].NestedListTest.ListItem[1].BB.bb", "bb2"); test_string_attr(doc, TOP "." DESC "[1].NestedListTest.ListItem[2].BB.bb", us); test_string_attr(doc, TOP "." DESC "[1].NestedListTest.ListItem[1].Bb.bb", us); test_string_attr(doc, TOP "." DESC "[1].NestedListTest.ListItem[0].AA", us); test_double_attr(doc, TOP "." DESC "[1].NestedListTest.ListItem[1].Bb.dbl", 17.818); test_string_attr(doc, TOP "." DESC "[1].NestedListTest.ListItem[1].BB.dbl", us); test_double_attr(doc, TOP "." DESC "[1].NestedListTest.ListItem[1].BB.dbl", MAGIC_UNSET_DOUBLE); printf("Number ok: %d\n", n_ok); if (n_bad>0) printf("**** Not all tests passed!\n" "**** Number of failures: %d\n", n_bad); xmlFreeDoc(doc); xmlCleanupParser(); unlink("test.xml"); exit(1); }
static ERL_NIF_TERM type_test(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]) { int i; int sint; unsigned uint; long slong; unsigned long ulong; ErlNifSInt64 sint64; ErlNifUInt64 uint64; double d; ERL_NIF_TERM atom, ref1, ref2; sint = INT_MIN; do { if (!test_int(env,sint)) { goto error; } sint += ~sint / 3 + 1; } while (sint < 0); sint = INT_MAX; do { if (!test_int(env,sint)) { goto error; } sint -= sint / 3 + 1; } while (sint >= 0); slong = LONG_MIN; do { if (!test_long(env,slong)) { goto error; } slong += ~slong / 3 + 1; } while (slong < 0); slong = LONG_MAX; do { if (!test_long(env,slong)) { goto error; } slong -= slong / 3 + 1; } while (slong >= 0); sint64 = ((ErlNifSInt64)1 << 63); /* INT64_MIN */ do { if (!test_int64(env,sint64)) { goto error; } sint64 += ~sint64 / 3 + 1; } while (sint64 < 0); sint64 = ((ErlNifUInt64)1 << 63) - 1; /* INT64_MAX */ do { if (!test_int64(env,sint64)) { goto error; } sint64 -= sint64 / 3 + 1; } while (sint64 >= 0); uint = UINT_MAX; for (;;) { if (!test_uint(env,uint)) { goto error; } if (uint == 0) break; uint -= uint / 3 + 1; } ulong = ULONG_MAX; for (;;) { if (!test_ulong(env,ulong)) { goto error; } if (ulong == 0) break; ulong -= ulong / 3 + 1; } uint64 = (ErlNifUInt64)-1; /* UINT64_MAX */ for (;;) { if (!test_uint64(env,uint64)) { goto error; } if (uint64 == 0) break; uint64 -= uint64 / 3 + 1; } if (MAX_SMALL < INT_MAX) { /* 32-bit */ for (i=-10 ; i <= 10; i++) { if (!test_int(env,MAX_SMALL+i)) { goto error; } } for (i=-10 ; i <= 10; i++) { if (!test_int(env,MIN_SMALL+i)) { goto error; } } for (i=-10 ; i <= 10; i++) { if (!test_uint(env,MAX_SMALL+i)) { goto error; } } } assert((MAX_SMALL < INT_MAX) == (MIN_SMALL > INT_MIN)); for (i=-10 ; i < 10; i++) { if (!test_long(env,MAX_SMALL+i) || !test_ulong(env,MAX_SMALL+i) || !test_long(env,MIN_SMALL+i) || !test_int64(env,MAX_SMALL+i) || !test_uint64(env,MAX_SMALL+i) || !test_int64(env,MIN_SMALL+i)) { goto error; } if (MAX_SMALL < INT_MAX) { if (!test_int(env,MAX_SMALL+i) || !test_uint(env,MAX_SMALL+i) || !test_int(env,MIN_SMALL+i)) { goto error; } } } for (d=3.141592e-100 ; d < 1e100 ; d *= 9.97) { if (!test_double(env,d) || !test_double(env,-d)) { goto error; } } if (!enif_make_existing_atom(env,"nif_SUITE", &atom, ERL_NIF_LATIN1) || !enif_is_identical(atom,enif_make_atom(env,"nif_SUITE"))) { fprintf(stderr, "nif_SUITE not an atom?\r\n"); goto error; } for (i=2; i; i--) { if (enif_make_existing_atom(env,"nif_SUITE_pink_unicorn", &atom, ERL_NIF_LATIN1)) { fprintf(stderr, "pink unicorn exist?\r\n"); goto error; } } ref1 = enif_make_ref(env); ref2 = enif_make_ref(env); if (!enif_is_ref(env,ref1) || !enif_is_ref(env,ref2) || enif_is_identical(ref1,ref2) || enif_compare(ref1,ref2)==0) { fprintf(stderr, "strange refs?\r\n"); goto error; } return enif_make_atom(env,"ok"); error: return enif_make_atom(env,"error"); }