Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Not Equals method for comparing float and dobule arrays - Fixes #1957 #1961

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
72 changes: 72 additions & 0 deletions src/main/java/org/testng/Assert.java
Original file line number Diff line number Diff line change
Expand Up @@ -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,"");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: a space is missing after ','

}

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);
}
Expand Down