blob: 9d1a09af909165f29665b66bc595563562709abb [file] [log] [blame]
Jake Wharton801cb3e2019-12-12 23:35:29 -05001// Copyright (c) 2019, the R8 project authors. Please see the AUTHORS file
2// for details. All rights reserved. Use of this source code is governed by a
3// BSD-style license that can be found in the LICENSE file.
4
5package backport;
6
7import java.util.OptionalInt;
8
9public final class OptionalIntBackportJava11Main {
10
11 public static void main(String[] args) {
12 testIsEmpty();
13 }
14
15 private static void testIsEmpty() {
16 OptionalInt present = OptionalInt.of(2);
17 assertFalse(present.isEmpty());
18
19 OptionalInt absent = OptionalInt.empty();
20 assertTrue(absent.isEmpty());
21 }
22
23 private static void assertTrue(boolean value) {
24 if (!value) {
25 throw new AssertionError("Expected <true> but was <false>");
26 }
27 }
28
29 private static void assertFalse(boolean value) {
30 if (value) {
31 throw new AssertionError("Expected <false> but was <true>");
32 }
33 }
34}