forked from enlightenment/efl
Test rework #6: Eet_Cxx
This commit is contained in:
parent
8cc995cca8
commit
0b84e7593f
|
@ -19,7 +19,8 @@ TESTS += tests/eet_cxx/eet_cxx_suite
|
||||||
|
|
||||||
tests_eet_cxx_eet_cxx_suite_SOURCES = \
|
tests_eet_cxx_eet_cxx_suite_SOURCES = \
|
||||||
tests/eet_cxx/eet_cxx_suite.cc \
|
tests/eet_cxx/eet_cxx_suite.cc \
|
||||||
tests/eet_cxx/eet_cxx_test_descriptors.cc
|
tests/eet_cxx/eet_cxx_test_descriptors.cc \
|
||||||
|
tests/eet_cxx/eet_cxx_suite.h
|
||||||
|
|
||||||
tests_eet_cxx_eet_cxx_suite_CPPFLAGS = \
|
tests_eet_cxx_eet_cxx_suite_CPPFLAGS = \
|
||||||
-I$(top_builddir)/src/lib/efl \
|
-I$(top_builddir)/src/lib/efl \
|
||||||
|
|
|
@ -1,110 +1,26 @@
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
# include <config.h>
|
# include <config.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "Eet.hh"
|
#include "eet_cxx_suite.h"
|
||||||
#include <Eina.h>
|
#include "../efl_check.h"
|
||||||
|
|
||||||
#include <cassert>
|
static const Efl_Test_Case etc[] = {
|
||||||
#include <algorithm>
|
{ "Descriptors", eet_cxx_test_descriptors },
|
||||||
|
|
||||||
#include <check.h>
|
|
||||||
|
|
||||||
void eet_test_descriptors(TCase* tc);
|
|
||||||
|
|
||||||
typedef struct _Eet_Test_Case Eet_Test_Case;
|
|
||||||
struct _Eet_Test_Case
|
|
||||||
{
|
|
||||||
const char *test_case;
|
|
||||||
void (*build)(TCase *tc);
|
|
||||||
};
|
|
||||||
|
|
||||||
static const Eet_Test_Case etc[] = {
|
|
||||||
{ "Descriptors", eet_test_descriptors },
|
|
||||||
{ NULL, NULL }
|
{ NULL, NULL }
|
||||||
};
|
};
|
||||||
|
|
||||||
static void
|
|
||||||
_list_tests(void)
|
|
||||||
{
|
|
||||||
const Eet_Test_Case *itr = etc;
|
|
||||||
fputs("Available Test Cases:\n", stderr);
|
|
||||||
for (; itr->test_case; itr++)
|
|
||||||
fprintf(stderr, "\t%s\n", itr->test_case);
|
|
||||||
}
|
|
||||||
|
|
||||||
static Eina_Bool
|
|
||||||
_use_test(int argc, const char **argv, const char *test_case)
|
|
||||||
{
|
|
||||||
if (argc < 1)
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
for (; argc > 0; argc--, argv++)
|
|
||||||
if (strcmp(test_case, *argv) == 0)
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
Suite *
|
|
||||||
eet_build_suite(int argc, const char **argv)
|
|
||||||
{
|
|
||||||
TCase *tc;
|
|
||||||
Suite *s;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
s = suite_create("Eet C++");
|
|
||||||
|
|
||||||
for (i = 0; etc[i].test_case; ++i)
|
|
||||||
{
|
|
||||||
if (!_use_test(argc, argv, etc[i].test_case))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
tc = tcase_create(etc[i].test_case);
|
|
||||||
#ifndef _WIN32
|
|
||||||
tcase_set_timeout(tc, 0);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
etc[i].build(tc);
|
|
||||||
suite_add_tcase(s, tc);
|
|
||||||
}
|
|
||||||
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc, char* argv[])
|
int main(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
Suite *s;
|
int failed_count;
|
||||||
SRunner *sr;
|
|
||||||
int i, failed_count;
|
|
||||||
|
|
||||||
for (i = 1; i < argc; i++)
|
if (!_efl_test_option_disp(argc, argv, etc))
|
||||||
if ((strcmp(argv[i], "-h") == 0) ||
|
return 0;
|
||||||
(strcmp(argv[i], "--help") == 0))
|
|
||||||
{
|
|
||||||
fprintf(stderr, "Usage:\n\t%s [test_case1 .. [test_caseN]]\n",
|
|
||||||
argv[0]);
|
|
||||||
_list_tests();
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
else if ((strcmp(argv[i], "-l") == 0) ||
|
|
||||||
(strcmp(argv[i], "--list") == 0))
|
|
||||||
{
|
|
||||||
_list_tests();
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
putenv(const_cast<char*>("EFL_RUN_IN_TREE=1"));
|
putenv(const_cast<char*>("EFL_RUN_IN_TREE=1"));
|
||||||
|
|
||||||
s = eet_build_suite(argc - 1, (const char **)argv + 1);
|
failed_count = _efl_suite_build_and_run(argc - 1, (const char **)argv + 1,
|
||||||
sr = srunner_create(s);
|
"Eet C++", etc);
|
||||||
|
|
||||||
srunner_set_xml(sr, TESTS_BUILD_DIR "/check-results.xml");
|
|
||||||
|
|
||||||
srunner_run_all(sr, CK_ENV);
|
|
||||||
failed_count = srunner_ntests_failed(sr);
|
|
||||||
srunner_free(sr);
|
|
||||||
|
|
||||||
return (failed_count == 0) ? 0 : 255;
|
return (failed_count == 0) ? 0 : 255;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
#ifndef _EET_CXX_SUITE_H
|
||||||
|
#define _EET_CXX_SUITE_H
|
||||||
|
|
||||||
|
#include <cassert>
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
|
#include <check.h>
|
||||||
|
|
||||||
|
void eet_cxx_test_descriptors(TCase* tc);
|
||||||
|
|
||||||
|
#endif /* _EET_CXX_SUITE_H */
|
|
@ -1,15 +1,13 @@
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
# include <config.h>
|
# include <config.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "Eet.hh"
|
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
#include <check.h>
|
#include <Eet.hh>
|
||||||
|
|
||||||
|
#include "eet_cxx_suite.h"
|
||||||
|
|
||||||
struct pod_type
|
struct pod_type
|
||||||
{
|
{
|
||||||
|
@ -141,7 +139,7 @@ START_TEST(eet_cxx_descriptors_composition)
|
||||||
|
|
||||||
Eet_File* file = eet_open("/tmp/eet_file_test.eet", EET_FILE_MODE_READ_WRITE);
|
Eet_File* file = eet_open("/tmp/eet_file_test.eet", EET_FILE_MODE_READ_WRITE);
|
||||||
ck_assert(file != 0);
|
ck_assert(file != 0);
|
||||||
|
|
||||||
::pod_composited pod_composited {new pod_type{5, 'a'}};
|
::pod_composited pod_composited {new pod_type{5, 'a'}};
|
||||||
|
|
||||||
int s = eet_data_write(file, d.native_handle(), "foo", &pod_composited, false);
|
int s = eet_data_write(file, d.native_handle(), "foo", &pod_composited, false);
|
||||||
|
@ -170,7 +168,7 @@ START_TEST(eet_cxx_descriptors_composition)
|
||||||
|
|
||||||
Eet_File* file = eet_open("/tmp/eet_file_test.eet", EET_FILE_MODE_READ_WRITE);
|
Eet_File* file = eet_open("/tmp/eet_file_test.eet", EET_FILE_MODE_READ_WRITE);
|
||||||
ck_assert(file != 0);
|
ck_assert(file != 0);
|
||||||
|
|
||||||
::pod_composited_with_non_pod pod_composited_with_non_pod {new non_pod};
|
::pod_composited_with_non_pod pod_composited_with_non_pod {new non_pod};
|
||||||
|
|
||||||
int s = eet_data_write(file, d.native_handle(), "foo", &pod_composited_with_non_pod, false);
|
int s = eet_data_write(file, d.native_handle(), "foo", &pod_composited_with_non_pod, false);
|
||||||
|
@ -205,7 +203,7 @@ START_TEST(eet_cxx_descriptors_composition)
|
||||||
|
|
||||||
Eet_File* file = eet_open("/tmp/eet_file_test.eet", EET_FILE_MODE_READ_WRITE);
|
Eet_File* file = eet_open("/tmp/eet_file_test.eet", EET_FILE_MODE_READ_WRITE);
|
||||||
ck_assert(file != 0);
|
ck_assert(file != 0);
|
||||||
|
|
||||||
::pod_value_composited pod_value_composited {{5, 'a'}};
|
::pod_value_composited pod_value_composited {{5, 'a'}};
|
||||||
|
|
||||||
int s = eet_data_write(file, d.native_handle(), "foo", &pod_value_composited, false);
|
int s = eet_data_write(file, d.native_handle(), "foo", &pod_value_composited, false);
|
||||||
|
@ -227,7 +225,7 @@ START_TEST(eet_cxx_descriptors_composition)
|
||||||
END_TEST
|
END_TEST
|
||||||
|
|
||||||
void
|
void
|
||||||
eet_test_descriptors(TCase* tc)
|
eet_cxx_test_descriptors(TCase* tc)
|
||||||
{
|
{
|
||||||
tcase_add_test(tc, eet_cxx_descriptors);
|
tcase_add_test(tc, eet_cxx_descriptors);
|
||||||
tcase_add_test(tc, eet_cxx_descriptors_non_pod);
|
tcase_add_test(tc, eet_cxx_descriptors_non_pod);
|
||||||
|
|
Loading…
Reference in New Issue