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

Introduce missing assertEquals(long, Long, String) overload #3199

Merged
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
12 changes: 12 additions & 0 deletions testng-asserts/src/main/java/org/testng/Assert.java
Original file line number Diff line number Diff line change
Expand Up @@ -968,6 +968,18 @@ public static void assertEquals(Long actual, long expected, String message) {
assertEquals(actual, Long.valueOf(expected), message);
}

/**
* Asserts that two longs are equal. If they are not, an AssertionError, with the given message,
* is thrown.
*
* @param actual the actual value
* @param expected the expected value
* @param message the assertion error message
*/
public static void assertEquals(long actual, Long expected, String message) {
assertEquals(Long.valueOf(actual), expected, message);
}

/**
* Asserts that two longs are equal. If they are not, an AssertionError, with the given message,
* is thrown.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public void assertEqualsBoxedUnboxedLong() {
assertEquals(a, b);
assertEquals(a, b, "");
assertEquals(b, a);
assertEquals(b, a, "");
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Without the added method, this statement causes a compilation failure:

Execution failed for task ':testng-asserts:compileTestJava'.
> Compilation failed; see the compiler output below.
  /tmp/testng/testng-asserts/src/test/java/test/asserttests/AssertTest.java:54: error: reference to assertEquals is ambiguous
      assertEquals(b, a, "");
      ^
    both method assertEquals(double,double,String) in Assert and method assertEquals(Object,Object,String) in Assert match
  1 error

assertEquals(Long.valueOf(b), a, "");
}

Expand Down
Loading