File tree 4 files changed +38
-48
lines changed
thrift/lib/cpp2/transport/rocket/framing/parser/test
4 files changed +38
-48
lines changed Original file line number Diff line number Diff line change 16
16
17
17
#include < gtest/gtest.h>
18
18
#include < thrift/lib/cpp2/transport/rocket/framing/parser/AllocatingParserStrategy.h>
19
+ #include < thrift/lib/cpp2/transport/rocket/framing/parser/test/TestUtil.h>
19
20
20
21
namespace apache {
21
22
namespace thrift {
22
23
namespace rocket {
23
24
24
- class FakeOwner {
25
- public:
26
- void handleFrame (std::unique_ptr<folly::IOBuf> buf) {
27
- frames_.push_back (std::move (buf));
28
- }
29
- bool incMemoryUsage (uint32_t n) {
30
- memoryCounter_ += n;
31
- return true ;
32
- }
33
- void decMemoryUsage (uint32_t n) { memoryCounter_ -= n; }
34
-
35
- std::vector<std::unique_ptr<folly::IOBuf>> frames_{};
36
-
37
- uint32_t memoryCounter_ = 0 ;
38
- };
39
-
40
25
ParserAllocatorType alloc = ParserAllocatorType();
41
26
42
27
TEST (AllocatingParserStrategyTest, testAppendFrame) {
Original file line number Diff line number Diff line change 18
18
19
19
#include < folly/io/IOBuf.h>
20
20
#include < thrift/lib/cpp2/transport/rocket/framing/parser/FrameLengthParserStrategy.h>
21
+ #include < thrift/lib/cpp2/transport/rocket/framing/parser/test/TestUtil.h>
21
22
22
23
namespace apache {
23
24
namespace thrift {
24
25
namespace rocket {
25
26
26
- class FakeOwner {
27
- public:
28
- void handleFrame (std::unique_ptr<folly::IOBuf> buf) {
29
- frames_.push_back (std::move (buf));
30
- }
31
- bool incMemoryUsage (uint32_t n) {
32
- memoryCounter_ += n;
33
- return true ;
34
- }
35
- void decMemoryUsage (uint32_t n) { memoryCounter_ -= n; }
36
-
37
- std::vector<std::unique_ptr<folly::IOBuf>> frames_{};
38
-
39
- uint32_t memoryCounter_ = 0 ;
40
- };
41
-
42
27
TEST (FrameLengthParserTest, testAppendFrame) {
43
28
FakeOwner owner;
44
29
FrameLengthParserStrategy<FakeOwner> parser (owner);
Original file line number Diff line number Diff line change 19
19
#include < folly/io/IOBuf.h>
20
20
#include < thrift/lib/cpp2/transport/rocket/framing/parser/FrameLengthParserStrategy.h>
21
21
#include < thrift/lib/cpp2/transport/rocket/framing/parser/ParserStrategy.h>
22
+ #include < thrift/lib/cpp2/transport/rocket/framing/parser/test/TestUtil.h>
22
23
23
24
namespace apache {
24
25
namespace thrift {
25
26
namespace rocket {
26
27
27
- class FakeOwner {
28
- public:
29
- void handleFrame (std::unique_ptr<folly::IOBuf> buf) {
30
- frames_.push_back (std::move (buf));
31
- }
32
- bool incMemoryUsage (uint32_t n) {
33
- memoryCounter_ += n;
34
- return true ;
35
- }
36
- void decMemoryUsage (uint32_t n) { memoryCounter_ -= n; }
37
-
38
- std::vector<std::unique_ptr<folly::IOBuf>> frames_{};
39
-
40
- uint32_t memoryCounter_ = 0 ;
41
- };
42
-
43
28
TEST (ParserTest, testAppendFrame) {
44
29
FakeOwner owner;
45
30
ParserStrategy<FakeOwner, FrameLengthParserStrategy> parser (owner);
Original file line number Diff line number Diff line change
1
+ /*
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ #pragma once
18
+
19
+ namespace apache ::thrift::rocket {
20
+ class FakeOwner {
21
+ public:
22
+ void handleFrame (std::unique_ptr<folly::IOBuf> buf) {
23
+ frames_.push_back (std::move (buf));
24
+ }
25
+ bool incMemoryUsage (uint32_t n) {
26
+ memoryCounter_ += n;
27
+ return true ;
28
+ }
29
+ void decMemoryUsage (uint32_t n) { memoryCounter_ -= n; }
30
+
31
+ std::vector<std::unique_ptr<folly::IOBuf>> frames_{};
32
+
33
+ uint32_t memoryCounter_ = 0 ;
34
+ };
35
+ } // namespace apache::thrift::rocket
You can’t perform that action at this time.
0 commit comments