From aa6eb5cd8061983e476c7e3a2a9eeaad4bb179f8 Mon Sep 17 00:00:00 2001 From: Tobias Grosser Date: Fri, 26 Aug 2016 12:25:08 +0000 Subject: [PATCH] unittests: Make the expected value the first argument in EXPECT_EQ [NFC] This improves the readability of failing test results, as gtest prints always the first argument as the 'expected value'. In the previous commit we already changed the tests for isl_valFromAPInt. In this commit, the tests for IslValToAPInt follow. Suggested-by: Michael Kruse llvm-svn: 279817 --- polly/unittests/Isl/IslTest.cpp | 65 ++++++++++++++++++++--------------------- 1 file changed, 32 insertions(+), 33 deletions(-) diff --git a/polly/unittests/Isl/IslTest.cpp b/polly/unittests/Isl/IslTest.cpp index 5dccaba..46a2cdf 100644 --- a/polly/unittests/Isl/IslTest.cpp +++ b/polly/unittests/Isl/IslTest.cpp @@ -114,82 +114,81 @@ TEST(Isl, IslValToAPInt) { auto *IslNOne = isl_val_int_from_si(IslCtx, -1); auto APNOne = APIntFromVal(IslNOne); // Compare with the two's complement of -1 in a 1-bit integer. - EXPECT_EQ(APNOne, 1); - EXPECT_EQ(APNOne.getBitWidth(), 1u); + EXPECT_EQ(1, APNOne); + EXPECT_EQ(1u, APNOne.getBitWidth()); } { auto *IslNTwo = isl_val_int_from_si(IslCtx, -2); auto APNTwo = APIntFromVal(IslNTwo); // Compare with the two's complement of -2 in a 2-bit integer. - EXPECT_EQ(APNTwo, 2); - EXPECT_EQ(APNTwo.getBitWidth(), 2u); + EXPECT_EQ(2, APNTwo); + EXPECT_EQ(2u, APNTwo.getBitWidth()); } { auto *IslNThree = isl_val_int_from_si(IslCtx, -3); auto APNThree = APIntFromVal(IslNThree); // Compare with the two's complement of -3 in a 3-bit integer. - EXPECT_EQ(APNThree, 5); - EXPECT_EQ(APNThree.getBitWidth(), 3u); + EXPECT_EQ(5, APNThree); + EXPECT_EQ(3u, APNThree.getBitWidth()); } { auto *IslNFour = isl_val_int_from_si(IslCtx, -4); auto APNFour = APIntFromVal(IslNFour); // Compare with the two's complement of -4 in a 3-bit integer. - EXPECT_EQ(APNFour, 4); - EXPECT_EQ(APNFour.getBitWidth(), 3u); + EXPECT_EQ(4, APNFour); + EXPECT_EQ(3u, APNFour.getBitWidth()); } { auto *IslZero = isl_val_int_from_ui(IslCtx, 0); auto APZero = APIntFromVal(IslZero); - EXPECT_EQ(APZero, 0); - EXPECT_EQ(APZero.getBitWidth(), 1u); + EXPECT_EQ(0, APZero); + EXPECT_EQ(1u, APZero.getBitWidth()); } { auto *IslOne = isl_val_int_from_ui(IslCtx, 1); auto APOne = APIntFromVal(IslOne); - EXPECT_EQ(APOne, 1); - EXPECT_EQ(APOne.getBitWidth(), 2u); + EXPECT_EQ(1, APOne); + EXPECT_EQ(2u, APOne.getBitWidth()); } { auto *IslTwo = isl_val_int_from_ui(IslCtx, 2); auto APTwo = APIntFromVal(IslTwo); - EXPECT_EQ(APTwo, 2); - EXPECT_EQ(APTwo.getBitWidth(), 3u); + EXPECT_EQ(2, APTwo); + EXPECT_EQ(3u, APTwo.getBitWidth()); } { auto *IslThree = isl_val_int_from_ui(IslCtx, 3); auto APThree = APIntFromVal(IslThree); - EXPECT_EQ(APThree, 3); - - EXPECT_EQ(APThree.getBitWidth(), 3u); + EXPECT_EQ(3, APThree); + EXPECT_EQ(3u, APThree.getBitWidth()); } { auto *IslFour = isl_val_int_from_ui(IslCtx, 4); auto APFour = APIntFromVal(IslFour); - EXPECT_EQ(APFour, 4); - EXPECT_EQ(APFour.getBitWidth(), 4u); + EXPECT_EQ(4, APFour); + EXPECT_EQ(4u, APFour.getBitWidth()); } { auto *IslNOne = isl_val_int_from_ui(IslCtx, (1ull << 32) - 1); auto APNOne = APIntFromVal(IslNOne); - EXPECT_EQ(APNOne, (1ull << 32) - 1); - EXPECT_EQ(APNOne.getBitWidth(), 33u); + EXPECT_EQ((1ull << 32) - 1, APNOne); + EXPECT_EQ(33u, APNOne.getBitWidth()); } { auto *IslLargeNum = isl_val_int_from_ui(IslCtx, (1ull << 60) - 1); auto APLargeNum = APIntFromVal(IslLargeNum); - EXPECT_EQ(APLargeNum, (1ull << 60) - 1); - EXPECT_EQ(APLargeNum.getBitWidth(), 61u); + EXPECT_EQ((1ull << 60) - 1, APLargeNum); + EXPECT_EQ(61u, APLargeNum.getBitWidth()); } { @@ -197,17 +196,17 @@ TEST(Isl, IslValToAPInt) { auto *IslLargePow2 = isl_val_2exp(IslExp); auto APLargePow2 = APIntFromVal(IslLargePow2); EXPECT_TRUE(APLargePow2.isPowerOf2()); - EXPECT_EQ(APLargePow2.getBitWidth(), 502u); - EXPECT_EQ(APLargePow2.getMinSignedBits(), 502u); + EXPECT_EQ(502u, APLargePow2.getBitWidth()); + EXPECT_EQ(502u, APLargePow2.getMinSignedBits()); } { auto *IslExp = isl_val_int_from_ui(IslCtx, 500); auto *IslLargeNPow2 = isl_val_neg(isl_val_2exp(IslExp)); auto APLargeNPow2 = APIntFromVal(IslLargeNPow2); - EXPECT_EQ(APLargeNPow2.getBitWidth(), 501u); - EXPECT_EQ(APLargeNPow2.getMinSignedBits(), 501u); - EXPECT_EQ((-APLargeNPow2).exactLogBase2(), 500); + EXPECT_EQ(501u, APLargeNPow2.getBitWidth()); + EXPECT_EQ(501u, APLargeNPow2.getMinSignedBits()); + EXPECT_EQ(500, (-APLargeNPow2).exactLogBase2()); } { @@ -215,17 +214,17 @@ TEST(Isl, IslValToAPInt) { auto *IslLargePow2 = isl_val_2exp(IslExp); auto APLargePow2 = APIntFromVal(IslLargePow2); EXPECT_TRUE(APLargePow2.isPowerOf2()); - EXPECT_EQ(APLargePow2.getBitWidth(), 514u); - EXPECT_EQ(APLargePow2.getMinSignedBits(), 514u); + EXPECT_EQ(514u, APLargePow2.getBitWidth()); + EXPECT_EQ(514u, APLargePow2.getMinSignedBits()); } { auto *IslExp = isl_val_int_from_ui(IslCtx, 512); auto *IslLargeNPow2 = isl_val_neg(isl_val_2exp(IslExp)); auto APLargeNPow2 = APIntFromVal(IslLargeNPow2); - EXPECT_EQ(APLargeNPow2.getBitWidth(), 513u); - EXPECT_EQ(APLargeNPow2.getMinSignedBits(), 513u); - EXPECT_EQ((-APLargeNPow2).exactLogBase2(), 512); + EXPECT_EQ(513u, APLargeNPow2.getBitWidth()); + EXPECT_EQ(513u, APLargeNPow2.getMinSignedBits()); + EXPECT_EQ(512, (-APLargeNPow2).exactLogBase2()); } isl_ctx_free(IslCtx); -- 2.7.4