Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
PreconditionsTest.java
Go to the documentation of this file.
1// Copyright 2013 The Flutter Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5package io.flutter.util;
6
7import static org.junit.Assert.assertEquals;
8import static org.junit.Assert.assertThrows;
9
10import androidx.test.ext.junit.runners.AndroidJUnit4;
11import org.junit.Test;
12import org.junit.runner.RunWith;
13import org.robolectric.annotation.Config;
14
15@Config(manifest = Config.NONE)
16@RunWith(AndroidJUnit4.class)
17public class PreconditionsTest {
18 @Test
19 public void checkNotNull_notNull() {
20 // Should always return its input.
21 assertEquals("non-null", Preconditions.checkNotNull("non-null"));
22 assertEquals(42, (int) Preconditions.checkNotNull(42));
23 Object classParam = new Object();
24 assertEquals(classParam, Preconditions.checkNotNull(classParam));
25 }
26
27 @Test
28 public void checkNotNull_Null() {
29 assertThrows(
30 NullPointerException.class,
31 () -> {
32 Preconditions.checkNotNull(null);
33 });
34 }
35}
static< T > T checkNotNull(T reference)