|
|
|
@ -20,12 +20,13 @@ |
|
|
|
|
#include "gtest/gtest.h" |
|
|
|
|
|
|
|
|
|
#include "src/core/lib/promise/promise.h" |
|
|
|
|
#include "test/core/promise/poll_matcher.h" |
|
|
|
|
|
|
|
|
|
namespace grpc_core { |
|
|
|
|
|
|
|
|
|
TEST(MapTest, Works) { |
|
|
|
|
Promise<int> x = Map([]() { return 42; }, [](int i) { return i / 2; }); |
|
|
|
|
EXPECT_EQ(x(), Poll<int>(21)); |
|
|
|
|
EXPECT_THAT(x(), IsReady(21)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
TEST(MapTest, JustElem) { |
|
|
|
@ -34,6 +35,21 @@ TEST(MapTest, JustElem) { |
|
|
|
|
EXPECT_EQ(JustElem<0>()(t), 1); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
TEST(CheckDelayedTest, SeesImmediate) { |
|
|
|
|
auto x = CheckDelayed([]() { return 42; }); |
|
|
|
|
EXPECT_THAT(x(), IsReady(std::make_tuple(42, false))); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
TEST(CheckDelayedTest, SeesDelayed) { |
|
|
|
|
auto x = CheckDelayed([n = 1]() mutable -> Poll<int> { |
|
|
|
|
if (n == 0) return 42; |
|
|
|
|
--n; |
|
|
|
|
return Pending{}; |
|
|
|
|
}); |
|
|
|
|
EXPECT_THAT(x(), IsPending()); |
|
|
|
|
EXPECT_THAT(x(), IsReady(std::make_tuple(42, true))); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} // namespace grpc_core
|
|
|
|
|
|
|
|
|
|
int main(int argc, char** argv) { |
|
|
|
|