Commit 0941ce7f by Fergus Henderson Committed by Copybara-Service

Enable Cord tests with Crc.

PiperOrigin-RevId: 629403229
Change-Id: I24762df161f8a0ea41e59765ec68273f8607166b
parent f638e342
...@@ -243,12 +243,14 @@ class CordTestPeer { ...@@ -243,12 +243,14 @@ class CordTestPeer {
ABSL_NAMESPACE_END ABSL_NAMESPACE_END
} // namespace absl } // namespace absl
// The CordTest fixture runs all tests with and without Cord Btree enabled,
// and with our without expected CRCs being set on the subject Cords.
class CordTest : public testing::TestWithParam<int> { // The CordTest fixture runs all tests with and without expected CRCs being set
// on the subject Cords.
class CordTest : public testing::TestWithParam<bool /*useCrc*/> {
public: public:
// Returns true if test is running with btree enabled. // Returns true if test is running with Crc enabled.
bool UseCrc() const { return GetParam() == 2 || GetParam() == 3; } bool UseCrc() const { return GetParam(); }
void MaybeHarden(absl::Cord& c) { void MaybeHarden(absl::Cord& c) {
if (UseCrc()) { if (UseCrc()) {
c.SetExpectedChecksum(1); c.SetExpectedChecksum(1);
...@@ -260,20 +262,16 @@ class CordTest : public testing::TestWithParam<int> { ...@@ -260,20 +262,16 @@ class CordTest : public testing::TestWithParam<int> {
} }
// Returns human readable string representation of the test parameter. // Returns human readable string representation of the test parameter.
static std::string ToString(testing::TestParamInfo<int> param) { static std::string ToString(testing::TestParamInfo<bool> useCrc) {
switch (param.param) { if (useCrc.param) {
case 0:
return "Btree";
case 1:
return "BtreeHardened"; return "BtreeHardened";
default: } else {
assert(false); return "Btree";
return "???";
} }
} }
}; };
INSTANTIATE_TEST_SUITE_P(WithParam, CordTest, testing::Values(0, 1), INSTANTIATE_TEST_SUITE_P(WithParam, CordTest, testing::Bool(),
CordTest::ToString); CordTest::ToString);
TEST(CordRepFlat, AllFlatCapacities) { TEST(CordRepFlat, AllFlatCapacities) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment