summaryrefslogtreecommitdiff
path: root/src/tests/org/noreply/fancydress/directory/ServerDescriptorTest.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/tests/org/noreply/fancydress/directory/ServerDescriptorTest.java')
-rw-r--r--src/tests/org/noreply/fancydress/directory/ServerDescriptorTest.java44
1 files changed, 44 insertions, 0 deletions
diff --git a/src/tests/org/noreply/fancydress/directory/ServerDescriptorTest.java b/src/tests/org/noreply/fancydress/directory/ServerDescriptorTest.java
new file mode 100644
index 0000000..adbe46e
--- /dev/null
+++ b/src/tests/org/noreply/fancydress/directory/ServerDescriptorTest.java
@@ -0,0 +1,44 @@
+import java.io.*;
+import java.util.*;
+import junit.framework.*;
+import org.noreply.fancydress.misc.Util;
+import org.noreply.fancydress.directory.ServerDescriptor;
+
+public class ServerDescriptorTest extends TestCase {
+
+ public ServerDescriptorTest(String name) {
+ super(name);
+ }
+
+ private boolean equals(String[] s1, String[] s2) {
+ boolean equals = s1.length == s2.length;
+ if (equals)
+ for (int i=0; i<s1.length; i++) {
+ equals = equals && s1[i].equals(s2[i]);
+ }
+ return equals;
+ }
+
+ public void testParsePacketVersions() {
+ String versions = "0.1 , 0.3, 0.6";
+ String[] expected = {"0.1", "0.3", "0.6"};
+ String[] parsed = ServerDescriptor.parsePacketVersions(versions, false);
+ String[] expected2 = {"0.3"};
+ String[] parsed2 = ServerDescriptor.parsePacketVersions(versions);
+ String[] parsed2_1 = ServerDescriptor.parsePacketVersions("0.3");
+
+ assertTrue(equals(expected, parsed));
+ assertTrue(equals(expected2, parsed2));
+ assertTrue(equals(expected2, parsed2_1));
+ };
+
+ public static Test suite() {
+ TestSuite suite= new TestSuite();
+ suite.addTest(new ServerDescriptorTest("testParsePacketVersions"));
+ return suite;
+ }
+
+ public static void main(String args[]) {
+ junit.textui.TestRunner.run(suite());
+ }
+}