forked from mockito/mockito
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve Varargs handling in AdditionalAnswers
Fixes: mockito#2644 Fixes issues around vararg handling for the following methods in `AdditionalAnswers`: * `returnsFirstArg` * `returnsSecondArg` * `returnsLastArg` * `returnsArgAt` * `answer` * `answerVoid` These methods were not correctly handling varargs. For example, ```java doAnswer(answerVoid( (VoidAnswer2<String, Object[]>) logger::info )).when(mock) .info(any(), (Object[]) any()); mock.info("Some message with {} {} {}", "three", "parameters", ""); ``` Would previously have resulted in a `ClassCastException` being thrown from the `mock.info` call. This was because the `answerVoid` method was not taking into account that the second parameter was a varargs parameter and was attempting to pass the second actual argument `"three"`, rather than the second _raw_ argument `["three", "parameters", ""]`.
- Loading branch information
1 parent
1fbef57
commit 459efad
Showing
5 changed files
with
535 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.