Commit 9a824fa4 authored by Dominik Charousset's avatar Dominik Charousset

split unit_tests into 15 single tests

parent d82eaa24
...@@ -201,9 +201,6 @@ enable_testing() ...@@ -201,9 +201,6 @@ enable_testing()
add_subdirectory(unit_testing) add_subdirectory(unit_testing)
add_subdirectory(examples) add_subdirectory(examples)
add_subdirectory(benchmarks) add_subdirectory(benchmarks)
#add_subdirectory(benchmarks)
#add_dependencies(unit_tests libcppa)
#add_dependencies(benchmarks libcppa)
add_dependencies(announce_example_1 libcppa) add_dependencies(announce_example_1 libcppa)
add_dependencies(announce_example_2 libcppa) add_dependencies(announce_example_2 libcppa)
add_dependencies(announce_example_3 libcppa) add_dependencies(announce_example_3 libcppa)
...@@ -213,12 +210,26 @@ add_dependencies(dancing_kirby libcppa) ...@@ -213,12 +210,26 @@ add_dependencies(dancing_kirby libcppa)
add_dependencies(dining_philosophers libcppa) add_dependencies(dining_philosophers libcppa)
add_dependencies(hello_world_example libcppa) add_dependencies(hello_world_example libcppa)
add_dependencies(math_actor_example libcppa) add_dependencies(math_actor_example libcppa)
add_dependencies(unit_tests libcppa)
add_dependencies(actor_creation libcppa) add_dependencies(actor_creation libcppa)
add_dependencies(mailbox_performance libcppa) add_dependencies(mailbox_performance libcppa)
add_dependencies(mixed_case libcppa) add_dependencies(mixed_case libcppa)
add_dependencies(distributed libcppa) add_dependencies(distributed libcppa)
add_dependencies(matching libcppa) add_dependencies(matching libcppa)
add_dependencies(test__atom libcppa)
add_dependencies(test__intrusive_containers libcppa)
add_dependencies(test__local_group libcppa)
add_dependencies(test__pattern libcppa)
add_dependencies(test__remote_actor libcppa)
add_dependencies(test__serialization libcppa)
add_dependencies(test__uniform_type libcppa)
add_dependencies(test__fixed_vector libcppa)
add_dependencies(test__intrusive_ptr libcppa)
add_dependencies(test__match libcppa)
add_dependencies(test__primitive_variant libcppa)
add_dependencies(test__ripemd_160 libcppa)
add_dependencies(test__spawn libcppa)
add_dependencies(test__type_list libcppa)
add_dependencies(test__yield_interface libcppa)
string(TOUPPER ${CMAKE_BUILD_TYPE} build_type) string(TOUPPER ${CMAKE_BUILD_TYPE} build_type)
set(CONTEXT_SWITCHING true) set(CONTEXT_SWITCHING true)
......
...@@ -235,7 +235,6 @@ src/unicast_network.cpp ...@@ -235,7 +235,6 @@ src/unicast_network.cpp
src/uniform_type_info.cpp src/uniform_type_info.cpp
src/yield_interface.cpp src/yield_interface.cpp
src/context_switching_actor.cpp src/context_switching_actor.cpp
unit_testing/main.cpp
unit_testing/ping_pong.cpp unit_testing/ping_pong.cpp
unit_testing/ping_pong.hpp unit_testing/ping_pong.hpp
unit_testing/test.hpp unit_testing/test.hpp
......
cmake_minimum_required(VERSION 2.6) cmake_minimum_required(VERSION 2.6)
project(cppa_unit_tests CXX) project(cppa_unit_tests CXX)
# Set up environment paths to cmake modules and libcppa # set up environment paths to cmake modules and libcppa
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}) set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR})
add_executable(unit_tests
main.cpp
test__atom.cpp
test__intrusive_containers.cpp
test__local_group.cpp
test__pattern.cpp
test__remote_actor.cpp
test__serialization.cpp
test__tuple.cpp
test__uniform_type.cpp
ping_pong.cpp
test__fixed_vector.cpp
test__intrusive_ptr.cpp
test__match.cpp
test__primitive_variant.cpp
test__ripemd_160.cpp
test__spawn.cpp
test__type_list.cpp
test__yield_interface.cpp)
# search for libs # search for libs
if(NOT cppa_LIBRARY) if(NOT cppa_LIBRARY)
find_package(Libcppa REQUIRED) find_package(Libcppa REQUIRED)
...@@ -36,6 +16,53 @@ include_directories(. ${cppa_INCLUDE} ${Boost_INCLUDE_DIRS}) ...@@ -36,6 +16,53 @@ include_directories(. ${cppa_INCLUDE} ${Boost_INCLUDE_DIRS})
set(EXAMPLE_LIBS ${CMAKE_DL_LIBS} ${CPPA_LIBRARY} ${Boost_THREAD_LIBRARY}) set(EXAMPLE_LIBS ${CMAKE_DL_LIBS} ${CPPA_LIBRARY} ${Boost_THREAD_LIBRARY})
target_link_libraries(unit_tests ${EXAMPLE_LIBS}) # add binaries
add_executable(test__atom test__atom.cpp)
add_executable(test__intrusive_containers test__intrusive_containers.cpp)
add_executable(test__local_group test__local_group.cpp)
add_executable(test__pattern test__pattern.cpp)
add_executable(test__remote_actor test__remote_actor.cpp ping_pong.cpp)
add_executable(test__serialization test__serialization.cpp)
add_executable(test__uniform_type test__uniform_type.cpp)
add_executable(test__fixed_vector test__fixed_vector.cpp)
add_executable(test__intrusive_ptr test__intrusive_ptr.cpp)
add_executable(test__match test__match.cpp)
add_executable(test__primitive_variant test__primitive_variant.cpp)
add_executable(test__ripemd_160 test__ripemd_160.cpp)
add_executable(test__spawn test__spawn.cpp ping_pong.cpp)
add_executable(test__type_list test__type_list.cpp)
add_executable(test__yield_interface test__yield_interface.cpp)
# link binaries to libraries
target_link_libraries(test__atom ${EXAMPLE_LIBS})
target_link_libraries(test__intrusive_containers ${EXAMPLE_LIBS})
target_link_libraries(test__local_group ${EXAMPLE_LIBS})
target_link_libraries(test__pattern ${EXAMPLE_LIBS})
target_link_libraries(test__remote_actor ${EXAMPLE_LIBS})
target_link_libraries(test__serialization ${EXAMPLE_LIBS})
target_link_libraries(test__uniform_type ${EXAMPLE_LIBS})
target_link_libraries(test__fixed_vector ${EXAMPLE_LIBS})
target_link_libraries(test__intrusive_ptr ${EXAMPLE_LIBS})
target_link_libraries(test__match ${EXAMPLE_LIBS})
target_link_libraries(test__primitive_variant ${EXAMPLE_LIBS})
target_link_libraries(test__ripemd_160 ${EXAMPLE_LIBS})
target_link_libraries(test__spawn ${EXAMPLE_LIBS})
target_link_libraries(test__type_list ${EXAMPLE_LIBS})
target_link_libraries(test__yield_interface ${EXAMPLE_LIBS})
add_test(unit_tests ${EXECUTABLE_OUTPUT_PATH}/unit_tests) # add binaries to unit tests
add_test(ripemd_160 ${EXECUTABLE_OUTPUT_PATH}/test__ripemd_160)
add_test(atom ${EXECUTABLE_OUTPUT_PATH}/test__atom)
add_test(fixed_vector ${EXECUTABLE_OUTPUT_PATH}/test__fixed_vector)
add_test(intrusive_ptr ${EXECUTABLE_OUTPUT_PATH}/test__intrusive_ptr)
add_test(intrusive_containers ${EXECUTABLE_OUTPUT_PATH}/test__intrusive_containers)
add_test(pattern ${EXECUTABLE_OUTPUT_PATH}/test__pattern)
add_test(match ${EXECUTABLE_OUTPUT_PATH}/test__match)
add_test(primitive_variant ${EXECUTABLE_OUTPUT_PATH}/test__primitive_variant)
add_test(uniform_type ${EXECUTABLE_OUTPUT_PATH}/test__uniform_type)
add_test(type_list ${EXECUTABLE_OUTPUT_PATH}/test__type_list)
add_test(yield_interface ${EXECUTABLE_OUTPUT_PATH}/test__yield_interface)
add_test(local_group ${EXECUTABLE_OUTPUT_PATH}/test__local_group)
add_test(serialization ${EXECUTABLE_OUTPUT_PATH}/test__serialization)
add_test(remote_actor ${EXECUTABLE_OUTPUT_PATH}/test__remote_actor)
add_test(spawn ${EXECUTABLE_OUTPUT_PATH}/test__spawn)
#include <map>
#include <cstdio>
#include <atomic>
#include <string>
#include <limits>
#include <vector>
#include <cstring>
#include <cassert>
#include <cstddef>
#include <cstdint>
#include <sstream>
#include <typeinfo>
#include <iostream>
#include "test.hpp"
#include "ping_pong.hpp"
#include "cppa/cppa.hpp"
#include "cppa/match.hpp"
#include "cppa/config.hpp"
#include "cppa/anything.hpp"
#include "cppa/cow_tuple.hpp"
#include "cppa/detail/demangle.hpp"
#include "cppa/uniform_type_info.hpp"
#include "cppa/process_information.hpp"
#include "cppa/detail/thread_pool_scheduler.hpp"
#define CPPA_TEST_CATCH_BLOCK() \
catch (std::exception& e) { \
std::cerr << "test exited after throwing an instance of \"" \
<< ::cppa::detail::demangle(typeid(e).name()) \
<< "\"\n what(): " << e.what() << std::endl; \
errors += 1; \
} \
catch (...) { \
std::cerr << "test exited because of an unknown exception" << std::endl; \
errors += 1; \
}
#define RUN_TEST(fun_name) \
std::cout << "run " << #fun_name << " ..." << std::endl; \
try { errors += fun_name (); } CPPA_TEST_CATCH_BLOCK() \
std::cout << std::endl
#define RUN_TEST_A1(fun_name, arg1) \
std::cout << "run " << #fun_name << " ..." << std::endl; \
try { errors += fun_name ((arg1)); } CPPA_TEST_CATCH_BLOCK() \
std::cout << std::endl
#define RUN_TEST_A2(fun_name, arg1, arg2) \
std::cout << "run " << #fun_name << " ..." << std::endl; \
try { errors += fun_name ((arg1), (arg2)); } CPPA_TEST_CATCH_BLOCK() \
std::cout << std::endl
#define RUN_TEST_A3(fun_name, arg1, arg2, arg3) \
std::cout << "run " << #fun_name << " ..." << std::endl; \
try { errors += fun_name ((arg1), (arg2), (arg3)); } CPPA_TEST_CATCH_BLOCK() \
std::cout << std::endl
using std::cout;
using std::cerr;
using std::endl;
using namespace cppa;
std::vector<std::string> split(const std::string& str, char delim) {
std::vector<std::string> result;
std::stringstream strs{str};
std::string tmp;
while (std::getline(strs, tmp, delim)) result.push_back(tmp);
return result;
}
void print_node_id() {
auto pinfo = cppa::process_information::get();
auto node_id_hash = cppa::to_string(pinfo->node_id());
cout << "node id: " << node_id_hash << endl;
cout << "process id: " << pinfo->process_id() << endl;
cout << "actor id format: {process id}.{actor id}@{node id}" << endl;
cout << "example actor id: " << pinfo->process_id()
<< ".42@"
<< node_id_hash
<< endl;
}
std::vector<string_pair> get_kv_pairs(int argc, char** argv, int begin = 1) {
std::vector<string_pair> result;
for (int i = begin; i < argc; ++i) {
auto vec = split(argv[i], '=');
if (vec.size() != 2) {
cerr << "\"" << argv[i] << "\" is not a key-value pair" << endl;
}
else if (std::any_of(result.begin(), result.end(),
[&](const string_pair& p) { return p.first == vec[0]; })) {
cerr << "key \"" << vec[0] << "\" is already defined" << endl;
}
else {
result.emplace_back(vec[0], vec[1]);
}
}
return result;
}
void usage(const char* argv0) {
cout << "usage: " << split(argv0, '/').back() << " "
<< "[run=remote_actor] "
<< "[scheduler=(thread_pool_scheduler|mock_scheduler)]"
<< endl;
}
int main(int argc, char** argv) {
auto args = get_kv_pairs(argc, argv);
match_each(args) (
on("run", "remote_actor") >> [&]() {
test__remote_actor(argv[0], true, args);
exit(0);
},
on("run", "threaded_ping_pong") >> []() {
spawn<detached>(pong, spawn<detached>(ping, 1000));
await_all_others_done();
exit(0);
},
on("run", "ping_pong") >> []() {
spawn_event_based_pong(spawn_event_based_ping(1000000));
await_all_others_done();
exit(0);
},
on("run_ping", arg_match) >> [&](const std::string& num_pings) {
auto ping_actor = spawn<detached>(ping, std::stoi(num_pings));
//auto ping_actor = spawn_event_based_ping(std::stoi(num_pings));
std::uint16_t port = 4242;
bool success = false;
do {
try {
publish(ping_actor, port);
success = true;
}
catch (bind_failure&) {
// try next port
++port;
}
}
while (!success);
cout << "port is " << port << endl;
await_all_others_done();
exit(0);
},
on("scheduler", val<std::string>) >> [](const std::string& sched) {
if (sched == "thread_pool_scheduler") {
cout << "using thread_pool_scheduler" << endl;
set_scheduler(new cppa::detail::thread_pool_scheduler);
}
else {
cerr << "unknown scheduler: " << sched << endl;
exit(1);
}
}
);
std::cout << std::boolalpha;
size_t errors = 0;
//print_node_id();
RUN_TEST(test__ripemd_160);
RUN_TEST(test__primitive_variant);
RUN_TEST(test__intrusive_containers);
RUN_TEST(test__uniform_type);
RUN_TEST(test__pattern);
RUN_TEST(test__match);
RUN_TEST(test__intrusive_ptr);
RUN_TEST(test__type_list);
RUN_TEST(test__fixed_vector);
RUN_TEST(test__tuple);
RUN_TEST(test__serialization);
RUN_TEST(test__atom);
RUN_TEST(test__yield_interface);
RUN_TEST(test__spawn);
RUN_TEST(test__local_group);
RUN_TEST_A3(test__remote_actor, argv[0], false, args);
cout << endl
<< "error(s) in all tests: " << errors
<< endl;
return 0;
}
...@@ -30,7 +30,7 @@ template<typename T1, typename T2> ...@@ -30,7 +30,7 @@ template<typename T1, typename T2>
inline bool cppa_check_value_fun(const T1& value1, const T2& value2, inline bool cppa_check_value_fun(const T1& value1, const T2& value2,
const char* file_name, const char* file_name,
int line_number, int line_number,
size_t& error_count) { int& error_count) {
if (cppa_check_value_fun_eq(value1, value2) == false) { if (cppa_check_value_fun_eq(value1, value2) == false) {
std::cerr << "ERROR in file " << file_name << " on line " << line_number std::cerr << "ERROR in file " << file_name << " on line " << line_number
<< " => expected value: " << value1 << " => expected value: " << value1
...@@ -46,7 +46,7 @@ template<typename T1, typename T2> ...@@ -46,7 +46,7 @@ template<typename T1, typename T2>
inline void cppa_check_value_verbose_fun(const T1& value1, const T2& value2, inline void cppa_check_value_verbose_fun(const T1& value1, const T2& value2,
const char* file_name, const char* file_name,
int line_number, int line_number,
size_t& error_count) { int& error_count) {
if (cppa_check_value_fun(value1, value2, file_name, if (cppa_check_value_fun(value1, value2, file_name,
line_number, error_count)) { line_number, error_count)) {
std::cout << "line " << line_number << " passed" << std::endl; std::cout << "line " << line_number << " passed" << std::endl;
...@@ -55,7 +55,7 @@ inline void cppa_check_value_verbose_fun(const T1& value1, const T2& value2, ...@@ -55,7 +55,7 @@ inline void cppa_check_value_verbose_fun(const T1& value1, const T2& value2,
#define CPPA_TEST(name) \ #define CPPA_TEST(name) \
struct cppa_test_scope { \ struct cppa_test_scope { \
size_t error_count; \ int error_count; \
cppa_test_scope() : error_count(0) { } \ cppa_test_scope() : error_count(0) { } \
~cppa_test_scope() { \ ~cppa_test_scope() { \
std::cout << error_count << " error(s) detected" << std::endl; \ std::cout << error_count << " error(s) detected" << std::endl; \
...@@ -102,25 +102,13 @@ if (!(line_of_code)) { \ ...@@ -102,25 +102,13 @@ if (!(line_of_code)) { \
typedef std::pair<std::string, std::string> string_pair; typedef std::pair<std::string, std::string> string_pair;
size_t test__yield_interface(); inline std::vector<std::string> split(const std::string& str, char delim) {
size_t test__remote_actor(const char* app_path, bool is_client, std::vector<std::string> result;
const std::vector<string_pair>& args); std::stringstream strs{str};
size_t test__ripemd_160(); std::string tmp;
size_t test__uniform_type(); while (std::getline(strs, tmp, delim)) result.push_back(tmp);
size_t test__type_list(); return result;
size_t test__atom(); }
size_t test__tuple();
size_t test__match();
size_t test__spawn();
size_t test__pattern();
size_t test__intrusive_ptr();
size_t test__serialization();
size_t test__local_group();
size_t test__primitive_variant();
size_t test__fixed_vector();
size_t test__intrusive_containers();
std::vector<std::string> split(const std::string& str, char delim);
using std::cout; using std::cout;
using std::endl; using std::endl;
......
...@@ -30,7 +30,7 @@ void foo() { ...@@ -30,7 +30,7 @@ void foo() {
<< endl; << endl;
} }
size_t test__atom() { int main() {
bool matched_pattern[3] = { false, false, false }; bool matched_pattern[3] = { false, false, false };
CPPA_TEST(test__atom); CPPA_TEST(test__atom);
// check if there are leading bits that distinguish "zzz" and "000 " // check if there are leading bits that distinguish "zzz" and "000 "
......
...@@ -11,7 +11,7 @@ using std::endl; ...@@ -11,7 +11,7 @@ using std::endl;
using std::equal; using std::equal;
using cppa::util::fixed_vector; using cppa::util::fixed_vector;
size_t test__fixed_vector() { int main() {
CPPA_TEST(test__fixed_vector); CPPA_TEST(test__fixed_vector);
int arr1[] {1, 2, 3, 4}; int arr1[] {1, 2, 3, 4};
fixed_vector<int, 4> vec1 {1, 2, 3, 4}; fixed_vector<int, 4> vec1 {1, 2, 3, 4};
......
...@@ -61,7 +61,7 @@ inline bool operator==(int lhs, const iint& rhs) { ...@@ -61,7 +61,7 @@ inline bool operator==(int lhs, const iint& rhs) {
typedef cppa::intrusive::singly_linked_list<iint> iint_list; typedef cppa::intrusive::singly_linked_list<iint> iint_list;
typedef cppa::intrusive::single_reader_queue<iint> iint_queue; typedef cppa::intrusive::single_reader_queue<iint> iint_queue;
size_t test__intrusive_containers() { int main() {
CPPA_TEST(test__intrusive_containers); CPPA_TEST(test__intrusive_containers);
iint_list ilist1; iint_list ilist1;
ilist1.push_back(new iint(1)); ilist1.push_back(new iint(1));
......
...@@ -42,25 +42,25 @@ class0_ptr get_test_ptr() { ...@@ -42,25 +42,25 @@ class0_ptr get_test_ptr() {
return get_test_rc(); return get_test_rc();
} }
size_t test__intrusive_ptr() { int main() {
// this test dosn't test thread-safety of intrusive_ptr // this test dosn't test thread-safety of intrusive_ptr
// however, it is thread safe since it uses atomic operations only // however, it is thread safe since it uses atomic operations only
CPPA_TEST(test__intrusive_ptr); CPPA_TEST(test__intrusive_ptr);
{ {
class0_ptr p(new class0); class0_ptr p(new class0);
CPPA_CHECK_EQUAL(class0_instances, 1); CPPA_CHECK_EQUAL(class0_instances, 1);
CPPA_CHECK(p->unique()); CPPA_CHECK(p->unique());
} }
CPPA_CHECK_EQUAL(class0_instances, 0); CPPA_CHECK_EQUAL(class0_instances, 0);
{ {
class0_ptr p; class0_ptr p;
p = new class0; p = new class0;
CPPA_CHECK_EQUAL(class0_instances, 1); CPPA_CHECK_EQUAL(class0_instances, 1);
CPPA_CHECK(p->unique()); CPPA_CHECK(p->unique());
} }
CPPA_CHECK_EQUAL(class0_instances, 0); CPPA_CHECK_EQUAL(class0_instances, 0);
{ {
class0_ptr p1; class0_ptr p1;
p1 = get_test_rc(); p1 = get_test_rc();
class0_ptr p2 = p1; class0_ptr p2 = p1;
...@@ -68,7 +68,7 @@ size_t test__intrusive_ptr() { ...@@ -68,7 +68,7 @@ size_t test__intrusive_ptr() {
CPPA_CHECK_EQUAL(p1->unique(), false); CPPA_CHECK_EQUAL(p1->unique(), false);
} }
CPPA_CHECK_EQUAL(class0_instances, 0); CPPA_CHECK_EQUAL(class0_instances, 0);
{ {
std::list<class0_ptr> pl; std::list<class0_ptr> pl;
pl.push_back(get_test_ptr()); pl.push_back(get_test_ptr());
pl.push_back(get_test_rc()); pl.push_back(get_test_rc());
...@@ -77,7 +77,7 @@ size_t test__intrusive_ptr() { ...@@ -77,7 +77,7 @@ size_t test__intrusive_ptr() {
CPPA_CHECK_EQUAL(class0_instances, 3); CPPA_CHECK_EQUAL(class0_instances, 3);
} }
CPPA_CHECK_EQUAL(class0_instances, 0); CPPA_CHECK_EQUAL(class0_instances, 0);
{ {
class0_ptr p1(new class0); class0_ptr p1(new class0);
p1 = new class1; p1 = new class1;
CPPA_CHECK_EQUAL(class0_instances, 1); CPPA_CHECK_EQUAL(class0_instances, 1);
......
...@@ -22,7 +22,7 @@ using std::endl; ...@@ -22,7 +22,7 @@ using std::endl;
using std::string; using std::string;
using namespace cppa; using namespace cppa;
size_t test__local_group() { int main() {
CPPA_TEST(test__local_group); CPPA_TEST(test__local_group);
auto foo_group = group::get("local", "foo"); auto foo_group = group::get("local", "foo");
actor_ptr master = self; actor_ptr master = self;
......
...@@ -104,7 +104,7 @@ struct fobaz : sb_actor<fobaz> { ...@@ -104,7 +104,7 @@ struct fobaz : sb_actor<fobaz> {
}; };
size_t test__match() { int main() {
CPPA_TEST(test__match); CPPA_TEST(test__match);
using namespace std::placeholders; using namespace std::placeholders;
......
...@@ -63,7 +63,7 @@ void invoke_test(std::vector<any_tuple>& test_tuples, Testee& x) { ...@@ -63,7 +63,7 @@ void invoke_test(std::vector<any_tuple>& test_tuples, Testee& x) {
} }
} }
size_t test__pattern() { int main() {
CPPA_TEST(test__pattern); CPPA_TEST(test__pattern);
pattern<int, anything, int> i3; pattern<int, anything, int> i3;
......
...@@ -30,7 +30,7 @@ inline std::ostream& operator<<(std::ostream& o, const primitive_variant& pv) { ...@@ -30,7 +30,7 @@ inline std::ostream& operator<<(std::ostream& o, const primitive_variant& pv) {
using namespace cppa; using namespace cppa;
size_t test__primitive_variant() { int main() {
CPPA_TEST(test__primitive_variant); CPPA_TEST(test__primitive_variant);
std::uint32_t forty_two = 42; std::uint32_t forty_two = 42;
......
...@@ -16,6 +16,24 @@ using namespace cppa; ...@@ -16,6 +16,24 @@ using namespace cppa;
namespace { namespace {
std::vector<string_pair> get_kv_pairs(int argc, char** argv, int begin = 1) {
std::vector<string_pair> result;
for (int i = begin; i < argc; ++i) {
auto vec = split(argv[i], '=');
if (vec.size() != 2) {
cerr << "\"" << argv[i] << "\" is not a key-value pair" << endl;
}
else if (std::any_of(result.begin(), result.end(),
[&](const string_pair& p) { return p.first == vec[0]; })) {
cerr << "key \"" << vec[0] << "\" is already defined" << endl;
}
else {
result.emplace_back(vec[0], vec[1]);
}
}
return result;
}
void client_part(const std::vector<string_pair>& args) { void client_part(const std::vector<string_pair>& args) {
auto i = std::find_if(args.begin(), args.end(), auto i = std::find_if(args.begin(), args.end(),
[](const string_pair& p) { return p.first == "port"; }); [](const string_pair& p) { return p.first == "port"; });
...@@ -31,9 +49,10 @@ void client_part(const std::vector<string_pair>& args) { ...@@ -31,9 +49,10 @@ void client_part(const std::vector<string_pair>& args) {
} // namespace <anonymous> } // namespace <anonymous>
size_t test__remote_actor(const char* app_path, bool is_client, int main(int argc, char** argv) {
const std::vector<string_pair>& args) { const char* app_path = argv[0];
if (is_client) { if (argc > 1) {
auto args = get_kv_pairs(argc, argv);
client_part(args); client_part(args);
return 0; return 0;
} }
......
...@@ -26,7 +26,7 @@ std::string str_hash(const std::string& what) { ...@@ -26,7 +26,7 @@ std::string str_hash(const std::string& what) {
// verify ripemd implementation with example hash results from // verify ripemd implementation with example hash results from
// http://homes.esat.kuleuven.be/~bosselae/ripemd160.html // http://homes.esat.kuleuven.be/~bosselae/ripemd160.html
size_t test__ripemd_160() { int main() {
CPPA_TEST(test__ripemd_160); CPPA_TEST(test__ripemd_160);
CPPA_CHECK_EQUAL(str_hash(""), CPPA_CHECK_EQUAL(str_hash(""),
"9c1185a5c5e9fc54612808977ee8f548b2258d31"); "9c1185a5c5e9fc54612808977ee8f548b2258d31");
......
...@@ -104,7 +104,7 @@ bool operator!=(const struct_c& lhs, const struct_c& rhs) { ...@@ -104,7 +104,7 @@ bool operator!=(const struct_c& lhs, const struct_c& rhs) {
static const char* msg1str = u8R"__(@<> ( { @i32 ( 42 ), @str ( "Hello \"World\"!" ) } ))__"; static const char* msg1str = u8R"__(@<> ( { @i32 ( 42 ), @str ( "Hello \"World\"!" ) } ))__";
size_t test__serialization() { int main() {
CPPA_TEST(test__serialization); CPPA_TEST(test__serialization);
auto oarr = new detail::object_array; auto oarr = new detail::object_array;
......
...@@ -407,7 +407,7 @@ class fixed_stack : public sb_actor<fixed_stack> { ...@@ -407,7 +407,7 @@ class fixed_stack : public sb_actor<fixed_stack> {
}; };
#endif #endif
size_t test__spawn() { int main() {
using std::string; using std::string;
CPPA_TEST(test__spawn); CPPA_TEST(test__spawn);
......
...@@ -98,7 +98,7 @@ struct is_same_ : std::is_same<typename First::second, typename Second::second> ...@@ -98,7 +98,7 @@ struct is_same_ : std::is_same<typename First::second, typename Second::second>
CPPA_ERROR(#FunName " erroneously invoked"); \ CPPA_ERROR(#FunName " erroneously invoked"); \
} invoked = "" } invoked = ""
size_t test__tuple() { int main() {
CPPA_TEST(test__tuple); CPPA_TEST(test__tuple);
using namespace cppa::placeholders; using namespace cppa::placeholders;
...@@ -407,77 +407,7 @@ size_t test__tuple() { ...@@ -407,77 +407,7 @@ size_t test__tuple() {
} }
} }
exit(0); //exit(0);
/*
VERBOSE(f00(42, 42));
VERBOSE(f01(42, 42));
VERBOSE(f02(42, 42));
VERBOSE(f02(42, 21));
VERBOSE(f03(42, 42));
cout << detail::demangle(typeid(f04).name()) << endl;
VERBOSE(f04(42, 42));
VERBOSE(f04(42, std::string("42")));
VERBOSE(f05(42, 42));
VERBOSE(f05(42, std::string("41")));
VERBOSE(f05(42, std::string("42")));
VERBOSE(f05(42, std::string("hello world!")));
auto f06 = f04.or_else(on<int, int>().when(_x2 > _x1) >> []() { });
VERBOSE(f06(42, 42));
VERBOSE(f06(1, 2));
*/
/*
auto f06 = on<anything, int>() >> []() { };
VERBOSE(f06(1));
VERBOSE(f06(1.f, 2));
*/
/*
auto f0 = cfun<token1>([](int, int) { cout << "f0[0]!" << endl; }, _x1 < _x2)
//.or_else(f00)
.or_else(cfun<token1>([](int, int) { cout << "f0[1]!" << endl; }, _x1 > _x2))
.or_else(cfun<token1>([](int, int) { cout << "f0[2]!" << endl; }, _x1 == 2 && _x2 == 2))
.or_else(cfun<token2>([](float) { cout << "f0[3]!" << endl; }, value_guard< util::type_list<> >{}))
.or_else(cfun<token1>([](int, int) { cout << "f0[4]" << endl; }, value_guard< util::type_list<> >{}));
//VERBOSE(f0(make_cow_tuple(1, 2)));
VERBOSE(f0(3, 3));
VERBOSE(f0.invoke(make_cow_tuple(3, 3)));
VERBOSE(f0.invoke(make_cow_tuple(2, 2)));
VERBOSE(f0.invoke(make_cow_tuple(3, 2)));
VERBOSE(f0.invoke(make_cow_tuple(1.f)));
auto f1 = cfun<token1>([](float, int) { cout << "f1!" << endl; }, _x1 < 6, tofloat);
VERBOSE(f1.invoke(make_cow_tuple(5, 6)));
VERBOSE(f1.invoke(make_cow_tuple(6, 7)));
auto i2 = make_cow_tuple(1, 2);
VERBOSE(f0.invoke(*i2.vals()->type_token(), i2.vals()->impl_type(), i2.vals()->native_data(), *(i2.vals())));
VERBOSE(f1.invoke(*i2.vals()->type_token(), i2.vals()->impl_type(), i2.vals()->native_data(), *(i2.vals())));
any_tuple dt1; {
auto oarr = new detail::object_array;
oarr->push_back(object::from(1));
oarr->push_back(object::from(2));
dt1 = any_tuple{static_cast<detail::abstract_tuple*>(oarr)};
}
VERBOSE(f0.invoke(*dt1.cvals()->type_token(), dt1.cvals()->impl_type(), dt1.cvals()->native_data(), *dt1.cvals()));
VERBOSE(f1.invoke(*dt1.cvals()->type_token(), dt1.cvals()->impl_type(), dt1.cvals()->native_data(), *dt1.cvals()));
*/
// check type correctness of make_cow_tuple() // check type correctness of make_cow_tuple()
auto t0 = make_cow_tuple("1", 2); auto t0 = make_cow_tuple("1", 2);
......
...@@ -15,7 +15,7 @@ using std::is_same; ...@@ -15,7 +15,7 @@ using std::is_same;
using namespace cppa::util; using namespace cppa::util;
size_t test__type_list() { int main() {
CPPA_TEST(test__type_list); CPPA_TEST(test__type_list);
......
...@@ -43,7 +43,7 @@ inline bool operator==(const foo& lhs, const foo& rhs) { ...@@ -43,7 +43,7 @@ inline bool operator==(const foo& lhs, const foo& rhs) {
using namespace cppa; using namespace cppa;
size_t test__uniform_type() { int main() {
CPPA_TEST(test__uniform_type); CPPA_TEST(test__uniform_type);
bool announce1 = announce<foo>(&foo::value); bool announce1 = announce<foo>(&foo::value);
bool announce2 = announce<foo>(&foo::value); bool announce2 = announce<foo>(&foo::value);
......
...@@ -35,7 +35,7 @@ struct pseudo_worker { ...@@ -35,7 +35,7 @@ struct pseudo_worker {
void coroutine(void* worker) { (*reinterpret_cast<pseudo_worker*>(worker))(); } void coroutine(void* worker) { (*reinterpret_cast<pseudo_worker*>(worker))(); }
size_t test__yield_interface() { int main() {
CPPA_TEST(test__yield_interface); CPPA_TEST(test__yield_interface);
# ifdef CPPA_DISABLE_CONTEXT_SWITCHING # ifdef CPPA_DISABLE_CONTEXT_SWITCHING
cout << "WARNING: context switching was explicitly disabled using " cout << "WARNING: context switching was explicitly disabled using "
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment