From 5dfa37788c7f039eff00b27cc0ca8b9b9a71f60e Mon Sep 17 00:00:00 2001 From: Javier Date: Sat, 20 Mar 2021 23:57:51 +0100 Subject: Initial import --- .../com/javispedro/rempe/MainActivityTest.java | 40 ++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 app/src/test/java/com/javispedro/rempe/MainActivityTest.java (limited to 'app/src/test/java/com/javispedro') diff --git a/app/src/test/java/com/javispedro/rempe/MainActivityTest.java b/app/src/test/java/com/javispedro/rempe/MainActivityTest.java new file mode 100644 index 0000000..fe0f4c5 --- /dev/null +++ b/app/src/test/java/com/javispedro/rempe/MainActivityTest.java @@ -0,0 +1,40 @@ +package com.javispedro.rempe; + +import org.junit.Test; + +import java.util.ArrayList; +import java.util.Random; + +import static org.junit.Assert.assertEquals; + +public class MainActivityTest { + private final static String TAG = "MainActivityTest"; + + @Test + public void setDeviceNumberList() { + final MainActivity activity = new MainActivity(); + final Random r = new Random(); + + ArrayList list = new ArrayList(); + activity.setDeviceNumberList(list); + assertEquals(list, activity.getDeviceNumberList()); + + list.add(r.nextInt(30000)); + activity.setDeviceNumberList(list); + assertEquals(list, activity.getDeviceNumberList()); + + for (int i = 0; i < 400; ++i) { + list.add(r.nextInt(list.size()), r.nextInt(60000)); + activity.setDeviceNumberList(list); + assertEquals(list, activity.getDeviceNumberList()); + + list.add(r.nextInt(list.size()), r.nextInt(60000)); + activity.setDeviceNumberList(list); + assertEquals(list, activity.getDeviceNumberList()); + + list.remove(r.nextInt(list.size() - 1)); + activity.setDeviceNumberList(list); + assertEquals(list, activity.getDeviceNumberList()); + } + } +} \ No newline at end of file -- cgit v1.2.3