summaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorAlessandro Iezzi <aiezzi@alessandroiezzi.it>2022-11-30 16:10:25 +0100
committerAlessandro Iezzi <aiezzi@alessandroiezzi.it>2022-11-30 16:10:25 +0100
commit46bed7c28a5df7add8f52730d87712bde13e29c5 (patch)
tree151383db4c3b4e23e08027c6ea5af1082511e1d0 /src/test
parent3ceced8cb403d616444afc44717675f251d9c59e (diff)
downloadcommons-page-46bed7c28a5df7add8f52730d87712bde13e29c5.tar.gz
commons-page-46bed7c28a5df7add8f52730d87712bde13e29c5.zip
Add whole directory
Diffstat (limited to 'src/test')
-rw-r--r--src/test/java/it/alessandroiezzi/commons/page/ExampleUnitTest.java36
-rw-r--r--src/test/java/it/alessandroiezzi/commons/page/PageAdapterUnitTest.java61
2 files changed, 97 insertions, 0 deletions
diff --git a/src/test/java/it/alessandroiezzi/commons/page/ExampleUnitTest.java b/src/test/java/it/alessandroiezzi/commons/page/ExampleUnitTest.java
new file mode 100644
index 0000000..ae6692d
--- /dev/null
+++ b/src/test/java/it/alessandroiezzi/commons/page/ExampleUnitTest.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2022 Alessandro Iezzi <aiezzi AT alessandroiezzi PERIOD it>
+ *
+ * This file is part of commons-page.
+ *
+ * commons-page is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * commons-page is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with commons-page. If not, see <https://www.gnu.org/licenses/>.
+ */
+
+package it.alessandroiezzi.commons.page;
+
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+/**
+ * Example local unit test, which will execute on the development machine (host).
+ *
+ * @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
+ */
+public class ExampleUnitTest {
+ @Test
+ public void addition_isCorrect() {
+ assertEquals(4, 2 + 2);
+ }
+} \ No newline at end of file
diff --git a/src/test/java/it/alessandroiezzi/commons/page/PageAdapterUnitTest.java b/src/test/java/it/alessandroiezzi/commons/page/PageAdapterUnitTest.java
new file mode 100644
index 0000000..65b880d
--- /dev/null
+++ b/src/test/java/it/alessandroiezzi/commons/page/PageAdapterUnitTest.java
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2022 Alessandro Iezzi <aiezzi AT alessandroiezzi PERIOD it>
+ *
+ * This file is part of commons-page.
+ *
+ * commons-page is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * commons-page is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with commons-page. If not, see <https://www.gnu.org/licenses/>.
+ */
+
+package it.alessandroiezzi.commons.page;
+
+import org.junit.*;
+
+import java.util.*;
+
+import static org.junit.Assert.*;
+
+public class PageAdapterUnitTest {
+ @Test
+ public void test() {
+ int max = 48;
+ List<Integer> integers = new ArrayList<>();
+ for (int i = 1; i < max; i++) {
+ integers.add(i);
+ }
+ Pages<Integer> pages = new PageAdapter<>(integers);
+ assertEquals(4, pages.getTotalPages());
+
+ int i = 0;
+ for (Integer integer : pages.firstPage().getContent()) {
+ assertEquals(++i, (int) integer);
+ }
+ assertEquals(i, 15);
+
+ for (Integer integer : pages.lastPage().getContent()) {
+// System.out.println(integer);
+ }
+
+ for (int j = max; j < max + 13; j++) {
+ pages.addElement(j);
+ }
+ pages.removeElementIf((e) -> e > 0 && e < 58);
+ for (Integer integer : pages.lastPage().getContent()) {
+ System.out.println(integer);
+ }
+ System.out.println();
+ for (Integer integer : pages.firstPage().getContent()) {
+ System.out.println(integer);
+ }
+ }
+} \ No newline at end of file