From 8ab8e40d15a4d9f28ced76d28232f9e791f161d3 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Fri, 28 Oct 2022 12:15:53 -0700 Subject: [NFC] Rewrite PossibleContents::combine to be static (#5192) This makes the logic symmetric and easier to read. Measuring speed, this seems identical to before, so that concern seems fine. --- test/gtest/possible-contents.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'test/gtest/possible-contents.cpp') diff --git a/test/gtest/possible-contents.cpp b/test/gtest/possible-contents.cpp index 63486e7a9..ea2a0c0f0 100644 --- a/test/gtest/possible-contents.cpp +++ b/test/gtest/possible-contents.cpp @@ -25,17 +25,24 @@ template void assertNotEqualSymmetric(const T& a, const T& b) { // Asserts a combined with b (in any order) is equal to c. template void assertCombination(const T& a, const T& b, const T& c) { - T temp1 = a; - temp1.combine(b); + T temp1 = PossibleContents::combine(a, b); assertEqualSymmetric(temp1, c); // Also check the type, as nulls will compare equal even if their types // differ. We want to make sure even the types are identical. assertEqualSymmetric(temp1.getType(), c.getType()); - T temp2 = b; - temp2.combine(a); + T temp2 = PossibleContents::combine(b, a); assertEqualSymmetric(temp2, c); assertEqualSymmetric(temp2.getType(), c.getType()); + + // Verify the shorthand API works like the static one. + T temp3 = a; + temp3.combine(b); + assertEqualSymmetric(temp3, temp1); + + T temp4 = b; + temp4.combine(a); + assertEqualSymmetric(temp4, temp2); } // Parse a module from text and return it. -- cgit v1.2.3