From a02a469b20198f921deb4fddc3d1ef928b313aee Mon Sep 17 00:00:00 2001 From: Brad Chase Date: Mon, 14 Aug 2017 16:44:18 -0400 Subject: [PATCH] Fix unit test compiler warnings --- src/test/app/Flow_test.cpp | 9 +++++---- src/test/app/Offer_test.cpp | 7 +++---- src/test/beast/aged_associative_container_test.cpp | 7 +++++++ src/test/ledger/Invariants_test.cpp | 4 ++-- src/test/ledger/PaymentSandbox_test.cpp | 6 +++--- 5 files changed, 20 insertions(+), 13 deletions(-) diff --git a/src/test/app/Flow_test.cpp b/src/test/app/Flow_test.cpp index 521addc5c3c..89393dfcc32 100644 --- a/src/test/app/Flow_test.cpp +++ b/src/test/app/Flow_test.cpp @@ -747,8 +747,9 @@ struct Flow_test : public beast::unit_test::suite auto const timeDelta = Env{*this}.closed ()->info ().closeTimeResolution; - for(auto const& d: {-timeDelta*100, +timeDelta*100}){ - auto const closeTime = fix1141Time () + d; + for (auto const& d : {-100 * timeDelta, +100 * timeDelta}) + { + auto const closeTime = fix1141Time () + d ; Env env (*this, no_features); env.close (closeTime); @@ -1112,7 +1113,7 @@ struct Flow_test : public beast::unit_test::suite using namespace jtx; Env env(*this, with_features(featureFlow)); auto const timeDelta = env.closed ()->info ().closeTimeResolution; - auto const d = withFix ? timeDelta*100 : -timeDelta*100; + auto const d = withFix ? 100*timeDelta : -100*timeDelta; auto closeTime = fix1443Time() + d; env.close(closeTime); @@ -1165,7 +1166,7 @@ struct Flow_test : public beast::unit_test::suite using namespace jtx; Env env(*this, with_features(featureFlow)); auto const timeDelta = env.closed ()->info ().closeTimeResolution; - auto const d = withFix ? timeDelta*100 : -timeDelta*100; + auto const d = withFix ? 100*timeDelta : -100*timeDelta; auto closeTime = fix1449Time() + d; env.close(closeTime); diff --git a/src/test/app/Offer_test.cpp b/src/test/app/Offer_test.cpp index db668540981..003b4c06e1b 100644 --- a/src/test/app/Offer_test.cpp +++ b/src/test/app/Offer_test.cpp @@ -253,11 +253,10 @@ class Offer_test : public beast::unit_test::suite for (int i=0;i<101;++i) env (offer (carol, USD (1), EUR (2))); - for (auto timeDelta : { - - env.closed()->info().closeTimeResolution, - env.closed()->info().closeTimeResolution} ) + for (auto d : {-1, 1}) { - auto const closeTime = STAmountSO::soTime + timeDelta; + auto const closeTime = STAmountSO::soTime + + d * env.closed()->info().closeTimeResolution; env.close (closeTime); *stAmountCalcSwitchover = closeTime > STAmountSO::soTime; // Will fail without the underflow fix diff --git a/src/test/beast/aged_associative_container_test.cpp b/src/test/beast/aged_associative_container_test.cpp index 8c2354a2f57..0f6e5fe3323 100644 --- a/src/test/beast/aged_associative_container_test.cpp +++ b/src/test/beast/aged_associative_container_test.cpp @@ -142,6 +142,13 @@ class aged_associative_container_test_base : public unit_test::suite return true; } + template + bool operator!= (AllocT const& o) const + { + return !(*this == o); + } + + T* allocate (std::size_t n, T const* = 0) { return static_cast ( diff --git a/src/test/ledger/Invariants_test.cpp b/src/test/ledger/Invariants_test.cpp index 65f35805ac1..c59d9de0cf4 100644 --- a/src/test/ledger/Invariants_test.cpp +++ b/src/test/ledger/Invariants_test.cpp @@ -250,7 +250,7 @@ class Invariants_test : public beast::unit_test::suite auto const sle = ac.view().peek (keylet::account(A1.id())); if(! sle) return false; - STAmount nonNative {A2["USD"](51)}; + STAmount nonNative (A2["USD"](51)); sle->setFieldAmount (sfBalance, nonNative); ac.view().update (sle); return true; @@ -366,7 +366,7 @@ class Invariants_test : public beast::unit_test::suite return false; auto sleNew = std::make_shared ( keylet::escrow(A1, (*sle)[sfSequence] + 2)); - STAmount nonNative {A2["USD"](51)}; + STAmount nonNative (A2["USD"](51)); sleNew->setFieldAmount (sfAmount, nonNative); ac.view().insert (sleNew); return true; diff --git a/src/test/ledger/PaymentSandbox_test.cpp b/src/test/ledger/PaymentSandbox_test.cpp index 7cee87c662d..0ab0efef292 100644 --- a/src/test/ledger/PaymentSandbox_test.cpp +++ b/src/test/ledger/PaymentSandbox_test.cpp @@ -278,10 +278,10 @@ class PaymentSandbox_test : public beast::unit_test::suite STAmount hugeAmt (issue, STAmount::cMaxValue, STAmount::cMaxOffset - 1, false, false, STAmount::unchecked{}); - for (auto timeDelta : {-env.closed ()->info ().closeTimeResolution, - env.closed ()->info ().closeTimeResolution}) + for (auto d : {-1, 1}) { - auto const closeTime = fix1141Time () + timeDelta; + auto const closeTime = fix1141Time () + + d * env.closed()->info().closeTimeResolution; env.close (closeTime); ApplyViewImpl av (&*env.current (), tapNONE); PaymentSandbox pv (&av);