/*
 * Copyright (C) 2018 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

public class SimpleTests {
    public static class TestGuardSkips extends VarHandleUnitTest {
        public boolean checkGuard() {
            return false;
        }

        @Override
        protected void doTest() {
            throw new IllegalStateException("Not reachable");
        }

        public static void main(String[] args) {
            new TestGuardSkips().run();
        }
    }

    public static class TestEqualsOK extends VarHandleUnitTest {
        @Override
        protected void doTest() {
            assertEquals(true, true);
        }
    }

    public static class TestEqualsOK2 extends VarHandleUnitTest {
        @Override
        protected void doTest() {
            assertEquals(true, false);
        }
    }

    public static class TestExceptionsFail extends VarHandleUnitTest {
        @Override
        protected void doTest() {
            throw new NullPointerException();
        }
    }

    public static void main(String[] args) {
        new TestGuardSkips().run();
        new TestEqualsOK().run();
        new TestEqualsOK2().run();
        new TestExceptionsFail().run();
        VarHandleUnitTest.DEFAULT_COLLECTOR.printSummary();
    }
}
