forked from enlightenment/efl
Test rework #11: Eina_Cxx
This commit is contained in:
parent
1b143f233e
commit
dce4a966ad
|
@ -60,7 +60,8 @@ tests/eina_cxx/eina_cxx_test_accessor.cc \
|
|||
tests/eina_cxx/eina_cxx_test_thread.cc \
|
||||
tests/eina_cxx/eina_cxx_test_optional.cc \
|
||||
tests/eina_cxx/eina_cxx_test_value.cc \
|
||||
tests/eina_cxx/simple.c
|
||||
tests/eina_cxx/simple.c \
|
||||
tests/eina_cxx/eina_cxx_suite.h
|
||||
|
||||
tests/eina_cxx/tests_eina_cxx_eina_cxx_suite-eina_cxx_test_accessor.$(OBJEXT): tests/eina_cxx/simple.eo.hh tests/eina_cxx/simple.eo.h
|
||||
tests/eina_cxx/tests_eina_cxx_eina_cxx_suite-eina_cxx_test_ptrarray.$(OBJEXT): tests/eina_cxx/simple.eo.hh tests/eina_cxx/simple.eo.h
|
||||
|
|
|
@ -1,36 +1,11 @@
|
|||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include "Eina.hh"
|
||||
#include "eina_cxx_suite.h"
|
||||
#include "../efl_check.h"
|
||||
|
||||
#include <cassert>
|
||||
#include <algorithm>
|
||||
|
||||
#include <check.h>
|
||||
|
||||
void eina_test_inlist(TCase* tc);
|
||||
void eina_test_inarray(TCase* tc);
|
||||
void eina_test_ptrlist(TCase* tc);
|
||||
void eina_test_ptrarray(TCase* tc);
|
||||
void eina_test_iterator(TCase* tc);
|
||||
void eina_test_stringshare(TCase* tc);
|
||||
void eina_test_error(TCase* tc);
|
||||
void eina_test_accessor(TCase* tc);
|
||||
void eina_test_thread(TCase* tc);
|
||||
void eina_test_optional(TCase* tc);
|
||||
void eina_test_value(TCase* tc);
|
||||
void eina_test_log(TCase* tc);
|
||||
|
||||
typedef struct _Eina_Test_Case Eina_Test_Case;
|
||||
struct _Eina_Test_Case
|
||||
{
|
||||
const char *test_case;
|
||||
void (*build)(TCase *tc);
|
||||
};
|
||||
|
||||
static const Eina_Test_Case etc[] = {
|
||||
static const Efl_Test_Case etc[] = {
|
||||
{ "Ptr_List", eina_test_ptrlist },
|
||||
{ "Ptr_Array", eina_test_ptrarray },
|
||||
{ "Inlist", eina_test_inlist },
|
||||
|
@ -46,88 +21,18 @@ static const Eina_Test_Case etc[] = {
|
|||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
static void
|
||||
_list_tests(void)
|
||||
int
|
||||
main(int argc, char* argv[])
|
||||
{
|
||||
const Eina_Test_Case *itr = etc;
|
||||
fputs("Available Test Cases:\n", stderr);
|
||||
for (; itr->test_case; itr++)
|
||||
fprintf(stderr, "\t%s\n", itr->test_case);
|
||||
}
|
||||
int failed_count;
|
||||
|
||||
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 *
|
||||
eina_build_suite(int argc, const char **argv)
|
||||
{
|
||||
TCase *tc;
|
||||
Suite *s;
|
||||
int i;
|
||||
|
||||
s = suite_create("Eina 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[])
|
||||
{
|
||||
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;
|
||||
}
|
||||
if (!_efl_test_option_disp(argc, argv, etc))
|
||||
return 0;
|
||||
|
||||
putenv(const_cast<char*>("EFL_RUN_IN_TREE=1"));
|
||||
|
||||
s = eina_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);
|
||||
|
||||
eina_shutdown();
|
||||
failed_count = _efl_suite_build_and_run(argc - 1, (const char **)argv + 1,
|
||||
"Eina C++", etc);
|
||||
|
||||
return (failed_count == 0) ? 0 : 255;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
#ifndef _EINA_CXX_SUITE_H
|
||||
#define _EINA_CXX_SUITE_H
|
||||
|
||||
#include <cassert>
|
||||
#include <algorithm>
|
||||
|
||||
#include <check.h>
|
||||
|
||||
void eina_test_inlist(TCase* tc);
|
||||
void eina_test_inarray(TCase* tc);
|
||||
void eina_test_ptrlist(TCase* tc);
|
||||
void eina_test_ptrarray(TCase* tc);
|
||||
void eina_test_iterator(TCase* tc);
|
||||
void eina_test_stringshare(TCase* tc);
|
||||
void eina_test_error(TCase* tc);
|
||||
void eina_test_accessor(TCase* tc);
|
||||
void eina_test_thread(TCase* tc);
|
||||
void eina_test_optional(TCase* tc);
|
||||
void eina_test_value(TCase* tc);
|
||||
void eina_test_log(TCase* tc);
|
||||
|
||||
#endif /* _EINA_CXX_SUITE_H */
|
|
@ -1,14 +1,11 @@
|
|||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include "Eina.hh"
|
||||
#include "Eo.hh"
|
||||
#include <Eina.hh>
|
||||
#include <Eo.hh>
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include <check.h>
|
||||
#include "eina_cxx_suite.h"
|
||||
|
||||
extern "C" {
|
||||
#include "simple.eo.h"
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include "Eina.hh"
|
||||
#include <Eina.hh>
|
||||
|
||||
#include <check.h>
|
||||
#include "eina_cxx_suite.h"
|
||||
|
||||
Eina_Error my_error, my_error_2;
|
||||
|
||||
|
@ -16,7 +15,7 @@ START_TEST(eina_cxx_get_error)
|
|||
my_error = ::eina_error_msg_static_register("Message 1");
|
||||
|
||||
::eina_error_set(0);
|
||||
|
||||
|
||||
efl::eina::error_code ec1 = efl::eina::get_error_code();
|
||||
ck_assert(!ec1);
|
||||
|
||||
|
@ -24,14 +23,14 @@ START_TEST(eina_cxx_get_error)
|
|||
|
||||
efl::eina::error_code ec2 = efl::eina::get_error_code();
|
||||
ck_assert(!!ec2);
|
||||
|
||||
|
||||
ck_assert(ec2.message() == "Message 1");
|
||||
|
||||
::eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
efl::eina::error_code ec3 = efl::eina::get_error_code();
|
||||
ck_assert(!!ec3);
|
||||
|
||||
|
||||
ck_assert(ec3.message() == "Out of memory");
|
||||
}
|
||||
END_TEST
|
||||
|
|
|
@ -1,16 +1,13 @@
|
|||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include "Eina.hh"
|
||||
|
||||
#include <algorithm>
|
||||
#include <functional>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include <check.h>
|
||||
#include <Eina.hh>
|
||||
|
||||
#include "eina_cxx_suite.h"
|
||||
|
||||
START_TEST(eina_cxx_inarray_pod_push_back)
|
||||
{
|
||||
|
@ -139,7 +136,7 @@ START_TEST(eina_cxx_inarray_pod_erase)
|
|||
array1.push_back(20);
|
||||
array1.push_back(25);
|
||||
array1.push_back(30);
|
||||
|
||||
|
||||
efl::eina::inarray<int>::iterator it = array1.begin(), it2;
|
||||
|
||||
it = array1.erase(it);
|
||||
|
@ -152,7 +149,7 @@ START_TEST(eina_cxx_inarray_pod_erase)
|
|||
it = array1.erase(it);
|
||||
ck_assert(*it == 20);
|
||||
ck_assert(array1.size() == 4);
|
||||
|
||||
|
||||
it = array1.end() - 1;
|
||||
it = array1.erase(it);
|
||||
ck_assert(it == array1.end());
|
||||
|
@ -354,7 +351,7 @@ START_TEST(eina_cxx_inarray_nonpod_erase)
|
|||
array1.push_back(20);
|
||||
array1.push_back(25);
|
||||
array1.push_back(30);
|
||||
|
||||
|
||||
efl::eina::inarray<non_pod>::iterator it = array1.begin(), it2;
|
||||
|
||||
it = array1.erase(it);
|
||||
|
@ -367,13 +364,13 @@ START_TEST(eina_cxx_inarray_nonpod_erase)
|
|||
it = array1.erase(it);
|
||||
ck_assert(*it == 20);
|
||||
ck_assert(array1.size() == 4);
|
||||
|
||||
|
||||
it = array1.end() - 1;
|
||||
it = array1.erase(it);
|
||||
ck_assert(it == array1.end());
|
||||
ck_assert(array1.size() == 3);
|
||||
ck_assert(array1.back() == 25);
|
||||
|
||||
|
||||
it = array1.begin() + 1;
|
||||
it2 = array1.end() - 1;
|
||||
it = array1.erase(it, it2);
|
||||
|
|
|
@ -1,14 +1,12 @@
|
|||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include "Eina.hh"
|
||||
|
||||
#include <algorithm>
|
||||
#include <functional>
|
||||
|
||||
#include <check.h>
|
||||
#include <Eina.hh>
|
||||
|
||||
#include "eina_cxx_suite.h"
|
||||
|
||||
struct Eina_Test_Inlist
|
||||
{
|
||||
|
@ -180,7 +178,7 @@ START_TEST(eina_cxx_inlist_erase)
|
|||
list1.push_back(20);
|
||||
list1.push_back(25);
|
||||
list1.push_back(30);
|
||||
|
||||
|
||||
efl::eina::inlist<int>::iterator it = list1.begin(), it2;
|
||||
|
||||
it = list1.erase(it);
|
||||
|
@ -197,7 +195,7 @@ START_TEST(eina_cxx_inlist_erase)
|
|||
ck_assert(it == it2);
|
||||
ck_assert(list1.size() == 4);
|
||||
ck_assert(*it2 == 20);
|
||||
|
||||
|
||||
it = list1.end();
|
||||
--it;
|
||||
it = list1.erase(it);
|
||||
|
@ -232,7 +230,7 @@ START_TEST(eina_cxx_inlist_range)
|
|||
list.push_back(30);
|
||||
|
||||
efl::eina::range_inlist<int> range_list(list);
|
||||
|
||||
|
||||
ck_assert(range_list.size() == 6u);
|
||||
|
||||
int result[] = {5, 10, 15, 20, 25, 30};
|
||||
|
|
|
@ -1,13 +1,10 @@
|
|||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include "Eina.hh"
|
||||
#include <Eina.hh>
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include <check.h>
|
||||
#include "eina_cxx_suite.h"
|
||||
|
||||
START_TEST(eina_cxx_iterator_equal)
|
||||
{
|
||||
|
@ -21,7 +18,7 @@ START_TEST(eina_cxx_iterator_equal)
|
|||
list.push_back(new int(10));
|
||||
list.push_back(new int(15));
|
||||
list.push_back(new int(20));
|
||||
|
||||
|
||||
efl::eina::iterator<int> iterator = list.ibegin()
|
||||
, last_iterator = list.iend();
|
||||
|
||||
|
|
|
@ -1,13 +1,10 @@
|
|||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include "Eina.hh"
|
||||
#include <Eina.hh>
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include <check.h>
|
||||
#include "eina_cxx_suite.h"
|
||||
|
||||
bool expensive_called = false;
|
||||
|
||||
|
|
|
@ -1,16 +1,13 @@
|
|||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include "Eina.hh"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include <check.h>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include <Eina.hh>
|
||||
|
||||
#include "eina_cxx_suite.h"
|
||||
|
||||
std::size_t nonpod_constructed = 0u
|
||||
, nonpod_destructed = 0u;
|
||||
|
||||
|
|
|
@ -1,16 +1,13 @@
|
|||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include "Eina.hh"
|
||||
#include "Eo.hh"
|
||||
|
||||
#include <Eina.hh>
|
||||
#include <eina_array.hh>
|
||||
#include <Eo.hh>
|
||||
|
||||
#include <algorithm>
|
||||
#include "eina_cxx_suite.h"
|
||||
|
||||
#include <check.h>
|
||||
extern "C" {
|
||||
#include "simple.eo.h"
|
||||
}
|
||||
|
@ -32,7 +29,7 @@ START_TEST(eina_cxx_ptrarray_push_back)
|
|||
wrapper const w1(eo_add(SIMPLE_CLASS, NULL));
|
||||
wrapper const w2(eo_add(SIMPLE_CLASS, NULL));
|
||||
wrapper const w3(eo_add(SIMPLE_CLASS, NULL));
|
||||
|
||||
|
||||
{
|
||||
efl::eina::ptr_array<int> array;
|
||||
|
||||
|
@ -335,7 +332,7 @@ START_TEST(eina_cxx_ptrarray_erase)
|
|||
int rresult[] = {30, 25, 20, 15, 10, 5};
|
||||
ck_assert(std::equal(array1.begin(), array1.end(), result));
|
||||
ck_assert(std::equal(array1.rbegin(), array1.rend(), rresult));
|
||||
|
||||
|
||||
efl::eina::ptr_array<int>::iterator it = array1.erase(array1.begin());
|
||||
ck_assert(it == array1.begin());
|
||||
ck_assert(array1.size() == 5);
|
||||
|
@ -346,7 +343,7 @@ START_TEST(eina_cxx_ptrarray_erase)
|
|||
it = array1.erase(array1.begin() + 1);
|
||||
ck_assert(*it == 20);
|
||||
ck_assert(array1.size() == 4);
|
||||
|
||||
|
||||
it = array1.erase(array1.end() - 1);
|
||||
ck_assert(it == array1.end());
|
||||
ck_assert(array1.size() == 3);
|
||||
|
@ -365,9 +362,9 @@ START_TEST(eina_cxx_ptrarray_erase)
|
|||
wrapper const w4(eo_add(SIMPLE_CLASS, NULL));
|
||||
wrapper const w5(eo_add(SIMPLE_CLASS, NULL));
|
||||
wrapper const w6(eo_add(SIMPLE_CLASS, NULL));
|
||||
|
||||
|
||||
efl::eina::array<wrapper> array1;
|
||||
|
||||
|
||||
array1.push_back(w1);
|
||||
array1.push_back(w2);
|
||||
array1.push_back(w3);
|
||||
|
@ -379,7 +376,7 @@ START_TEST(eina_cxx_ptrarray_erase)
|
|||
wrapper rresult[] = {w6, w5, w4, w3, w2, w1};
|
||||
ck_assert(std::equal(array1.begin(), array1.end(), result_));
|
||||
ck_assert(std::equal(array1.rbegin(), array1.rend(), rresult));
|
||||
|
||||
|
||||
efl::eina::array<wrapper>::iterator it = array1.erase(array1.begin());
|
||||
ck_assert(it == array1.begin());
|
||||
ck_assert(array1.size() == 5);
|
||||
|
@ -390,7 +387,7 @@ START_TEST(eina_cxx_ptrarray_erase)
|
|||
it = array1.erase(array1.begin() + 1);
|
||||
ck_assert(*it == w4);
|
||||
ck_assert(array1.size() == 4);
|
||||
|
||||
|
||||
it = array1.erase(array1.end() - 1);
|
||||
ck_assert(it == array1.end());
|
||||
ck_assert(array1.size() == 3);
|
||||
|
@ -420,7 +417,7 @@ START_TEST(eina_cxx_ptrarray_range)
|
|||
array.push_back(new int(30));
|
||||
|
||||
efl::eina::range_ptr_array<int> range_array(array);
|
||||
|
||||
|
||||
ck_assert(range_array.size() == 6u);
|
||||
|
||||
int result[] = {5, 10, 15, 20, 25, 30};
|
||||
|
@ -456,7 +453,7 @@ START_TEST(eina_cxx_ptrarray_range)
|
|||
array.push_back(w6);
|
||||
|
||||
// efl::eina::range_array<wrapper> range_array(array);
|
||||
|
||||
|
||||
// ck_assert(range_array.size() == 6u);
|
||||
|
||||
// wrapper result[] = {5, 10, 15, 20, 25, 30};
|
||||
|
|
|
@ -1,17 +1,14 @@
|
|||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include "Eina.hh"
|
||||
#include "Eo.hh"
|
||||
|
||||
#include <eina_list.hh>
|
||||
|
||||
#include <algorithm>
|
||||
#include <iostream>
|
||||
|
||||
#include <check.h>
|
||||
#include <Eina.hh>
|
||||
#include <eina_list.hh>
|
||||
#include <Eo.hh>
|
||||
|
||||
#include "eina_cxx_suite.h"
|
||||
|
||||
extern "C" {
|
||||
#include "simple.eo.h"
|
||||
|
@ -34,7 +31,7 @@ START_TEST(eina_cxx_ptrlist_push_back)
|
|||
wrapper const w1(eo_add(SIMPLE_CLASS, NULL));
|
||||
wrapper const w2(eo_add(SIMPLE_CLASS, NULL));
|
||||
wrapper const w3(eo_add(SIMPLE_CLASS, NULL));
|
||||
|
||||
|
||||
{
|
||||
efl::eina::ptr_list<int> list;
|
||||
|
||||
|
@ -162,7 +159,7 @@ START_TEST(eina_cxx_ptrlist_push_front)
|
|||
ck_assert(list.size() == 3);
|
||||
ck_assert(std::equal(list.begin(), list.end(), result));
|
||||
ck_assert(std::equal(list.rbegin(), list.rend(), rresult));
|
||||
}
|
||||
}
|
||||
}
|
||||
END_TEST
|
||||
|
||||
|
@ -408,7 +405,7 @@ START_TEST(eina_cxx_ptrlist_erase)
|
|||
list1.push_back(new int(20));
|
||||
list1.push_back(new int(25));
|
||||
list1.push_back(new int(30));
|
||||
|
||||
|
||||
efl::eina::ptr_list<int>::iterator it = list1.begin(), it2;
|
||||
|
||||
it = list1.erase(it);
|
||||
|
@ -425,7 +422,7 @@ START_TEST(eina_cxx_ptrlist_erase)
|
|||
ck_assert(it == it2);
|
||||
ck_assert(list1.size() == 4);
|
||||
ck_assert(*it2 == 20);
|
||||
|
||||
|
||||
it = list1.end();
|
||||
--it;
|
||||
it = list1.erase(it);
|
||||
|
@ -460,7 +457,7 @@ START_TEST(eina_cxx_ptrlist_range)
|
|||
list.push_back(new int(30));
|
||||
|
||||
efl::eina::range_ptr_list<int> range_list(list);
|
||||
|
||||
|
||||
ck_assert(range_list.size() == 6u);
|
||||
|
||||
int result[] = {5, 10, 15, 20, 25, 30};
|
||||
|
|
|
@ -3,12 +3,11 @@
|
|||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include "Eina.hh"
|
||||
|
||||
#include <algorithm>
|
||||
#include <functional>
|
||||
|
||||
#include <check.h>
|
||||
#include <Eina.hh>
|
||||
|
||||
#include "eina_cxx_suite.h"
|
||||
|
||||
START_TEST(eina_cxx_stringshare_constructors)
|
||||
{
|
||||
|
|
|
@ -1,13 +1,10 @@
|
|||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include "Eina.hh"
|
||||
#include <Eina.hh>
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include <check.h>
|
||||
#include "eina_cxx_suite.h"
|
||||
|
||||
bool no_args = false
|
||||
, args_1 = false
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include "Eina.hh"
|
||||
#include <Eina.hh>
|
||||
|
||||
#include <check.h>
|
||||
#include "eina_cxx_suite.h"
|
||||
|
||||
START_TEST(eina_cxx_value_constructors)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue