Skip to content

Commit

Permalink
chore: Ready to get released
Browse files Browse the repository at this point in the history
  • Loading branch information
cwahn committed Mar 9, 2024
1 parent 0b630b5 commit 7b2c850
Showing 1 changed file with 25 additions and 23 deletions.
48 changes: 25 additions & 23 deletions test/efp/maybe_test.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,29 +183,31 @@ TEST_CASE("Maybe as bool") {
// CHECK(action_2(true, true).value() == 42);
// }

SECTION("example") {
Enum<bool, int, double> x = 2; // Example with int

int y = x.match(
[](int x) { return x * 2; }, // Specific branch for int
[]() { return -1; } // Wildcard branch
);
CHECK(y == 4);

// Maybe<A> is a specialization of Enum<Nothing, A>
Maybe<int> maybe_42 = 42;
Maybe<int> no_value = nothing;

// Using value() and isEmpty() for direct value access and checking
CHECK(maybe_42.value() == 42);
CHECK(no_value.is_nothing() == true);

int result = maybe_42.match(
[](int x) { return x; }, // Executes if there's a value
[]() { return 0; } // Executes if empty (wildcard)
);
CHECK(result == 42);
}
// todo Make example test

// SECTION("example") {
// Enum<bool, int, double> x = 2; // Example with int

// int y = x.match(
// [](int x) { return x * 2; }, // Specific branch for int
// []() { return -1; } // Wildcard branch
// );
// CHECK(y == 4);

// // Maybe<A> is a specialization of Enum<Nothing, A>
// Maybe<int> maybe_42 = 42;
// Maybe<int> no_value = nothing;

// // Using value() and isEmpty() for direct value access and checking
// CHECK(maybe_42.value() == 42);
// CHECK(no_value.is_nothing() == true);

// int result = maybe_42.match(
// [](int x) { return x; }, // Executes if there's a value
// []() { return 0; } // Executes if empty (wildcard)
// );
// CHECK(result == 42);
// }
}

TEST_CASE("EnumAt on Maybe") {
Expand Down

0 comments on commit 7b2c850

Please sign in to comment.