MCPcopy Create free account
hub / github.com/bytedance/bolt / TEST

Function TEST

bolt/common/base/tests/SpillConfigTest.cpp:40–93  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

38using namespace bytedance::bolt::exec;
39
40TEST(SpillConfig, spillLevel) {
41 const uint8_t kInitialBitOffset = 16;
42 const uint8_t kNumPartitionsBits = 3;
43 static const std::string emptyPath = "";
44 GetSpillDirectoryPathCB getPathCb = [&]() -> const std::string& {
45 return emptyPath;
46 };
47 UpdateAndCheckSpillLimitCB checkLimitCb = [&](uint64_t) {};
48 const SpillConfig config(
49 getPathCb,
50 checkLimitCb,
51 "fakeSpillPath",
52 0,
53 false,
54 0,
55 nullptr,
56 0,
57 0,
58 kInitialBitOffset,
59 kNumPartitionsBits,
60 0,
61 0,
62 0,
63 0,
64 "none");
65 struct {
66 uint8_t bitOffset;
67 // Indicates an invalid if 'expectedLevel' is negative.
68 int32_t expectedLevel;
69
70 std::string debugString() const {
71 return fmt::format(
72 "bitOffset:{}, expectedLevel:{}", bitOffset, expectedLevel);
73 }
74 } testSettings[] = {
75 {0, -1},
76 {kInitialBitOffset - 1, -1},
77 {kInitialBitOffset - kNumPartitionsBits, -1},
78 {kInitialBitOffset, 0},
79 {kInitialBitOffset + 1, -1},
80 {kInitialBitOffset + kNumPartitionsBits, 1},
81 {kInitialBitOffset + 3 * kNumPartitionsBits, 3},
82 {kInitialBitOffset + 15 * kNumPartitionsBits, 15},
83 {kInitialBitOffset + 16 * kNumPartitionsBits, -1}};
84 for (const auto& testData : testSettings) {
85 SCOPED_TRACE(testData.debugString());
86 if (testData.expectedLevel == -1) {
87 ASSERT_ANY_THROW(config.joinSpillLevel(testData.bitOffset));
88 } else {
89 ASSERT_EQ(
90 config.joinSpillLevel(testData.bitOffset), testData.expectedLevel);
91 }
92 }
93}
94
95TEST(SpillConfig, spillLevelLimit) {
96 struct {

Callers

nothing calls this directly

Calls 7

makeFullConfigFunction · 0.85
assertFieldsEqualFunction · 0.85
joinSpillLevelMethod · 0.80
deserializeFunction · 0.50
debugStringMethod · 0.45
serializeMethod · 0.45

Tested by

no test coverage detected