Skip to content

Commit ac04844

Browse files
committed
make test class public.
1 parent cea334d commit ac04844

File tree

2 files changed

+33
-3
lines changed

2 files changed

+33
-3
lines changed

src/net/sharksystem/utils/Utils.java

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import java.util.ArrayList;
77
import java.util.Collection;
88
import java.util.HashSet;
9+
import java.util.Iterator;
910

1011
public class Utils {
1112
public static String url2FileName(String url) {
@@ -84,6 +85,35 @@ public static Collection<Integer> getErasInRange(Collection<Integer> searchSpace
8485

8586
}
8687

88+
/**
89+
* Return true if both collections contain same number of elements and for each element in a there is an
90+
* identical element in b (String.compareTo())
91+
* in a has the "same"
92+
* @param a
93+
* @param b
94+
* @return
95+
*/
96+
public static boolean sameContent(Collection<CharSequence> a, Collection<CharSequence> b) {
97+
if(a == null && b == null) return true;
98+
if(a == null) return false; // b is not null
99+
if(b == null) return false; // a is not null
100+
// bot not null
101+
if(a.size() != b.size()) return false;
102+
103+
for(CharSequence aElement : a) {
104+
String aString = aElement.toString();
105+
boolean found = false;
106+
Iterator<CharSequence> bIterator = b.iterator();
107+
while(bIterator.hasNext() && !found) {
108+
String bString = bIterator.next().toString();
109+
if(bString.compareTo(aString) == 0) found = true;
110+
}
111+
if(!found) return false;
112+
}
113+
114+
return true;
115+
}
116+
87117
public static boolean compareArrays(byte[] a, byte[] b) {
88118
if(a.length != b.length) {
89119
System.out.println("not same length");

test/net/sharksystem/asap/mockAndTemplates/TestUtils.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import java.io.*;
44

5-
class TestUtils {
5+
public class TestUtils {
66
static final CharSequence ALICE = "Alice";
77
static final CharSequence BOB = "Bob";
88
static final CharSequence YOUR_APP_NAME = "yourAppName";
@@ -15,7 +15,7 @@ class TestUtils {
1515
* @param exampleBoolean
1616
* @return
1717
*/
18-
static byte[] serializeExample(long exampleLong, String exampleString, boolean exampleBoolean) throws IOException {
18+
public static byte[] serializeExample(long exampleLong, String exampleString, boolean exampleBoolean) throws IOException {
1919
ByteArrayOutputStream baos = new ByteArrayOutputStream();
2020
DataOutputStream daos = new DataOutputStream(baos);
2121

@@ -30,7 +30,7 @@ static byte[] serializeExample(long exampleLong, String exampleString, boolean e
3030
/**
3131
* a deserialization example
3232
*/
33-
static void deserializeExample(byte[] serializedData) throws IOException {
33+
public static void deserializeExample(byte[] serializedData) throws IOException {
3434
ByteArrayInputStream bais = new ByteArrayInputStream(serializedData);
3535
DataInputStream dais = new DataInputStream(bais);
3636

0 commit comments

Comments
 (0)