diff options
author | Alon Zakai <azakai@google.com> | 2022-10-28 12:15:53 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-28 19:15:53 +0000 |
commit | 8ab8e40d15a4d9f28ced76d28232f9e791f161d3 (patch) | |
tree | 993722fe48256cca1d57bf553fb15e6be62333a0 /test/gtest/possible-contents.cpp | |
parent | 7e7dd338b9ae6026f54f3384bebe095fefb9fab5 (diff) | |
download | binaryen-8ab8e40d15a4d9f28ced76d28232f9e791f161d3.tar.gz binaryen-8ab8e40d15a4d9f28ced76d28232f9e791f161d3.tar.bz2 binaryen-8ab8e40d15a4d9f28ced76d28232f9e791f161d3.zip |
[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.
Diffstat (limited to 'test/gtest/possible-contents.cpp')
-rw-r--r-- | test/gtest/possible-contents.cpp | 15 |
1 files changed, 11 insertions, 4 deletions
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<typename T> void assertNotEqualSymmetric(const T& a, const T& b) { // Asserts a combined with b (in any order) is equal to c. template<typename T> 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. |