forked from rsocket/rsocket-cpp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStreamStateTest.cpp
More file actions
36 lines (30 loc) · 1.13 KB
/
StreamStateTest.cpp
File metadata and controls
36 lines (30 loc) · 1.13 KB
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
// Copyright 2004-present Facebook. All Rights Reserved.
#include <gmock/gmock.h>
#include <gtest/gtest.h>
#include "rsocket/statemachine/StreamState.h"
#include "test/test_utils/MockStats.h"
using namespace rsocket;
using namespace testing;
class StreamStateTest : public Test {
protected:
StrictMock<MockStats> stats_;
StreamState state_{stats_};
};
TEST_F(StreamStateTest, Stats) {
auto frame1Size = 7, frame2Size = 11;
EXPECT_CALL(stats_, streamBufferChanged(1, frame1Size));
state_.enqueueOutputPendingFrame(
folly::IOBuf::copyBuffer(std::string(frame1Size, 'x')));
EXPECT_CALL(stats_, streamBufferChanged(1, frame2Size));
state_.enqueueOutputPendingFrame(
folly::IOBuf::copyBuffer(std::string(frame2Size, 'x')));
EXPECT_CALL(stats_, streamBufferChanged(-2, -(frame1Size + frame2Size)));
state_.moveOutputPendingFrames();
}
TEST_F(StreamStateTest, StatsUpdatedInDtor) {
auto frameSize = 7;
EXPECT_CALL(stats_, streamBufferChanged(1, frameSize));
state_.enqueueOutputPendingFrame(
folly::IOBuf::copyBuffer(std::string(frameSize, 'x')));
EXPECT_CALL(stats_, streamBufferChanged(-1, -frameSize));
}