From 19ad58708fcf8cd2282f3a11eb33e956d96a0845 Mon Sep 17 00:00:00 2001 From: Atul Agrawal Date: Sun, 25 Nov 2018 16:03:34 +0800 Subject: [PATCH] Added Not Equals method for comparing float and dobule arrays - Fixes 1957 --- CHANGES.txt | 1 + src/main/java/org/testng/Assert.java | 72 ++++++++++++++++++++++++++++ 2 files changed, 73 insertions(+) diff --git a/CHANGES.txt b/CHANGES.txt index 14c7928aa4..bda4b17582 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,4 +1,5 @@ Current +Fixed: GITHUB-1957: Added NotEquals methods for comparing float and double arrays with and without delta (Atul Agrawal) Fixed: GITHUB-1952: Provide a TestNGListener that can be invoked when a test fails due to a timeout (Krishnan Mahadevan) Fixed: GITHUB-1953: TestNG throws a misleading error when @Factory method returns empty array. (Krishnan Mahadevan) Fixed: GITHUB-1946: Retry analyzer does not work properly when coupled with a data provider (Krishnan Mahadevan) diff --git a/src/main/java/org/testng/Assert.java b/src/main/java/org/testng/Assert.java index 720e16be83..3ed31bca04 100644 --- a/src/main/java/org/testng/Assert.java +++ b/src/main/java/org/testng/Assert.java @@ -1497,6 +1497,78 @@ public static void assertNotEquals(Set actual, Set expected, String messag } } + public static void assertNotEquals(float[] actual, float[] expected, String message) { + boolean fail; + try { + Assert.assertEquals(actual, expected, message); + fail = true; + } catch (AssertionError e) { + fail = false; + } + + if (fail) { + Assert.fail(message); + } + } + + public static void assertNotEquals(float[] actual, float[] expected) { + assertNotEquals(actual, expected, ""); + } + + public static void assertNotEquals(float[] actual, float[] expected, float delta, String message) { + boolean fail; + try { + Assert.assertEquals(actual, expected, delta, message); + fail = true; + } catch (AssertionError e) { + fail = false; + } + + if (fail) { + Assert.fail(message); + } + } + + public static void assertNotEquals(float[] actual, float[] expected, float delta) { + assertNotEquals(actual, expected, delta,""); + } + + public static void assertNotEquals(double[] actual, double[] expected, String message) { + boolean fail; + try { + Assert.assertEquals(actual, expected, message); + fail = true; + } catch (AssertionError e) { + fail = false; + } + + if (fail) { + Assert.fail(message); + } + } + + public static void assertNotEquals(double[] actual, double[] expected) { + assertNotEquals(actual, expected, ""); + } + + public static void assertNotEquals(double[] actual, double[] expected, double delta, String message) { + boolean fail; + try { + Assert.assertEquals(actual, expected, delta, message); + fail = true; + } catch (AssertionError e) { + fail = false; + } + + if (fail) { + Assert.fail(message); + } + } + + public static void assertNotEquals(double[] actual, double[] expected, double delta) { + assertNotEquals(actual, expected, delta, ""); + } + public static void assertNotEqualsDeep(Set actual, Set expected) { assertNotEqualsDeep(actual, expected, null); }