expression decomposition first steps!
diff --git a/examples/dev_testing/CMakeLists.txt b/examples/dev_testing/CMakeLists.txt
index 964ac58..9b7c84a 100644
--- a/examples/dev_testing/CMakeLists.txt
+++ b/examples/dev_testing/CMakeLists.txt
@@ -1,6 +1,7 @@
cmake_minimum_required(VERSION 2.8)
-project(dev_testing)
+get_filename_component(PROJECT_NAME ${CMAKE_CURRENT_SOURCE_DIR} NAME)
+project(${PROJECT_NAME})
include(../../scripts/flags.cmake)
diff --git a/examples/dev_testing/main.cpp b/examples/dev_testing/main.cpp
index 9b86b8a..46da5e6 100644
--- a/examples/dev_testing/main.cpp
+++ b/examples/dev_testing/main.cpp
@@ -6,85 +6,23 @@
#include <cstdio>
#include <exception>
-#define DECOMPOSE(expr) (expression_decomposer() << expr)
-
-#define EXPECT(expr) \
- do { \
- if(result failed = DECOMPOSE(expr)) \
- printf("failed!\n"); \
- } while(false)
-
-struct result
+#include <string>
+namespace doctest
{
- const bool passed;
- const doctest::String decomposition;
-
- result(bool passed, const doctest::String& decomposition)
- : passed(passed), decomposition(decomposition) {}
- operator bool() { return !passed; }
-};
-
-//inline std::string to_string(std::string const & text) { return "\"" + text + "\""; }
-inline doctest::String to_string(const char * text) { return doctest::String("\"") + text + "\""; }
-//inline doctest::String to_string(char text) { return doctest::String("\'") + text + "\'"; }
-
-inline std::ostream & operator<<(std::ostream & os, approx const & appr)
+namespace detail
{
- return os << appr.magnitude();
-}
-
-template <typename T>
-std::string to_string(T const & value, int = 0 /* VC6 */)
-{
- std::ostringstream os; os << std::boolalpha << value; return os.str();
-}
-
-template<typename T1, typename T2>
-std::string to_string(std::pair<T1, T2> const & pair)
-{
- std::ostringstream oss;
- oss << "{ " << to_string(pair.first) << ", " << to_string(pair.second) << " }";
- return oss.str();
-}
-
-template <typename L, typename R>
-std::string to_string(L const & lhs, std::string op, R const & rhs)
-{
- std::ostringstream os; os << to_string(lhs) << " " << op << " " << to_string(rhs); return os.str();
-}
-
-
-template <typename L>
-struct expression_lhs
-{
- const L lhs;
-
- expression_lhs(L lhs)
- : lhs(lhs) {}
-
- operator result() { return result(!!lhs, to_string(lhs)); }
-
- // clang-format off
- template <typename R> result operator==(R const & rhs) { return result(lhs == rhs, to_string(lhs, "==", rhs)); }
- template <typename R> result operator!=(R const & rhs) { return result(lhs != rhs, to_string(lhs, "!=", rhs)); }
- template <typename R> result operator< (R const & rhs) { return result(lhs < rhs, to_string(lhs, "<", rhs)); }
- template <typename R> result operator<=(R const & rhs) { return result(lhs <= rhs, to_string(lhs, "<=", rhs)); }
- template <typename R> result operator> (R const & rhs) { return result(lhs > rhs, to_string(lhs, ">", rhs)); }
- template <typename R> result operator>=(R const & rhs) { return result(lhs >= rhs, to_string(lhs, ">=", rhs)); }
- // clang-format on
-};
-
-struct expression_decomposer
-{
- template <typename L>
- expression_lhs<L const&> operator<<(L const& operand) {
- return expression_lhs<L const &>(operand);
+ template <>
+ String stringify(const std::string& in) {
+ return in.c_str();
}
-};
-
+} // namespace detail
+} // namespace doctest
testsuite(MAIN);
test(zzz) {
+ check(true == false);
+ check(std::string("OMG2") == std::string("OMG"));
+
printf("main\n");
subtest("") {
printf("1\n");
diff --git a/examples/disabled/CMakeLists.txt b/examples/disabled/CMakeLists.txt
index 3e44f8f..813ebfa 100644
--- a/examples/disabled/CMakeLists.txt
+++ b/examples/disabled/CMakeLists.txt
@@ -1,6 +1,7 @@
cmake_minimum_required(VERSION 2.8)
-project(disabled)
+get_filename_component(PROJECT_NAME ${CMAKE_CURRENT_SOURCE_DIR} NAME)
+project(${PROJECT_NAME})
include(../../scripts/flags.cmake)
diff --git a/examples/hello_world/CMakeLists.txt b/examples/hello_world/CMakeLists.txt
index 3defdd0..813ebfa 100644
--- a/examples/hello_world/CMakeLists.txt
+++ b/examples/hello_world/CMakeLists.txt
@@ -1,6 +1,7 @@
cmake_minimum_required(VERSION 2.8)
-project(hello_world)
+get_filename_component(PROJECT_NAME ${CMAKE_CURRENT_SOURCE_DIR} NAME)
+project(${PROJECT_NAME})
include(../../scripts/flags.cmake)
diff --git a/examples/multi_dll/CMakeLists.txt b/examples/multi_dll/CMakeLists.txt
index 9b7623d..6610da1 100644
--- a/examples/multi_dll/CMakeLists.txt
+++ b/examples/multi_dll/CMakeLists.txt
@@ -1,6 +1,7 @@
cmake_minimum_required(VERSION 2.8)
-project(multi_dll)
+get_filename_component(PROJECT_NAME ${CMAKE_CURRENT_SOURCE_DIR} NAME)
+project(${PROJECT_NAME})
include(../../scripts/flags.cmake)
diff --git a/examples/multiprocess/CMakeLists.txt b/examples/multiprocess/CMakeLists.txt
index 85347e2..6f99712 100644
--- a/examples/multiprocess/CMakeLists.txt
+++ b/examples/multiprocess/CMakeLists.txt
@@ -1,6 +1,7 @@
cmake_minimum_required(VERSION 2.8)
-project(multiprocess)
+get_filename_component(PROJECT_NAME ${CMAKE_CURRENT_SOURCE_DIR} NAME)
+project(${PROJECT_NAME})
include(../../scripts/flags.cmake)
diff --git a/examples/stress_test/CMakeLists.txt b/examples/stress_test/CMakeLists.txt
index 2b01923..7998851 100644
--- a/examples/stress_test/CMakeLists.txt
+++ b/examples/stress_test/CMakeLists.txt
@@ -6,7 +6,8 @@
return()
endif()
-project(stress_test)
+get_filename_component(PROJECT_NAME ${CMAKE_CURRENT_SOURCE_DIR} NAME)
+project(${PROJECT_NAME})
include(../../scripts/flags.cmake)
diff --git a/examples/type_reporting/CMakeLists.txt b/examples/type_reporting/CMakeLists.txt
new file mode 100644
index 0000000..813ebfa
--- /dev/null
+++ b/examples/type_reporting/CMakeLists.txt
@@ -0,0 +1,12 @@
+cmake_minimum_required(VERSION 2.8)
+
+get_filename_component(PROJECT_NAME ${CMAKE_CURRENT_SOURCE_DIR} NAME)
+project(${PROJECT_NAME})
+
+include(../../scripts/flags.cmake)
+
+include_directories("../../doctest/")
+
+add_executable(${PROJECT_NAME} main.cpp)
+
+add_test(NAME ${PROJECT_NAME} COMMAND $<TARGET_FILE:${PROJECT_NAME}>)
diff --git a/examples/type_reporting/main.cpp b/examples/type_reporting/main.cpp
new file mode 100644
index 0000000..28f6746
--- /dev/null
+++ b/examples/type_reporting/main.cpp
@@ -0,0 +1,30 @@
+#define DOCTEST_CONFIG_MAIN
+#define DOCTEST_CONFIG_IMPLEMENT
+#include "doctest.h"
+
+#include <climits>
+#include <cstdio>
+#include <string>
+
+// @TODO: maybe also check if __cplusplus == 201103 or higher?
+#if defined(_MSC_EXTENSIONS) || (defined(_MSC_VER) && (_MSC_VER >= 1400))
+#define HAS_LONG_LONG
+#elif (defined(ULLONG_MAX) || defined(ULONG_LONG_MAX) || defined(ULONGLONG_MAX))
+#define HAS_LONG_LONG
+#endif
+
+// @TODO: look at https://github.com/louisdx/cxx-prettyprint
+namespace doctest {
+namespace detail {
+ template <>
+ String stringify(const std::string& in) {
+ return in.c_str();
+ }
+} // namespace detail
+} // namespace doctest
+
+doctest_test(First) {
+ std::string dummy1 = "omg";
+ std::string dummy2 = "tralala";
+ doctest_check(dummy1 == dummy2);
+}