static void ok_sequence_(struct call_sequence **seq, int sequence_index, const struct call_entry *expected, const char *context, BOOL todo, const char *file, int line) { struct call_sequence *call_seq = seq[sequence_index]; static const struct call_entry end_of_sequence = { LastKind }; const struct call_entry *actual, *sequence; int failcount = 0; struct testcontext ctxt; add_call(seq, sequence_index, &end_of_sequence); sequence = call_seq->sequence; actual = sequence; ctxt.failcount = &failcount; ctxt.todo = todo; ctxt.file = file; ctxt.line = line; while (expected->kind != LastKind && actual->kind != LastKind) { if (expected->kind == actual->kind) { ctxt.kind = expected->kind; switch (actual->kind) { case ScriptAnalysis: test_uint(actual->sa.pos, expected->sa.pos, "position", &ctxt); test_uint(actual->sa.len, expected->sa.len, "length", &ctxt); test_uint(actual->sa.shapes, expected->sa.shapes, "shapes", &ctxt); break; default: ok(0, "%s: callback not handled, %s\n", context, get_analysis_kind_name(actual->kind)); } expected++; actual++; } else if (todo) { failcount++; todo_wine { ok_(file, line) (0, "%s: call %s was expected, but got call %s instead\n", context, get_analysis_kind_name(expected->kind), get_analysis_kind_name(actual->kind)); } flush_sequence(seq, sequence_index); return; } else { ok_(file, line) (0, "%s: call %s was expected, but got call %s instead\n", context, get_analysis_kind_name(expected->kind), get_analysis_kind_name(actual->kind)); expected++; actual++; } }
int test() { int Error(0); Error += test_uint(); Error += test_uvec4(); return Error; }
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() { int32_t a; uint32_t b; void *c; a = 0; test_int(a); a = -1; test_int(a); a = 1; test_int(a); a = -2; test_int(a); a = 2; test_int(a); a = MAX_TAG_INT-2; test_int(a); a = MAX_TAG_INT-1; test_int(a); a = MAX_TAG_INT; test_int(a); a = MIN_TAG_INT+2; test_int(a); a = MIN_TAG_INT+1; test_int(a); a = MIN_TAG_INT; test_int(a); b = 0; test_uint(b); b = 1; test_uint(b); b = 2; test_uint(b); b = MAX_TAG_UINT-2; test_uint(b); b = MAX_TAG_UINT-1; test_uint(b); b = MAX_TAG_UINT; test_uint(b); c = NULL; test_ptr(c); c = (void *) &a; test_ptr(c); c = (void *) &b; test_ptr(c); c = (void *) &c; test_ptr(c); 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; }
static int test_uints(void) { plan(135); header(); test_uint(0U, "\x00", 1); test_uint(1U, "\x01", 1); test_uint(0x7eU, "\x7e", 1); test_uint(0x7fU, "\x7f", 1); test_uint(0x80U, "\xcc\x80", 2); test_uint(0xfeU, "\xcc\xfe", 2); test_uint(0xffU, "\xcc\xff", 2); test_uint(0xfffeU, "\xcd\xff\xfe", 3); test_uint(0xffffU, "\xcd\xff\xff", 3); test_uint(0x10000U, "\xce\x00\x01\x00\x00", 5); test_uint(0xfffffffeU, "\xce\xff\xff\xff\xfe", 5); test_uint(0xffffffffU, "\xce\xff\xff\xff\xff", 5); test_uint(0x100000000ULL, "\xcf\x00\x00\x00\x01\x00\x00\x00\x00", 9); test_uint(0xfffffffffffffffeULL, "\xcf\xff\xff\xff\xff\xff\xff\xff\xfe", 9); test_uint(0xffffffffffffffffULL, "\xcf\xff\xff\xff\xff\xff\xff\xff\xff", 9); footer(); return check_plan(); }
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"); }
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); }