bool sparse_sub_hes(void) { bool ok = true; ok &= test_set("cppad.symmetric"); ok &= test_set("cppad.general"); // ok &= test_bool("cppad.symmetric"); ok &= test_bool("cppad.general"); return ok; }
int compare_localmotions(const LocalMotions* lms1, const LocalMotions* lms2){ test_bool(vs_vector_size(lms1) == vs_vector_size(lms2)); int i; for(i=0; i<vs_vector_size(lms1); i++){ test_bool(LMGet(lms1,i)->v.x == LMGet(lms2,i)->v.x); test_bool(LMGet(lms1,i)->v.y == LMGet(lms2,i)->v.y); } return 1; }
void test_checkCompareImg(const TestData* testdata){ VSMotionDetect md; VSMotionDetectConfig conf = vsMotionDetectGetDefaultConfig("test_checkCompareImg"); conf.shakiness=6; conf.accuracy=12; test_bool(vsMotionDetectInit(&md, &conf, &testdata->fi) == VS_OK); fflush(stdout); test_bool(checkCompareImg(&md,&testdata->frames[0])); vsMotionDetectionCleanup(&md); }
static int test_bools(void) { plan(18); header(); test_bool(true, "\xc3", 1); test_bool(false, "\xc2", 1); footer(); return check_plan(); }
int test_store_restore(TestData* testdata){ MotionDetect md; test_bool(initMotionDetect(&md, &testdata->fi, "test") == VS_OK); test_bool(configureMotionDetect(&md)== VS_OK); LocalMotions lms; int i; for(i=0; i<2; i++){ test_bool(motionDetection(&md, &lms,&testdata->frames[i])== VS_OK); if (i==0) vs_vector_del(&lms); } FILE* f = fopen("lmtest","w"); storeLocalmotions(f,&lms); fclose(f); f = fopen("lmtest","r"); LocalMotions test = restoreLocalmotions(f); fclose(f); storeLocalmotions(stderr,&test); compare_localmotions(&lms,&test); fprintf(stderr,"\n** LM and LMS OKAY\n"); f = fopen("lmstest","w"); md.frameNum=1; prepareFile(&md,f); writeToFile(&md,f,&lms); md.frameNum=2; writeToFile(&md,f,&test); fclose(f); f = fopen("lmstest","r"); test_bool(readFileVersion(f)==1); LocalMotions read1; test_bool(readFromFile(f,&read1)==1); compare_localmotions(&lms,&read1); LocalMotions read2; test_bool(readFromFile(f,&read2)==2); compare_localmotions(&test,&read2); fclose(f); fprintf(stderr,"** Reading file stepwise OKAY\n"); vs_vector_del(&read1); vs_vector_del(&read2); vs_vector_del(&test); vs_vector_del(&lms); f = fopen("lmstest","r"); ManyLocalMotions mlms; test_bool(readLocalMotionsFile(f,&mlms)==VS_OK); test_bool(vs_vector_size(&mlms)==2); fprintf(stderr,"** Entire file routine OKAY\n\n"); for(i=0; i< vs_vector_size(&mlms); i++){ if(MLMGet(&mlms,i)) vs_vector_del(MLMGet(&mlms,i)); } vs_vector_del(&mlms); return 1; }
void _t_common( const void *in, const void *out, const uint8_t *expected, size_t expected_size) { int i, retval; for (i = 0; i < 2; ++i) { memset( buffer, 0xFF, sizeof buffer); retval = zdo_match_desc_request( buffer, expected_size - i, TEST_ADDR, TEST_PROFILE, in, out); if (i) { if (test_compare( retval, -ENOSPC, "%ld", "supposedly fit in small buffer")) { if (retval > 0) { printf( "returned %d bytes instead of -ENOSPC:", retval); hex_dump( buffer, retval, HEX_DUMP_FLAG_TAB); } } } else if (! test_bool( retval > 0, "retval indicates error")) { compare_buffers( buffer, retval, expected, expected_size, "unexpected response"); test_compare( buffer[expected_size], 0xFF, NULL, "buffer overflow"); } } }
bool JsonIn::read(bool &b) { if (!test_bool()) { return false; } b = get_bool(); return true; }
void testmain(void) { print("basic arithmetic"); test_basic(); test_relative(); test_inc_dec(); test_bool(); test_ternary(); test_comma(); }
int test_store_restore(TestData* testdata){ VSMotionDetectConfig mdconf = vsMotionDetectGetDefaulfConfig("test_motionDetect"); VSMotionDetect md; test_bool(vsMotionDetectInit(&md, &mdconf, &testdata->fi) == VS_OK); LocalMotions lms; int i; for(i=0; i<2; i++){ test_bool(vsMotionDetection(&md, &lms,&testdata->frames[i])== VS_OK); if (i==0) vs_vector_del(&lms); } FILE* f = fopen("lmtest","w"); vsStoreLocalmotions(f,&lms); fclose(f); f = fopen("lmtest","r"); LocalMotions test = vsRestoreLocalmotions(f); fclose(f); vsStoreLocalmotions(stderr,&test); compare_localmotions(&lms,&test); fprintf(stderr,"\n** LM and LMS OKAY\n"); f = fopen("lmstest","w"); md.frameNum=1; vsPrepareFile(&md,f); vsWriteToFile(&md,f,&lms); md.frameNum=2; vsWriteToFile(&md,f,&test); fclose(f); f = fopen("lmstest","r"); test_bool(vsReadFileVersion(f)==1); LocalMotions read1; test_bool(vsReadFromFile(f,&read1)==1); compare_localmotions(&lms,&read1); LocalMotions read2; test_bool(vsReadFromFile(f,&read2)==2); compare_localmotions(&test,&read2); fclose(f); fprintf(stderr,"** Reading file stepwise OKAY\n"); vs_vector_del(&read1); vs_vector_del(&read2); vs_vector_del(&test); vs_vector_del(&lms); f = fopen("lmstest","r"); VSManyLocalMotions mlms; test_bool(vsReadLocalMotionsFile(f,&mlms)==VS_OK); test_bool(vs_vector_size(&mlms)==2); fprintf(stderr,"** Entire file routine OKAY\n\n"); for(i=0; i< vs_vector_size(&mlms); i++){ if(VSMLMGet(&mlms,i)) vs_vector_del(VSMLMGet(&mlms,i)); } vs_vector_del(&mlms); return 1; }
void generateFrames(TestData* testdata, int num){ int i; for(i=0; i<num; i++){ allocateFrame(&testdata->frames[i],&testdata->fi); } // first frame noise fillArrayWithNoise(testdata->frames[0].data[0], testdata->fi.width*testdata->fi.height, 10); fillArrayWithNoise(testdata->frames[0].data[1], testdata->fi.width/2*testdata->fi.height/2, 5); fillArrayWithNoise(testdata->frames[0].data[2], testdata->fi.width/2*testdata->fi.height/2, 5); // add rectangles int k; for(k=0; k<NUM_RECTANGLES; k++){ paintRectangle(testdata->frames[0].data[0],&testdata->fi, randUpTo(testdata->fi.width), randUpTo(testdata->fi.height), randUpTo((testdata->fi.width>>4)+4), randUpTo((testdata->fi.height>>4)+4),randPixel()); } TransformData td; test_bool(initTransformData(&td, &testdata->fi, &testdata->fi, "generate") == VS_OK); td.interpolType=Zero; test_bool(configureTransformData(&td)== VS_OK); fprintf(stderr, "testframe transforms\n"); for(i=1; i<num; i++){ Transform t = getTestFrameTransform(i); fprintf(stderr, "%i, %6.4lf %6.4lf %8.5lf %6.4lf %i\n", i, t.x, t.y, t.alpha, t.zoom, t.extra); test_bool(transformPrepare(&td,&testdata->frames[i-1],&testdata->frames[i])== VS_OK); test_bool(transformYUV_float(&td, t)== VS_OK); test_bool(transformFinish(&td)== VS_OK); } cleanupTransformData(&td); }
void run () override { test_bool (); test_bad_json (); test_edge_cases (); test_copy (); test_move (); test_comparisons (); test_compact (); test_nest_limits (); }
void t_memcheck( void) { char error[80]; int i, retval; bool_t result; for (i = 0; i < _TABLE_ENTRIES( test); ++i) { sprintf( error, "entry %u, testing for 0x%02X, expected %d", i, test[i].test_char, test[i].expected); retval = memcheck( test[i].values, test[i].test_char, test[i].length); switch (test[i].expected) { case -1: result = (retval < 0); break; case 0: result = (retval == 0); break; case +1: result = (retval > 0); break; default: result = FALSE; break; } test_bool( result, error); } test_bool( memcheck( "\xFF\xFF\xFF", 0xFF, 3) == 0, "0xFF check failed"); }
void compare_buffers( const void *actual, size_t actual_length, const void *expected, size_t expected_length, const char *error) { int passed; passed = actual_length == expected_length && (memcmp( actual, expected, expected_length) == 0); if (test_bool( passed, error) && test_verbose) { puts( "actual:"); hex_dump( actual, actual_length, HEX_DUMP_FLAG_TAB); puts( "expected:"); hex_dump( expected, expected_length, HEX_DUMP_FLAG_TAB); } }
int test_send( const wpan_envelope_t FAR *envelope, uint16_t flags) { int passed; ++response_count; passed = (envelope->length == expected_length && memcmp( envelope->payload, expected_response, expected_length) == 0); if (test_bool( passed, "received unexpected payload") && test_verbose) { printf( "unexpected %d-byte response:\n", envelope->length); hex_dump( envelope->payload, envelope->length, HEX_DUMP_FLAG_TAB); printf( "should be %d-byte response:\n", expected_length); hex_dump( expected_response, expected_length, HEX_DUMP_FLAG_TAB); } return 0; }
void testmain(void) { print("function"); expect(77, t1()); t2(79); t3(1, 2, 3, 4, 5, 6); t4(); t5(); expect(3, t6()); expect(12, t7(3, 4)); t8(23); t9(); expect(7, t10(3, 4.0)); func_ptr_call(); func_name(); empty(); empty2(); test_bool(); test_struct(); }
int main() { test_bool(); test<char>((std::numeric_limits<char>::min)(), (std::numeric_limits<char>::max)()); test<int>((std::numeric_limits<int>::min)(), (std::numeric_limits<int>::min)() + 100); test<int>((std::numeric_limits<int>::max)() - 100, (std::numeric_limits<int>::max)()); test<int>(-100, 100); test<unsigned>((std::numeric_limits<unsigned>::min)(), (std::numeric_limits<unsigned>::min)() + 100); test<unsigned>((std::numeric_limits<unsigned>::max)() - 100, (std::numeric_limits<unsigned>::max)()); test<long>((std::numeric_limits<long>::min)(), (std::numeric_limits<long>::min)() + 100); test<long>((std::numeric_limits<long>::max)() - 100, (std::numeric_limits<long>::max)()); test<long>(-100, 100); test<unsigned long>((std::numeric_limits<unsigned long>::min)(), (std::numeric_limits<unsigned long>::min)() + 100); test<unsigned long>((std::numeric_limits<unsigned long>::max)() - 100, (std::numeric_limits<unsigned long>::max)()); test_fp<float>((std::numeric_limits<float>::min)(), (std::numeric_limits<float>::min)() + 100); test_fp<float>((std::numeric_limits<float>::max)() - 100, (std::numeric_limits<float>::max)()); //it's incorrect // because floatmax() - 100 causes cancellations error, // digits are not affected test_fp<float>(-100, 100); test<double>((std::numeric_limits<double>::min)(), (std::numeric_limits<double>::min)() + 100); test<double>((std::numeric_limits<double>::max)() - 100, (std::numeric_limits<double>::max)()); //it's the same test<double>(-100, 100); return hpx::util::report_errors(); }
void testmain() { print("function"); expect(77, t1()); t2(79); t3(1, 2, 3, 4, 5, 6); t4(); t5(); expect(3, t6()); expect(12, t7(3, 4)); expect(77, (1 ? t1 : t6)()); expect(3, (0 ? t1 : t6)()); t8(23); t9(); expect(7, t10(3, 4.0)); func_ptr_call(); func_name(); local_static(); empty(); empty2(); test_bool(); test_struct(); test_funcdesg(); }