85 lines
2.0 KiB
C++
85 lines
2.0 KiB
C++
#include <archives/binary.hpp>
|
|
#include <CUnit/Basic.h>
|
|
#include "../image.h"
|
|
#include "../streamingview.hpp"
|
|
#include "../util.h"
|
|
#include <cwalk.h>
|
|
#ifdef __cplusplus
|
|
#include <iostream>
|
|
#endif // __cplusplus
|
|
|
|
#define STRLEN 2048
|
|
|
|
FILE *imageHandle = NULL;
|
|
char frame1Path[STRLEN];
|
|
|
|
#define HERE __FILE__
|
|
|
|
int setUp(void)
|
|
{
|
|
char framesDir[STRLEN];
|
|
size_t length;
|
|
cwk_path_get_dirname(HERE, &length); // archimedes_mobile_lib/src/tests
|
|
cwk_path_join(HERE, "../../../assets/test/frames", framesDir, STRLEN);
|
|
cwk_path_join(framesDir, "0001.png", frame1Path, STRLEN);
|
|
printf("Opening file %s\n", frame1Path);
|
|
return 0;
|
|
}
|
|
|
|
Frame *get_frame() {
|
|
imageHandle = fopen(frame1Path, "rw+");
|
|
Frame *f = new_frame_from_handle(
|
|
imageHandle,
|
|
768,
|
|
768,
|
|
64);
|
|
return f;
|
|
}
|
|
|
|
void destroy_frame() {
|
|
frame_
|
|
}
|
|
|
|
int tearDown(void)
|
|
{
|
|
if (imageHandle)
|
|
{
|
|
fclose(imageHandle);
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
void test_calculate_fetures
|
|
|
|
int main()
|
|
{
|
|
CU_pSuite pSuite = NULL;
|
|
|
|
/* initialize the CUnit test registry */
|
|
if (CUE_SUCCESS != CU_initialize_registry())
|
|
return CU_get_error();
|
|
|
|
/* add a suite to the registry */
|
|
pSuite = CU_add_suite("ImageSuite", setUp, tearDown);
|
|
if (NULL == pSuite)
|
|
{
|
|
CU_cleanup_registry();
|
|
return CU_get_error();
|
|
}
|
|
|
|
/* add the tests to the suite */
|
|
if ((NULL == CU_add_test(pSuite, "frame can be created", test_create_frame)) ||
|
|
(NULL == CU_add_test(pSuite, "frame can be created from data", test_frame_from_data)) ||
|
|
(NULL == CU_add_test(pSuite, "data can be retrieved from frame", test_archimedes_get_data)) ||
|
|
(NULL == CU_add_test(pSuite, "Streaming view can read & write data", test_archimedes_streamed_view)))
|
|
{
|
|
CU_cleanup_registry();
|
|
return CU_get_error();
|
|
}
|
|
|
|
/* Run all tests using the CUnit Basic interface */
|
|
CU_basic_set_mode(CU_BRM_VERBOSE);
|
|
CU_basic_run_tests();
|
|
CU_cleanup_registry();
|
|
return CU_get_error();
|
|
} |