| 20 | } |
| 21 | } |
| 22 | public static void main(String[] args) { |
| 23 | test(s -> s = checkNotNull(s), "X"); |
| 24 | test(s -> s = checkNotNull(s), null); |
| 25 | test(s -> s = checkNotNull(s, "s was null"), null); |
| 26 | test(s -> s = checkNotNull( |
| 27 | s, "s was null, %s %s", "arg2", "arg3"), null); |
| 28 | |
| 29 | test(s -> checkArgument(s == "Fozzie"), "Fozzie"); |
| 30 | test(s -> checkArgument(s == "Fozzie"), "X"); |
| 31 | test(s -> checkArgument(s == "Fozzie"), null); |
| 32 | test(s -> checkArgument( |
| 33 | s == "Fozzie", "Bear Left!"), null); |
| 34 | test(s -> checkArgument( |
| 35 | s == "Fozzie", "Bear Left! %s Right!", "Frog"), |
| 36 | null); |
| 37 | |
| 38 | test(s -> checkState(s.length() > 6), "Mortimer"); |
| 39 | test(s -> checkState(s.length() > 6), "Mort"); |
| 40 | test(s -> checkState(s.length() > 6), null); |
| 41 | |
| 42 | test(s -> |
| 43 | checkElementIndex(6, s.length()), "Robert"); |
| 44 | test(s -> |
| 45 | checkElementIndex(6, s.length()), "Bob"); |
| 46 | test(s -> |
| 47 | checkElementIndex(6, s.length()), null); |
| 48 | |
| 49 | test(s -> |
| 50 | checkPositionIndex(6, s.length()), "Robert"); |
| 51 | test(s -> |
| 52 | checkPositionIndex(6, s.length()), "Bob"); |
| 53 | test(s -> |
| 54 | checkPositionIndex(6, s.length()), null); |
| 55 | |
| 56 | test(s -> checkPositionIndexes( |
| 57 | 0, 6, s.length()), "Hieronymus"); |
| 58 | test(s -> checkPositionIndexes( |
| 59 | 0, 10, s.length()), "Hieronymus"); |
| 60 | test(s -> checkPositionIndexes( |
| 61 | 0, 11, s.length()), "Hieronymus"); |
| 62 | test(s -> checkPositionIndexes( |
| 63 | -1, 6, s.length()), "Hieronymus"); |
| 64 | test(s -> checkPositionIndexes( |
| 65 | 7, 6, s.length()), "Hieronymus"); |
| 66 | test(s -> checkPositionIndexes( |
| 67 | 0, 6, s.length()), null); |
| 68 | } |
| 69 | } |
| 70 | /* Output: |
| 71 | X |