From 0a3195180c883df3ac3a28c667c469a0f5c5788a Mon Sep 17 00:00:00 2001 From: Javen O'Neal Date: Fri, 20 Jan 2017 05:37:12 +0000 Subject: [PATCH] fix copy-paste typo in unit test found by Andrzej Witecki git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1779565 13f79535-47bb-0310-9956-ffa450edef68 --- src/testcases/org/apache/poi/POITestCase.java | 13 +++++++++++++ .../apache/poi/hssf/usermodel/TestHSSFSheet.java | 13 +++++-------- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/src/testcases/org/apache/poi/POITestCase.java b/src/testcases/org/apache/poi/POITestCase.java index a6cb26a901..55c7f99692 100644 --- a/src/testcases/org/apache/poi/POITestCase.java +++ b/src/testcases/org/apache/poi/POITestCase.java @@ -241,4 +241,17 @@ public final class POITestCase { public static void testPassesNow(int bug) { fail("This test passes now. Please update the unit test and bug " + bug + "."); } + + public static void assertBetween(String message, int value, int min, int max) { + assertTrue(message + ": " + value + " is less than minimum value of " + min, + min <= value); + assertTrue(message + ": " + value + " is greater than maximum value of " + max, + value <= max); + } + public static void assertStrictlyBetween(String message, int value, int min, int max) { + assertTrue(message + ": " + value + " is less or equal to than minimum value of " + min, + min < value); + assertTrue(message + ": " + value + " is greater or equal to than maximum value of " + max, + value < max); + } } diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFSheet.java b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFSheet.java index 65a5f21dbf..b2b8e5fabe 100644 --- a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFSheet.java +++ b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFSheet.java @@ -25,6 +25,7 @@ import static org.junit.Assert.assertNull; import static org.junit.Assert.assertSame; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; +import static org.apache.poi.POITestCase.assertBetween; import java.io.IOException; import java.util.List; @@ -704,10 +705,8 @@ public final class TestHSSFSheet extends BaseTestSheet { s.autoSizeColumn((short)1); // Size ranges due to different fonts on different machines - assertTrue("Single number column too small: " + s.getColumnWidth(0), s.getColumnWidth(0) > 350); - assertTrue("Single number column too big: " + s.getColumnWidth(0), s.getColumnWidth(0) < 550); - assertTrue("6 digit number column too small: " + s.getColumnWidth(1), s.getColumnWidth(1) > 1500); - assertTrue("6 digit number column too big: " + s.getColumnWidth(1), s.getColumnWidth(1) < 2000); + assertBetween("Single number column width", s.getColumnWidth(0), 350, 550); + assertBetween("6 digit number column width", s.getColumnWidth(1), 1500, 2000); // Set a date format HSSFCellStyle cs = wb.createCellStyle(); @@ -723,10 +722,8 @@ public final class TestHSSFSheet extends BaseTestSheet { s.autoSizeColumn((short)0); s.autoSizeColumn((short)1); - assertTrue("Date column too small: " + s.getColumnWidth(0), s.getColumnWidth(0) > 4750); - assertTrue("Date column too small: " + s.getColumnWidth(1), s.getColumnWidth(1) > 4750); - assertTrue("Date column too big: " + s.getColumnWidth(0), s.getColumnWidth(0) < 6500); - assertTrue("Date column too big: " + s.getColumnWidth(0), s.getColumnWidth(0) < 6500); + assertBetween("Date column width", s.getColumnWidth(0), 4750, 7000); + assertBetween("Date column width", s.getColumnWidth(1), 4750, 7000); wb.close(); } -- 2.39.5