Skip to content

Commit

Permalink
meta/pp: add more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Hedede committed Mar 24, 2024
1 parent fcd5abc commit 72de8b4
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 0 deletions.
3 changes: 3 additions & 0 deletions meta/tests/pp/foldl.c++
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@
using namespace std::string_view_literals;

static_assert(AW_TO_STR(AW_FOLD_LEFT(AW_IDENTITY, AW_TO_STR, a, b, c)) == R"("a", "b", "c")"sv);

#define SHOW_ASSOC( a, b ) (a b)
static_assert(AW_TO_STR(AW_FOLDL(SHOW_ASSOC, 1, 2, 3, 4, 5, 6, 7)) == "((((((1 2) 3) 4) 5) 6) 7)"sv);
3 changes: 3 additions & 0 deletions meta/tests/pp/foldr.c++
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@ using namespace std::string_view_literals;

static_assert(AW_TO_STR(AW_FOLD_RIGHT(AW_IDENTITY, AW_TO_STR, a, b, c)) == R"("a", "b", "c")"sv);
static_assert(AW_TO_STR(AW_FOREACH(AW_TO_STR, a, b, c)) == R"("a", "b", "c")"sv);

#define SHOW_ASSOC( a, b ) (a b)
static_assert(AW_TO_STR(AW_FOLDR(SHOW_ASSOC, 1, 2, 3, 4, 5, 6, 7)) == "(1 (2 (3 (4 (5 (6 7))))))"sv);
1 change: 1 addition & 0 deletions meta/tests/pp/tuple.c++
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ static_assert(AW_TO_STR(AW_FIRST( a,b,c )) == "a"sv);
static_assert(AW_TO_STR(AW_SECOND( a,b,c )) == "b"sv);
static_assert(AW_TO_STR(AW_TAIL( a,b,c )) == "b,c"sv);
static_assert(AW_TO_STR(AW_UNPACK( AW_TUPLE(a,b,c) )) == "a,b,c"sv);
static_assert(AW_TO_STR(AW_COMBINE( AW_TUPLE(a,b), AW_TUPLE(c,d)) ) == "(a,b,c,d)"sv);
11 changes: 11 additions & 0 deletions meta/tests/pp/tuple_fold.c++
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#include <aw/meta/pp/tuple.h>
#include <aw/meta/pp/separators.h>
#include <aw/meta/pp/foldr.h>

#include <string_view>

using namespace std::string_view_literals;

static_assert(
AW_TO_STR(AW_FOLD_RIGHT( AW_COMBINE, AW_IDENTITY, (1), (2), (3), (4), (5), (6), (7) )) ==
"(1,2,3,4,5,6,7)"sv);

0 comments on commit 72de8b4

Please sign in to comment.