async_result_ut.cpp 680 B

12345678910111213141516171819202122232425262728293031323334353637
  1. #include <library/cpp/testing/unittest/registar.h>
  2. #include "async_result.h"
  3. namespace {
  4. void SetValue(int* location, const int& value) {
  5. *location = value;
  6. }
  7. }
  8. Y_UNIT_TEST_SUITE(TAsyncResult) {
  9. Y_UNIT_TEST(AndThen_Here) {
  10. TAsyncResult<int> r;
  11. int var = 1;
  12. r.SetResult(17);
  13. r.AndThen(std::bind(&SetValue, &var, std::placeholders::_1));
  14. UNIT_ASSERT_VALUES_EQUAL(17, var);
  15. }
  16. Y_UNIT_TEST(AndThen_Later) {
  17. TAsyncResult<int> r;
  18. int var = 1;
  19. r.AndThen(std::bind(&SetValue, &var, std::placeholders::_1));
  20. r.SetResult(17);
  21. UNIT_ASSERT_VALUES_EQUAL(17, var);
  22. }
  23. }