From cc3af67b57fd00d1e2e6dc6a09dfcd1f8f54019b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jan=20Stan=C4=9Bk?= <jstanek@redhat.com>
Date: Fri, 28 Jun 2019 10:50:07 +0200
Subject: [PATCH] Tweak tests for 32-bit architectures
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: Jan Staněk <jstanek@redhat.com>
---
 rust/strprintf/src/lib.rs |  2 ++
 test/strprintf.cpp        | 12 +++++++-----
 2 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/rust/strprintf/src/lib.rs b/rust/strprintf/src/lib.rs
index eb8c5d57..891e4574 100644
--- a/rust/strprintf/src/lib.rs
+++ b/rust/strprintf/src/lib.rs
@@ -154,6 +154,7 @@ mod tests {
     }

     #[test]
+    #[cfg(target_pointer_width = "64")]
     fn formats_i64() {
         assert_eq!(fmt!("%li", 42i64), "42");
         assert_eq!(fmt!("%li", std::i32::MIN as i64 - 1), "-2147483649");
@@ -165,6 +166,7 @@ mod tests {
     }

     #[test]
+    #[cfg(target_pointer_width = "64")]
     fn formats_u64() {
         assert_eq!(fmt!("%lu", 42u64), "42");
         assert_eq!(fmt!("%lu", 0u64), "0");
diff --git a/test/strprintf.cpp b/test/strprintf.cpp
index 2e57bdd2..5aee9b1e 100644
--- a/test/strprintf.cpp
+++ b/test/strprintf.cpp
@@ -1,5 +1,6 @@
 #include "strprintf.h"

+#include <climits>
 #include <limits>

 #include "3rd-party/catch.hpp"
@@ -130,17 +131,17 @@ TEST_CASE("strprintf::fmt() formats long int", "[strprintf]")
 {
	REQUIRE(strprintf::fmt("%li", 42l) == "42");

+#if LONG_MIN < INT_MIN
	const auto int_min = std::numeric_limits<int>::min();
-	const auto long_min = std::numeric_limits<long int>::min();
-	REQUIRE(long_min < int_min);
	REQUIRE(int_min == -2147483648);
	REQUIRE(strprintf::fmt("%li", int_min - 1l) == "-2147483649");
+#endif

+#if LONG_MAX > INT_MAX
	const auto int_max = std::numeric_limits<int>::max();
-	const auto long_max = std::numeric_limits<long int>::max();
-	REQUIRE(long_max > int_max);
	REQUIRE(int_max == 2147483647);
	REQUIRE(strprintf::fmt("%li", int_max + 1l) == "2147483648");
+#endif
 }

 TEST_CASE("strprintf::fmt() formats long unsigned int", "[strprintf]")
@@ -149,9 +150,10 @@ TEST_CASE("strprintf::fmt() formats long unsigned int", "[strprintf]")

	REQUIRE(strprintf::fmt("%lu", 0lu) == "0");

+#if ULONG_MAX == 18446744073709551615lu
	const auto ulong_max = std::numeric_limits<long unsigned int>::max();
-	REQUIRE(ulong_max == 18446744073709551615lu);
	REQUIRE(strprintf::fmt("%lu", ulong_max) == "18446744073709551615");
+#endif
 }

 TEST_CASE("strprintf::fmt() formats long long int", "[strprintf]")
--
2.21.0
