forked from enlightenment/efl
eolian-cxx: Added tests.
This commit is contained in:
parent
256e21d939
commit
ac8975a73f
|
@ -49,5 +49,44 @@ bin_eolian_cxx_eolian_cxx_DEPENDENCIES = @USE_EOLIAN_INTERNAL_LIBS@
|
||||||
|
|
||||||
include Makefile_Eolian_Cxx_Helper.am
|
include Makefile_Eolian_Cxx_Helper.am
|
||||||
|
|
||||||
|
|
||||||
|
### Unit tests
|
||||||
|
|
||||||
|
if EFL_ENABLE_TESTS
|
||||||
|
|
||||||
|
check_PROGRAMS += tests/eolian_cxx/eolian_cxx_suite
|
||||||
|
TESTS += tests/eolian_cxx/eolian_cxx_suite
|
||||||
|
|
||||||
|
tests_eolian_cxx_eolian_cxx_suite_SOURCES = \
|
||||||
|
tests/eolian_cxx/eolian_cxx_suite.cc \
|
||||||
|
tests/eolian_cxx/eolian_cxx_test_parse.cc \
|
||||||
|
tests/eolian_cxx/eolian_cxx_test_generate.cc
|
||||||
|
|
||||||
|
tests_eolian_cxx_eolian_cxx_suite_CXXFLAGS = \
|
||||||
|
-I$(top_builddir)/src/lib/efl \
|
||||||
|
-I$(top_srcdir)/src/bin/eolian_cxx \
|
||||||
|
-I$(top_srcdir)/src/lib/eolian_cxx \
|
||||||
|
-DTESTS_WD=\"`pwd`\" \
|
||||||
|
-DTESTS_SRC_DIR=\"$(top_srcdir)/src/tests/eolian_cxx\" \
|
||||||
|
-DPACKAGE_BUILD_DIR=\"$(abs_top_builddir)/src/tests/eolian_cxx\" \
|
||||||
|
-DPACKAGE_DATA_DIR=\"$(datadir)/eolian_cxx\" \
|
||||||
|
-DTESTS_BUILD_DIR=\"$(top_builddir)/src/tests/eolian_cxx\" \
|
||||||
|
@CHECK_CFLAGS@ @EOLIAN_CXX_CFLAGS@ @EINA_CXX_CFLAGS@ \
|
||||||
|
@EOLIAN_CFLAGS@ @EINA_CFLAGS@ @EO_CFLAGS@
|
||||||
|
|
||||||
|
tests_eolian_cxx_eolian_cxx_suite_CFLAGS = ${tests_eolian_cxx_eolian_cxx_suite_CXXFLAGS}
|
||||||
|
tests_eolian_cxx_eolian_cxx_suite_CPPFLAGS = ${tests_eolian_cxx_eolian_cxx_suite_CXXFLAGS}
|
||||||
|
tests_eolian_cxx_eolian_cxx_suite_LDADD = \
|
||||||
|
@CHECK_LIBS@ @USE_EO_LIBS@ @USE_EINA_LIBS@ @USE_EOLIAN_LIBS@
|
||||||
|
tests_eolian_cxx_eolian_cxx_suite_DEPENDENCIES = @USE_EOLIAN_INTERNAL_LIBS@
|
||||||
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
EXTRA_DIST += \
|
||||||
|
tests/eolian_cxx/data/base.eo \
|
||||||
|
tests/eolian_cxx/data/class_simple.eo \
|
||||||
|
tests/eolian_cxx/data/scope.eo \
|
||||||
|
tests/eolian_cxx/data/ctor_dtor.eo \
|
||||||
|
tests/eolian_cxx/data/complex_type.eo
|
||||||
|
|
||||||
|
endif
|
||||||
|
|
|
@ -0,0 +1,103 @@
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <check.h>
|
||||||
|
#include <cassert>
|
||||||
|
|
||||||
|
void eolian_cxx_test_parse(TCase* tc);
|
||||||
|
void eolian_cxx_test_generate(TCase* tc);
|
||||||
|
|
||||||
|
typedef struct _Eolian_Cxx_Test_Case Eolian_Cxx_Test_Case;
|
||||||
|
struct _Eolian_Cxx_Test_Case
|
||||||
|
{
|
||||||
|
const char *test_case;
|
||||||
|
void (*build)(TCase *tc);
|
||||||
|
};
|
||||||
|
|
||||||
|
static const Eolian_Cxx_Test_Case etc[] = {
|
||||||
|
{ "Eolian-Cxx Parsing", eolian_cxx_test_parse },
|
||||||
|
{ "Eolian-Cxx Generation", eolian_cxx_test_generate },
|
||||||
|
{ NULL, NULL }
|
||||||
|
};
|
||||||
|
|
||||||
|
static void
|
||||||
|
_list_tests(void)
|
||||||
|
{
|
||||||
|
const Eolian_Cxx_Test_Case *itr;
|
||||||
|
|
||||||
|
itr = etc;
|
||||||
|
fputs("Available Test Cases:\n", stderr);
|
||||||
|
for (; itr->test_case; itr++)
|
||||||
|
fprintf(stderr, "\t%s\n", itr->test_case);
|
||||||
|
}
|
||||||
|
|
||||||
|
static 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 *
|
||||||
|
eolian_cxx_build_suite(int argc, const char **argv)
|
||||||
|
{
|
||||||
|
TCase *tc;
|
||||||
|
Suite *s;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
s = suite_create("Eolian 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);
|
||||||
|
tcase_set_timeout(tc, 0);
|
||||||
|
|
||||||
|
etc[i].build(tc);
|
||||||
|
suite_add_tcase(s, tc);
|
||||||
|
}
|
||||||
|
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, char* argv[])
|
||||||
|
{
|
||||||
|
Suite *s;
|
||||||
|
SRunner *sr;
|
||||||
|
int i, failed_count;
|
||||||
|
|
||||||
|
for (i = 1; i < argc; i++)
|
||||||
|
if ((strcmp(argv[i], "-h") == 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"));
|
||||||
|
|
||||||
|
s = eolian_cxx_build_suite(argc - 1, (const char **)argv + 1);
|
||||||
|
sr = srunner_create(s);
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
|
@ -0,0 +1,2 @@
|
||||||
|
|
||||||
|
// test EFL++ generated bindings
|
|
@ -0,0 +1,21 @@
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
# include <config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <Eolian_Cxx.hh>
|
||||||
|
|
||||||
|
#include <check.h>
|
||||||
|
#include <cassert>
|
||||||
|
|
||||||
|
START_TEST(eolian_cxx_test_generate_complex_types)
|
||||||
|
{
|
||||||
|
// TODO implement
|
||||||
|
}
|
||||||
|
END_TEST
|
||||||
|
|
||||||
|
void
|
||||||
|
eolian_cxx_test_generate(TCase* tc)
|
||||||
|
{
|
||||||
|
tcase_add_test(tc, eolian_cxx_test_generate_complex_types);
|
||||||
|
}
|
|
@ -0,0 +1,30 @@
|
||||||
|
|
||||||
|
#include <Eolian_Cxx.hh>
|
||||||
|
|
||||||
|
#include <cassert>
|
||||||
|
#include <check.h>
|
||||||
|
#include <tuple>
|
||||||
|
|
||||||
|
START_TEST(eolian_cxx_test_parse_complex_types)
|
||||||
|
{
|
||||||
|
efl::eolian::eolian_init init;
|
||||||
|
fail_if(!::eolian_directory_scan(PACKAGE_DATA_DIR"/data"));
|
||||||
|
fail_if(!::eolian_eo_file_parse(PACKAGE_DATA_DIR"/data/complex_type.eo"));
|
||||||
|
// TODO finish
|
||||||
|
}
|
||||||
|
END_TEST
|
||||||
|
|
||||||
|
START_TEST(eolian_cxx_test_parse_qualifiers)
|
||||||
|
{
|
||||||
|
efl::eolian::eolian_init init;
|
||||||
|
// XXX: implement
|
||||||
|
//eolian_cxx::type_qualify("");
|
||||||
|
//fail_if();
|
||||||
|
}
|
||||||
|
END_TEST
|
||||||
|
|
||||||
|
void
|
||||||
|
eolian_cxx_test_parse(TCase* tc)
|
||||||
|
{
|
||||||
|
tcase_add_test(tc, eolian_cxx_test_parse_qualifiers);
|
||||||
|
}
|
|
@ -0,0 +1,2 @@
|
||||||
|
|
||||||
|
// Test Eolian-Cxx wrappers
|
Loading…
Reference in New Issue