-
Notifications
You must be signed in to change notification settings - Fork 1
/
rx_test.mm
55 lines (42 loc) · 993 Bytes
/
rx_test.mm
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#import <Cocoa/Cocoa.h>
#import <XCTest/XCTest.h>
#import "rx_dispatch.h"
namespace rx = windberry::rx;
@interface rx_test : XCTestCase
@end
@implementation rx_test
- (void)setUp {
[super setUp];
//
}
- (void)tearDown {
//
[super tearDown];
}
- (void)testAsync {
auto ex = [self expectationWithDescription:@"got result"];
rx::pure_observable(8)
.subscribe_on(dispatch_get_global_queue(0, 0))
.deliver_on(dispatch_get_global_queue(0, 0))
.subscribe([=](int x){
XCTAssertEqual(x, 8);
[ex fulfill];
});
[self waitForExpectationsWithTimeout:0.1 handler:nil];
}
- (void)testSubject {
rx::replay_subject<int> s;
s.send_next(2);
s.send_next(4);
int expected = 2;
s.subscribe(rx::make_observer([&expected, self](int x){
XCTAssertEqual(x, expected);
expected *= 2;
}, [self](rx::default_error_type){
XCTFail();
}, [self]{
XCTFail();
}));
s.send_next(8);
}
@end