mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-25 11:20:47 +01:00
committed by
Greyson Parrelli
parent
cf24b22de9
commit
040d05a0a6
@@ -1,14 +1,13 @@
|
||||
package org.thoughtcrime.securesms.util;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.thoughtcrime.securesms.BaseUnitTest;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class ListPartitionTest extends BaseUnitTest {
|
||||
public class ListPartitionTest {
|
||||
|
||||
@Test public void testPartitionEven() {
|
||||
List<Integer> list = new LinkedList<>();
|
||||
@@ -19,16 +18,16 @@ public class ListPartitionTest extends BaseUnitTest {
|
||||
|
||||
List<List<Integer>> partitions = Util.partition(list, 10);
|
||||
|
||||
assertEquals(partitions.size(), 10);
|
||||
assertEquals(10, partitions.size());
|
||||
|
||||
int counter = 0;
|
||||
|
||||
for (int i=0;i<partitions.size();i++) {
|
||||
List<Integer> partition = partitions.get(i);
|
||||
assertEquals(partition.size(), 10);
|
||||
assertEquals(10, partition.size());
|
||||
|
||||
for (int j=0;j<partition.size();j++) {
|
||||
assertEquals((int)partition.get(j), counter++);
|
||||
assertEquals(counter++, (int)partition.get(j));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -44,21 +43,21 @@ public class ListPartitionTest extends BaseUnitTest {
|
||||
|
||||
List<List<Integer>> partitions = Util.partition(list, 10);
|
||||
|
||||
assertEquals(partitions.size(), 11);
|
||||
assertEquals(11, partitions.size());
|
||||
|
||||
int counter = 0;
|
||||
|
||||
for (int i=0;i<partitions.size()-1;i++) {
|
||||
List<Integer> partition = partitions.get(i);
|
||||
assertEquals(partition.size(), 10);
|
||||
assertEquals(10, partition.size());
|
||||
|
||||
for (int j=0;j<partition.size();j++) {
|
||||
assertEquals((int)partition.get(j), counter++);
|
||||
assertEquals(counter++, (int)partition.get(j));
|
||||
}
|
||||
}
|
||||
|
||||
assertEquals(partitions.get(10).size(), 1);
|
||||
assertEquals((int)partitions.get(10).get(0), 100);
|
||||
assertEquals(1, partitions.get(10).size());
|
||||
assertEquals(100, (int)partitions.get(10).get(0));
|
||||
}
|
||||
|
||||
@Test public void testPathological() {
|
||||
@@ -70,16 +69,16 @@ public class ListPartitionTest extends BaseUnitTest {
|
||||
|
||||
List<List<Integer>> partitions = Util.partition(list, 1);
|
||||
|
||||
assertEquals(partitions.size(), 100);
|
||||
assertEquals(100, partitions.size());
|
||||
|
||||
int counter = 0;
|
||||
|
||||
for (int i=0;i<partitions.size();i++) {
|
||||
List<Integer> partition = partitions.get(i);
|
||||
assertEquals(partition.size(), 1);
|
||||
assertEquals(1, partition.size());
|
||||
|
||||
for (int j=0;j<partition.size();j++) {
|
||||
assertEquals((int)partition.get(j), counter++);
|
||||
assertEquals(counter++, (int)partition.get(j));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,22 +1,20 @@
|
||||
package org.thoughtcrime.securesms.util;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.thoughtcrime.securesms.BaseUnitTest;
|
||||
import org.thoughtcrime.securesms.util.RemoteConfig.ConfigChange;
|
||||
import org.thoughtcrime.securesms.util.RemoteConfig.UpdateResult;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.thoughtcrime.securesms.testutil.TestHelpers.mapOf;
|
||||
import static org.thoughtcrime.securesms.testutil.TestHelpers.setOf;
|
||||
|
||||
public class RemoteConfigTest extends BaseUnitTest {
|
||||
public class RemoteConfigTest {
|
||||
|
||||
private static final String A = "A";
|
||||
private static final String B = "B";
|
||||
@@ -376,6 +374,7 @@ public class RemoteConfigTest extends BaseUnitTest {
|
||||
assertTrue(result.getMemoryChanges().isEmpty());
|
||||
}
|
||||
|
||||
/** @noinspection StringOperationCanBeSimplified*/
|
||||
@Test
|
||||
public void computeChanges_generic() {
|
||||
Map<String, Object> oldMap = new HashMap<>() {{
|
||||
@@ -412,8 +411,4 @@ public class RemoteConfigTest extends BaseUnitTest {
|
||||
assertFalse(changes.containsKey("i"));
|
||||
assertEquals(new ConfigChange("gwen", "stacy"), changes.get("j"));
|
||||
}
|
||||
|
||||
private static <V> Set<V> setOf(V... values) {
|
||||
return new HashSet<>(Arrays.asList(values));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,14 +18,13 @@
|
||||
package org.thoughtcrime.securesms.util;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.thoughtcrime.securesms.BaseUnitTest;
|
||||
|
||||
import java.net.URISyntaxException;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertThrows;
|
||||
|
||||
public class Rfc5724UriTest extends BaseUnitTest {
|
||||
public class Rfc5724UriTest {
|
||||
|
||||
@Test public void testInvalidPath() {
|
||||
final String[] invalidSchemaUris = {
|
||||
|
||||
Reference in New Issue
Block a user