Skip to content

Commit

Permalink
Add test for boolean contract with extra message argument (#945)
Browse files Browse the repository at this point in the history
This just tests an additional scenario; no logic changes.
  • Loading branch information
msridhar authored Mar 26, 2024
1 parent 83e0149 commit ce892d7
Showing 1 changed file with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ public void nonNullCheckIsTrueIsNotNullable() {
" Validation.checkTrue(o1 != null);",
" return o1.toString();",
" }",
" String test1WithMsg(@Nullable Object o1) {",
" Validation.checkTrue(o1 != null, \"o1 should not be null!\");",
" return o1.toString();",
" }",
" String test2(Map<String, String> map) {",
" Validation.checkTrue(map.get(\"key\") != null);",
" return map.get(\"key\").toString();",
Expand Down Expand Up @@ -553,6 +557,10 @@ private CompilationTestHelper helper() {
" static void checkTrue(boolean value) {",
" if (!value) throw new RuntimeException();",
" }",
" @Contract(\"false, _ -> fail\")",
" static void checkTrue(boolean value, String msg) {",
" if (!value) throw new RuntimeException(msg);",
" }",
" @Contract(\"true -> fail\")",
" static void checkFalse(boolean value) {",
" if (value) throw new RuntimeException();",
Expand Down

0 comments on commit ce892d7

Please sign in to comment.