aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/messagebus/async_result_ut.cpp
blob: 93f010d1f530a81446a065e44033d5e2ada4baad (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
 
#include <library/cpp/testing/unittest/registar.h>
 
#include "async_result.h" 
 
namespace { 
    void SetValue(int* location, const int& value) { 
        *location = value; 
    } 
 
} 
 
Y_UNIT_TEST_SUITE(TAsyncResult) {
    Y_UNIT_TEST(AndThen_Here) {
        TAsyncResult<int> r; 
 
        int var = 1; 
 
        r.SetResult(17); 
 
        r.AndThen(std::bind(&SetValue, &var, std::placeholders::_1));
 
        UNIT_ASSERT_VALUES_EQUAL(17, var); 
    } 
 
    Y_UNIT_TEST(AndThen_Later) {
        TAsyncResult<int> r; 
 
        int var = 1; 
 
        r.AndThen(std::bind(&SetValue, &var, std::placeholders::_1));
 
        r.SetResult(17); 
 
        UNIT_ASSERT_VALUES_EQUAL(17, var); 
    } 
}