From e885ebdbbb8718dc0ebeebb97421af8edc785718 Mon Sep 17 00:00:00 2001 From: Alexey Andreev Date: Tue, 10 Oct 2017 23:59:55 +0300 Subject: [PATCH] Move tests from TArrayDequeTests to proper location --- .../classlib/java/util/TArrayDequeTest.java | 127 ------------------ .../classlib/java/util/ArrayDequeTest.java | 107 +++++++++++++++ 2 files changed, 107 insertions(+), 127 deletions(-) delete mode 100644 classlib/src/test/java/org/teavm/classlib/java/util/TArrayDequeTest.java diff --git a/classlib/src/test/java/org/teavm/classlib/java/util/TArrayDequeTest.java b/classlib/src/test/java/org/teavm/classlib/java/util/TArrayDequeTest.java deleted file mode 100644 index 2c6bc5b99..000000000 --- a/classlib/src/test/java/org/teavm/classlib/java/util/TArrayDequeTest.java +++ /dev/null @@ -1,127 +0,0 @@ -/* - * Copyright 2017 Adam Ryan. - * - * 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. - */ -package org.teavm.classlib.java.util; - -import org.junit.Assert; -import org.junit.Test; - -public class TArrayDequeTest { - @Test - public void eachRemovedObjectShouldReduceTheSizeByOne() { - TArrayDeque arrayDeque = new TArrayDeque<>(); - Object object1 = new Object(); - Object object2 = new Object(); - Object object3 = new Object(); - arrayDeque.add(object1); - Assert.assertTrue(arrayDeque.size() == 1); - arrayDeque.remove(object1); - Assert.assertTrue(arrayDeque.size() == 0); - arrayDeque.add(object1); - arrayDeque.add(object2); - arrayDeque.add(object3); - Assert.assertTrue(arrayDeque.size() == 3); - arrayDeque.remove(object1); - arrayDeque.remove(object2); - arrayDeque.remove(object3); - Assert.assertTrue(arrayDeque.size() == 0); - arrayDeque.remove(object1); - Assert.assertTrue(arrayDeque.size() == 0); - } - - @Test - public void removeFirstShouldNotContainTheFirstAddedObject() { - TArrayDeque arrayDeque1 = new TArrayDeque<>(); - Object object1 = new Object(); - Object object2 = new Object(); - Object object3 = new Object(); - arrayDeque1.add(object1); - arrayDeque1.add(object2); - arrayDeque1.add(object3); - arrayDeque1.removeFirst(); - Assert.assertTrue(arrayDeque1.size() == 2); - Assert.assertTrue(arrayDeque1.contains(object2)); - Assert.assertTrue(arrayDeque1.contains(object3)); - - TArrayDeque arrayDeque2 = new TArrayDeque<>(); - arrayDeque2.add(object1); - arrayDeque2.add(object2); - arrayDeque2.add(object3); - arrayDeque2.remove(object1); - arrayDeque2.removeFirst(); - Assert.assertTrue(arrayDeque2.size() == 1); - Assert.assertTrue(arrayDeque2.contains(object3)); - - TArrayDeque arrayDeque3 = new TArrayDeque<>(); - arrayDeque3.add(object1); - arrayDeque3.add(object2); - arrayDeque3.add(object3); - arrayDeque3.remove(object2); - arrayDeque3.removeFirst(); - Assert.assertTrue(arrayDeque3.size() == 1); - Assert.assertTrue(arrayDeque3.contains(object3)); - - TArrayDeque arrayDeque4 = new TArrayDeque<>(); - arrayDeque4.add(object1); - arrayDeque4.add(object2); - arrayDeque4.add(object3); - arrayDeque4.remove(object3); - arrayDeque4.removeFirst(); - Assert.assertTrue(arrayDeque4.size() == 1); - Assert.assertTrue(arrayDeque4.contains(object2)); - } - - @Test - public void removeLastShouldNotContainTheLastAddedObject() { - TArrayDeque arrayDeque1 = new TArrayDeque<>(); - Object object1 = new Object(); - Object object2 = new Object(); - Object object3 = new Object(); - arrayDeque1.add(object1); - arrayDeque1.add(object2); - arrayDeque1.add(object3); - arrayDeque1.removeLast(); - Assert.assertTrue(arrayDeque1.size() == 2); - Assert.assertTrue(arrayDeque1.contains(object1)); - Assert.assertTrue(arrayDeque1.contains(object2)); - - TArrayDeque arrayDeque2 = new TArrayDeque<>(); - arrayDeque2.add(object1); - arrayDeque2.add(object2); - arrayDeque2.add(object3); - arrayDeque2.remove(object3); - arrayDeque2.removeLast(); - Assert.assertTrue(arrayDeque2.size() == 1); - Assert.assertTrue(arrayDeque2.contains(object1)); - - TArrayDeque arrayDeque3 = new TArrayDeque<>(); - arrayDeque3.add(object1); - arrayDeque3.add(object2); - arrayDeque3.add(object3); - arrayDeque3.remove(object2); - arrayDeque3.removeLast(); - Assert.assertTrue(arrayDeque3.size() == 1); - Assert.assertTrue(arrayDeque3.contains(object1)); - - TArrayDeque arrayDeque4 = new TArrayDeque<>(); - arrayDeque4.add(object1); - arrayDeque4.add(object2); - arrayDeque4.add(object3); - arrayDeque4.remove(object3); - arrayDeque4.removeLast(); - Assert.assertTrue(arrayDeque4.size() == 1); - Assert.assertTrue(arrayDeque4.contains(object1)); - } -} \ No newline at end of file diff --git a/tests/src/test/java/org/teavm/classlib/java/util/ArrayDequeTest.java b/tests/src/test/java/org/teavm/classlib/java/util/ArrayDequeTest.java index e40d95430..e4b111622 100644 --- a/tests/src/test/java/org/teavm/classlib/java/util/ArrayDequeTest.java +++ b/tests/src/test/java/org/teavm/classlib/java/util/ArrayDequeTest.java @@ -20,6 +20,7 @@ import static org.junit.Assert.assertFalse; import java.util.ArrayDeque; import java.util.Deque; import java.util.Iterator; +import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; import org.teavm.junit.TeaVMTestRunner; @@ -128,4 +129,110 @@ public class ArrayDequeTest { } assertEquals((Integer) 70, deque.removeLast()); } + + @Test + public void eachRemovedObjectShouldReduceTheSizeByOne() { + TArrayDeque arrayDeque = new TArrayDeque<>(); + Object object1 = new Object(); + Object object2 = new Object(); + Object object3 = new Object(); + arrayDeque.add(object1); + Assert.assertTrue(arrayDeque.size() == 1); + arrayDeque.remove(object1); + Assert.assertTrue(arrayDeque.size() == 0); + arrayDeque.add(object1); + arrayDeque.add(object2); + arrayDeque.add(object3); + Assert.assertTrue(arrayDeque.size() == 3); + arrayDeque.remove(object1); + arrayDeque.remove(object2); + arrayDeque.remove(object3); + Assert.assertTrue(arrayDeque.size() == 0); + arrayDeque.remove(object1); + Assert.assertTrue(arrayDeque.size() == 0); + } + + @Test + public void removeFirstShouldNotContainTheFirstAddedObject() { + TArrayDeque arrayDeque1 = new TArrayDeque<>(); + Object object1 = new Object(); + Object object2 = new Object(); + Object object3 = new Object(); + arrayDeque1.add(object1); + arrayDeque1.add(object2); + arrayDeque1.add(object3); + arrayDeque1.removeFirst(); + Assert.assertTrue(arrayDeque1.size() == 2); + Assert.assertTrue(arrayDeque1.contains(object2)); + Assert.assertTrue(arrayDeque1.contains(object3)); + + TArrayDeque arrayDeque2 = new TArrayDeque<>(); + arrayDeque2.add(object1); + arrayDeque2.add(object2); + arrayDeque2.add(object3); + arrayDeque2.remove(object1); + arrayDeque2.removeFirst(); + Assert.assertTrue(arrayDeque2.size() == 1); + Assert.assertTrue(arrayDeque2.contains(object3)); + + TArrayDeque arrayDeque3 = new TArrayDeque<>(); + arrayDeque3.add(object1); + arrayDeque3.add(object2); + arrayDeque3.add(object3); + arrayDeque3.remove(object2); + arrayDeque3.removeFirst(); + Assert.assertTrue(arrayDeque3.size() == 1); + Assert.assertTrue(arrayDeque3.contains(object3)); + + TArrayDeque arrayDeque4 = new TArrayDeque<>(); + arrayDeque4.add(object1); + arrayDeque4.add(object2); + arrayDeque4.add(object3); + arrayDeque4.remove(object3); + arrayDeque4.removeFirst(); + Assert.assertTrue(arrayDeque4.size() == 1); + Assert.assertTrue(arrayDeque4.contains(object2)); + } + + @Test + public void removeLastShouldNotContainTheLastAddedObject() { + TArrayDeque arrayDeque1 = new TArrayDeque<>(); + Object object1 = new Object(); + Object object2 = new Object(); + Object object3 = new Object(); + arrayDeque1.add(object1); + arrayDeque1.add(object2); + arrayDeque1.add(object3); + arrayDeque1.removeLast(); + Assert.assertTrue(arrayDeque1.size() == 2); + Assert.assertTrue(arrayDeque1.contains(object1)); + Assert.assertTrue(arrayDeque1.contains(object2)); + + TArrayDeque arrayDeque2 = new TArrayDeque<>(); + arrayDeque2.add(object1); + arrayDeque2.add(object2); + arrayDeque2.add(object3); + arrayDeque2.remove(object3); + arrayDeque2.removeLast(); + Assert.assertTrue(arrayDeque2.size() == 1); + Assert.assertTrue(arrayDeque2.contains(object1)); + + TArrayDeque arrayDeque3 = new TArrayDeque<>(); + arrayDeque3.add(object1); + arrayDeque3.add(object2); + arrayDeque3.add(object3); + arrayDeque3.remove(object2); + arrayDeque3.removeLast(); + Assert.assertTrue(arrayDeque3.size() == 1); + Assert.assertTrue(arrayDeque3.contains(object1)); + + TArrayDeque arrayDeque4 = new TArrayDeque<>(); + arrayDeque4.add(object1); + arrayDeque4.add(object2); + arrayDeque4.add(object3); + arrayDeque4.remove(object3); + arrayDeque4.removeLast(); + Assert.assertTrue(arrayDeque4.size() == 1); + Assert.assertTrue(arrayDeque4.contains(object1)); + } }