1 int compare_localmotions(const LocalMotions
* lms1
, const LocalMotions
* lms2
){
2 test_bool(vs_vector_size(lms1
) == vs_vector_size(lms2
));
4 for(i
=0; i
<vs_vector_size(lms1
); i
++){
5 test_bool(LMGet(lms1
,i
)->v
.x
== LMGet(lms2
,i
)->v
.x
);
6 test_bool(LMGet(lms1
,i
)->v
.y
== LMGet(lms2
,i
)->v
.y
);
11 int test_store_restore(TestData
* testdata
){
12 VSMotionDetectConfig mdconf
= vsMotionDetectGetDefaultConfig("test_motionDetect");
14 test_bool(vsMotionDetectInit(&md
, &mdconf
, &testdata
->fi
) == VS_OK
);
19 test_bool(vsMotionDetection(&md
, &lms
,&testdata
->frames
[i
])== VS_OK
);
20 if (i
==0) vs_vector_del(&lms
);
23 FILE* f
= fopen("lmtest","w");
24 vsStoreLocalmotions(f
,&lms
);
26 f
= fopen("lmtest","r");
27 LocalMotions test
= vsRestoreLocalmotions(f
);
29 vsStoreLocalmotions(stderr
,&test
);
30 compare_localmotions(&lms
,&test
);
31 fprintf(stderr
,"\n** LM and LMS OKAY\n");
33 f
= fopen("lmstest","w");
36 vsWriteToFile(&md
,f
,&lms
);
38 vsWriteToFile(&md
,f
,&test
);
41 f
= fopen("lmstest","r");
42 test_bool(vsReadFileVersion(f
)==1);
44 test_bool(vsReadFromFile(f
,&read1
)==1);
45 compare_localmotions(&lms
,&read1
);
47 test_bool(vsReadFromFile(f
,&read2
)==2);
48 compare_localmotions(&test
,&read2
);
50 fprintf(stderr
,"** Reading file stepwise OKAY\n");
51 vs_vector_del(&read1
);
52 vs_vector_del(&read2
);
56 f
= fopen("lmstest","r");
57 VSManyLocalMotions mlms
;
58 test_bool(vsReadLocalMotionsFile(f
,&mlms
)==VS_OK
);
59 test_bool(vs_vector_size(&mlms
)==2);
60 fprintf(stderr
,"** Entire file routine OKAY\n\n");
62 for(i
=0; i
< vs_vector_size(&mlms
); i
++){
64 vs_vector_del(VSMLMGet(&mlms
,i
));