From 9a9c9560e7259b85a8076ed9230c5df0b6bbb0ba Mon Sep 17 00:00:00 2001 From: Michael Keppler Date: Wed, 23 Apr 2014 11:04:48 +0200 Subject: rename test class --- .../cgeo/geocaching/LazyInitialilzedListTest.java | 76 ---------------------- .../cgeo/geocaching/LazyInitializedListTest.java | 76 ++++++++++++++++++++++ 2 files changed, 76 insertions(+), 76 deletions(-) delete mode 100644 tests/src/cgeo/geocaching/LazyInitialilzedListTest.java create mode 100644 tests/src/cgeo/geocaching/LazyInitializedListTest.java (limited to 'tests/src') diff --git a/tests/src/cgeo/geocaching/LazyInitialilzedListTest.java b/tests/src/cgeo/geocaching/LazyInitialilzedListTest.java deleted file mode 100644 index ec1f593..0000000 --- a/tests/src/cgeo/geocaching/LazyInitialilzedListTest.java +++ /dev/null @@ -1,76 +0,0 @@ -package cgeo.geocaching; - -import static org.assertj.core.api.Assertions.assertThat; - -import cgeo.geocaching.utils.LazyInitializedList; - -import android.test.AndroidTestCase; - -import java.util.LinkedList; -import java.util.List; - -public class LazyInitialilzedListTest extends AndroidTestCase { - - private static final int MAKE_NULL = -1; - private static final int MAKE_EXCEPTION = -2; - - private static class MyList extends LazyInitializedList { - - private int counter; - - MyList(int counter) { - this.counter = counter; - } - - @Override - public List call() { - if (counter == MAKE_NULL) { - return null; - } - if (counter == MAKE_EXCEPTION) { - throw new RuntimeException("exception in call()"); - } - final List result = new LinkedList(); - for (int i = 0; i < counter; i++) { - result.add(counter); - } - counter += 1; - return result; - } - - int getCounter() { - return counter; - } - - } - - public static void testCallOnce() { - final MyList list = new MyList(0); - assertThat(list.getCounter()).overridingErrorMessage("call() must not be called prematurely").isEqualTo(0); - list.size(); - assertThat(list.getCounter()).overridingErrorMessage("call() must be called when needed").isEqualTo(1); - list.size(); - assertThat(list.getCounter()).overridingErrorMessage("call() must be called only once").isEqualTo(1); - } - - public static void testSize() { - final MyList list = new MyList(3); - assertThat(list).overridingErrorMessage("completed size must be identical to call() result").hasSize(3); - } - - public static void testValue() { - final MyList list = new MyList(1); - assertThat(list.get(0)).overridingErrorMessage("value must be identical to call() result").isEqualTo(1); - } - - public static void testNull() { - final MyList list = new MyList(MAKE_NULL); - assertThat(list).overridingErrorMessage("null returned by call() must create an empty list").isEmpty(); - } - - public static void testException() { - final MyList list = new MyList(MAKE_EXCEPTION); - assertThat(list).overridingErrorMessage("exception in call() must create an empty list").isEmpty(); - } - -} diff --git a/tests/src/cgeo/geocaching/LazyInitializedListTest.java b/tests/src/cgeo/geocaching/LazyInitializedListTest.java new file mode 100644 index 0000000..ca96b42 --- /dev/null +++ b/tests/src/cgeo/geocaching/LazyInitializedListTest.java @@ -0,0 +1,76 @@ +package cgeo.geocaching; + +import static org.assertj.core.api.Assertions.assertThat; + +import cgeo.geocaching.utils.LazyInitializedList; + +import android.test.AndroidTestCase; + +import java.util.LinkedList; +import java.util.List; + +public class LazyInitializedListTest extends AndroidTestCase { + + private static final int MAKE_NULL = -1; + private static final int MAKE_EXCEPTION = -2; + + private static class MyList extends LazyInitializedList { + + private int counter; + + MyList(int counter) { + this.counter = counter; + } + + @Override + public List call() { + if (counter == MAKE_NULL) { + return null; + } + if (counter == MAKE_EXCEPTION) { + throw new RuntimeException("exception in call()"); + } + final List result = new LinkedList(); + for (int i = 0; i < counter; i++) { + result.add(counter); + } + counter += 1; + return result; + } + + int getCounter() { + return counter; + } + + } + + public static void testCallOnce() { + final MyList list = new MyList(0); + assertThat(list.getCounter()).overridingErrorMessage("call() must not be called prematurely").isEqualTo(0); + list.size(); + assertThat(list.getCounter()).overridingErrorMessage("call() must be called when needed").isEqualTo(1); + list.size(); + assertThat(list.getCounter()).overridingErrorMessage("call() must be called only once").isEqualTo(1); + } + + public static void testSize() { + final MyList list = new MyList(3); + assertThat(list).overridingErrorMessage("completed size must be identical to call() result").hasSize(3); + } + + public static void testValue() { + final MyList list = new MyList(1); + assertThat(list.get(0)).overridingErrorMessage("value must be identical to call() result").isEqualTo(1); + } + + public static void testNull() { + final MyList list = new MyList(MAKE_NULL); + assertThat(list).overridingErrorMessage("null returned by call() must create an empty list").isEmpty(); + } + + public static void testException() { + final MyList list = new MyList(MAKE_EXCEPTION); + assertThat(list).overridingErrorMessage("exception in call() must create an empty list").isEmpty(); + } + +} -- cgit v1.1