static void test_unstr_strpos(void) { unstr_t *emp = unstr_init_memory(1); unstr_t *text = unstr_init_memory(1); unstr_t *search = unstr_init_memory(1); unstr_strcpy_char(text, "0123456789"); unstr_strcpy_char(search, "34"); check_assert(unstr_strpos(NULL, search) < 0); check_assert(unstr_strpos(emp, search) < 0); check_assert(unstr_strpos(text, NULL) < 0); check_assert(unstr_strpos(text, emp) < 0); unstr_strcpy_char(text, "0123456789"); unstr_strcpy_char(search, "34"); check_int(unstr_strpos(text, search), 3); unstr_strcpy_char(text, "000123456789"); unstr_strcpy_char(search, "0"); check_int(unstr_strpos(text, search), 0); unstr_strcpy_char(text, "0123456789"); unstr_strcpy_char(search, "aaa"); check_assert(unstr_strpos(text, search) < 0); unstr_delete(3, emp, text, search); }
void test_read_element_id_with_full_buffer() { uint32_t id = 0; size_t pos = 0; uint8_t id_ebml[] = { 0x1A, 0x45, 0xDF, 0xA3, 0, 0, 0, 0 }; id = ebml_read_element_id(id_ebml, sizeof(id_ebml), &pos); check(id == 0x1A45DFA3); check_int(pos, 4); uint8_t id_timecode_scale[] = { 0x2A, 0xD7, 0xB1, 0, 0, 0, 0 }; pos = 0; id = ebml_read_element_id(id_timecode_scale, sizeof(id_timecode_scale), &pos); check(id == 0x2AD7B1); check_int(pos, 3); uint8_t id_ebml_version[] = { 0x42, 0x86, 0, 0, 0, 0 }; pos = 0; id = ebml_read_element_id(id_ebml_version, sizeof(id_ebml_version), &pos); check(id == 0x4286); check_int(pos, 2); uint8_t id_void[] = { 0xEC, 0, 0, 0, 0 }; pos = 0; id = ebml_read_element_id(id_void, sizeof(id_void), &pos); check(id == 0xEC); check_int(pos, 1); }
void test_read_int_and_uint() { char* buffer_ptr = NULL; size_t buffer_size = 0, pos = 0; FILE* f = open_memstream(&buffer_ptr, &buffer_size); ebml_element_uint(f, MKV_TimecodeScale, 0x0102030405060708); ebml_element_int(f, MKV_TimecodeScale, -1000000); ebml_element_int(f, MKV_TimecodeScale, 1000000); fclose(f); ebml_elem_t e = ebml_read_element(buffer_ptr, buffer_size, &pos); check(e.id == MKV_TimecodeScale); check_int(e.header_size, 3 + 1); uint64_t uvalue = ebml_read_uint(e.data_ptr, e.data_size); check_int(uvalue, 0x0102030405060708); e = ebml_read_element(buffer_ptr, buffer_size, &pos); check(e.id == MKV_TimecodeScale); int64_t ivalue = ebml_read_int(e.data_ptr, e.data_size); check_int(ivalue, -1000000); e = ebml_read_element(buffer_ptr, buffer_size, &pos); check(e.id == MKV_TimecodeScale); ivalue = ebml_read_int(e.data_ptr, e.data_size); check_int(ivalue, 1000000); free(buffer_ptr); }
static void test_unstr_strlen(void) { unstr_t *str = unstr_init("1234567890"); check_int(unstr_strlen(NULL), 0); check_int(unstr_strlen(str), 10); unstr_zero(str); check_int(unstr_strlen(str), 0); unstr_free(str); }
void foo (void) { aligned j; void bar () { aligned i; if (check_int (&i, __alignof__(i)) != i) abort (); if (check_int (&j, __alignof__(j)) != j) abort (); j = -20; }
LUA_API int LglutCreateMenuWindow(lua_State *L) { int win = check_int(L, 1); int x = check_int(L, 2); int y = check_int(L, 3); int width = check_int(L, 4); int height = check_int(L, 5); int id = glutCreateMenuWindow(win, x, y, width, height); alloc_wintable(L, id, win); lua_pushnumber(L, id); return 1; }
void test_str_ncmp() { const char *str1 = "foo"; const char *str2 = "foo2"; const char *str3 = "fun"; int result; result = str_ncmp(str1, sizeof(str1), str1, sizeof(str1)); check_int(result, 0); result = str_ncmp(str1, sizeof(str1), str2, sizeof(str2)); check_int(result, 0); result = str_ncmp(str1, sizeof(str1), str3, sizeof(str3)); check_int(result, 0); }
static void test_unstr_substr_count_char(void) { unstr_t *emp = unstr_init_memory(1); unstr_t *text = unstr_init("unkokkokokkokokkokokekokko"); char *search = "ko"; check_int(unstr_substr_count_char(NULL, search), 0); check_int(unstr_substr_count_char(emp, search), 0); check_int(unstr_substr_count_char(text, NULL), 0); check_int(unstr_substr_count_char(text, ""), 0); check_int(unstr_substr_count_char(text, search), 9); unstr_delete(2, emp, text); }
void test_read_data_size_error_cases() { uint8_t buffer[] = { 0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE }; uint64_t value = 0; size_t pos = 0; for(size_t i = 0; i < 8; i++) { value = ebml_read_data_size(&buffer, 0, &pos); check_int(value, 0); check_int(pos, 0); } value = ebml_read_data_size(&buffer, 8, &pos); check_int(value, 0x00FFFFFFFFFFFFFE); check_int(pos, 8); }
int test_inc(int verbose, const char *v1, const char *v2, const char *expect) { int err, failures; unsigned char bytes_buf1[20]; unsigned char bytes_buf2[20]; struct ehbigint bi1, bi2; bi1.bytes = bytes_buf1; bi1.bytes_len = 20; bi1.sign = 0; bi2.bytes = bytes_buf2; bi2.bytes_len = 20; bi2.sign = 0; VERBOSE_ANNOUNCE(verbose); failures = 0; err = ehbi_set_decimal_string(&bi1, v1, strlen(v1)); err += ehbi_set_decimal_string(&bi2, v2, strlen(v2)); err += ehbi_inc(&bi1, &bi2); if (err) { Test_log_error1("error %d from ehbi_inc\n", err); Test_log_error("Aborting test\n"); return (1 + failures); } failures += check_ehbigint_dec(&bi1, expect, __LINE__, TEST_FUNC); check_int(bi1.sign, expect[0] == '-'); if (failures) { Test_log_error1("%d failures in test_inc\n", failures); } return failures; }
static void test_unstr_zero(void) { unstr_t *str = unstr_init("unkokkokussakusa"); unstr_zero(str); check_int(str->length, 0); unstr_free(str); }
void test_a_to_i() { int result, expected_result; result = a_to_i("7", 2); expected_result = 7; check_int(result, expected_result); result = a_to_i("4211", 5); expected_result = 4211; check_int(result, expected_result); result = a_to_i(" -2 ", 5); expected_result = -2; check_int(result, expected_result); }
void foo (void *frame, uword_t error_code) { aligned j; if (check_int (frame, &j, __alignof__(j))) __builtin_abort (); }
void test_read_data_size_with_full_buffer() { uint64_t samples[] = { 1, 126, 16382, 2097150, 268435454, 34359738366, 4398046511102, 562949953421310, 72057594037927934 }; char* buffer = NULL; size_t buffer_size = 0, pos = 0; FILE* f = open_memstream(&buffer, &buffer_size); for(size_t i = 0; i < sizeof(samples) / sizeof(samples[0]); i++) ebml_write_data_size(f, samples[i], 0); fclose(f); for(size_t i = 0; i < sizeof(samples) / sizeof(samples[0]); i++) { uint64_t value = ebml_read_data_size(buffer + pos, buffer_size - pos, &pos); check_msg(value == samples[i], "got %llu, expected %llu\n", value, samples[i]); } check_int(pos, buffer_size); }
TInt CTestFloat_blr::remquo_remcheck_test() { // Create temporary variables in stack char chParam[MAX_SIZE]; FLOAT input1; FLOAT input2; int iPart; FLOAT expected_fPart; FLOAT expected_iPart; FLOAT max_ulp; FLOAT gen_ulp; // Read parameters ReadStringParam ( chParam); ReadFloatParam ( input1); ReadFloatParam ( input2); ReadFloatParam ( expected_fPart); ReadFloatParam ( expected_iPart); ReadFloatParam ( max_ulp); // TBuf<MAX_SIZE> buf; TInt len = strlen(chParam); for (TInt j =0; j<len;j++) { buf.Append(chParam[j]); } // Do some testing FLOAT res = FUNC(remquo) (input1, input2, &iPart); if( check_int(iPart, expected_iPart, max_ulp) &&check_float(res, expected_fPart, max_ulp, gen_ulp) ) { INFO_PRINTF1(_L("Test passed.")); } else { ERR_PRINTF1(_L("Test Failed.")); return KErrGeneral; } INFO_PRINTF1(_L("_________________________________________\n")); INFO_PRINTF2(_L("TestCase : %S\n"), &buf); INFO_PRINTF2(_L("Input Value 1 : %f\n"), input1 ); INFO_PRINTF2(_L("Input Value 2 : %f\n"), input1 ); INFO_PRINTF2(_L("Expected iPart : %f\n"), expected_fPart ); INFO_PRINTF2(_L("Expected iPart : %f\n"), expected_iPart ); INFO_PRINTF2(_L("Max ULP value : %f\n"), max_ulp ); INFO_PRINTF2(_L("Result fPart : %f\n"), res ); INFO_PRINTF2(_L("Result iPart : %d\n"), iPart ); INFO_PRINTF2(_L("Generated Ulp : %f\n"), gen_ulp ); INFO_PRINTF1(_L("_________________________________________\n")); return KErrNone; }
foo () { int __attribute__ ((aligned(64))) a=1; if (check_int (&a, __alignof__(a)) != a) abort (); ALTER_REGS(); throw a; }
LUA_API int LglutDestroyWindow(lua_State *L) { int id = check_int(L, 1); glutDestroyWindow(id); dealloc_wintable(L, id); return 0; }
void foo (void) { aligned i; if (check_int (&i, __alignof__(i)) != i) abort (); }
foo (__m128 x, __m128 y ,__m128 z ,__m128 a, int size) { aligned i; if (size != 5 || check_int (&i, __alignof__(i)) != i) abort (); r = a; }
static void test_unstr_substr_count(void) { unstr_t *emp = unstr_init_memory(1); unstr_t *text = unstr_init_memory(1); unstr_t *search = unstr_init_memory(1); unstr_strcpy_char(text, "unkokkokokkokokkokokekokko"); unstr_strcpy_char(search, "ko"); check_int(unstr_substr_count(NULL, search), 0); check_int(unstr_substr_count(emp, search), 0); check_int(unstr_substr_count(text, NULL), 0); check_int(unstr_substr_count(text, emp), 0); unstr_strcpy_char(text, "unkokkokokkokokkokokekokko"); unstr_strcpy_char(search, "ko"); check_int(unstr_substr_count(text, search), 9); unstr_delete(3, emp, text, search); }
void foo (void) throw (B,A) { aligned i; if (check_int (&i, __alignof__(i)) != i) abort (); throw A(); }
static int rbody_get_part_enabled (lua_State *L) { TRY_START check_args(L, 2); GET_UD_MACRO(RigidBody, self, 1, RBODY_TAG); int i = (int)check_int(L, 2, 0, self.getNumElements()-1); lua_pushboolean(L, self.getElementEnabled(i)); return 1; TRY_END }
TInt CTestFloat_blr::gamma_test() { // Create temporary variables in stack char chParam[MAX_SIZE]; FLOAT input1; FLOAT signgam_exp; FLOAT expected; FLOAT max_ulp; FLOAT gen_ulp; // Read parameters ReadStringParam ( chParam); ReadFloatParam ( input1); ReadFloatParam ( expected); ReadFloatParam ( signgam_exp); ReadFloatParam ( max_ulp); // TBuf<MAX_SIZE> buf; TInt len = strlen(chParam); for (TInt j =0; j<len;j++) { buf.Append(chParam[j]); } // Do some testing signgam = 0; FLOAT res = FUNC(gamma) (input1); if( check_float(res, expected, max_ulp, gen_ulp) && check_int((TInt)signgam_exp,signgam, 0)) { INFO_PRINTF1(_L("Test passed.")); } else { ERR_PRINTF1(_L("Test Failed.")); return KErrGeneral; } INFO_PRINTF1(_L("_________________________________________\n")); INFO_PRINTF2(_L("TestCase : %S\n"), &buf); INFO_PRINTF2(_L("Input Value : %f\n"), input1 ); INFO_PRINTF2(_L("Expected Res : %f\n"), expected ); INFO_PRINTF2(_L("Expected signagam : %f\n"), signgam_exp ); INFO_PRINTF2(_L("Max ULP value : %f\n"), max_ulp ); INFO_PRINTF2(_L("Result : %f\n"), res ); INFO_PRINTF2(_L("Obtained Signgam : %d\n"), signgam ); INFO_PRINTF2(_L("Generated Ulp : %f\n"), gen_ulp ); INFO_PRINTF1(_L("_________________________________________\n")); return KErrNone; }
static int rbody_get_part_orientation_offset (lua_State *L) { TRY_START check_args(L, 2); GET_UD_MACRO(RigidBody, self, 1, RBODY_TAG); int i = (int)check_int(L, 2, 0, self.getNumElements()-1); Quaternion q = self.getElementOrientationOffset(i); lua_pushnumber(L, q.w); lua_pushnumber(L, q.x); lua_pushnumber(L, q.y); lua_pushnumber(L, q.z); return 4; TRY_END }
static int rbody_set_part_enabled (lua_State *L) { TRY_START check_args(L, 3); GET_UD_MACRO(RigidBody, self, 1, RBODY_TAG); int i = (int)check_int(L, 2, 0, self.getNumElements()-1); bool b = check_bool(L, 3); self.setElementEnabled(i, b); return 0; TRY_END }
static int rbody_set_part_position_offset (lua_State *L) { TRY_START check_args(L, 3); GET_UD_MACRO(RigidBody, self, 1, RBODY_TAG); int i = (int)check_int(L, 2, 0, self.getNumElements()-1); Vector3 v = check_v3(L, 3); self.setElementPositionOffset(i, v); return 0; TRY_END }
static int rbody_set_part_orientation_offset (lua_State *L) { TRY_START check_args(L, 3); GET_UD_MACRO(RigidBody, self, 1, RBODY_TAG); int i = (int)check_int(L, 2, 0, self.getNumElements()-1); Quaternion q = check_quat(L, 3); self.setElementOrientationOffset(i, q); return 0; TRY_END }
void foo (int j, int k, int m, int n, int o) { aligned i; if (check_int (&i, __alignof__(i)) != i) abort (); if (i != 20 || j != 1 || k != 2 || m != 3 || n != 4 || o != 5) abort (); }
foo (void) #if __cplusplus <= 201402L throw (B,A) // { dg-warning "deprecated" "" { target { c++11 && { ! c++1z } } } } #endif { aligned i; if (check_int (&i, __alignof__(i)) != i) abort (); throw A(); }
static int rbody_get_part_position_offset (lua_State *L) { TRY_START check_args(L, 2); GET_UD_MACRO(RigidBody, self, 1, RBODY_TAG); int i = (int)check_int(L, 2, 0, self.getNumElements()-1); Vector3 v = self.getElementPositionOffset(i); lua_pushnumber(L, v.x); lua_pushnumber(L, v.y); lua_pushnumber(L, v.z); return 3; TRY_END }