Kaynağa Gözat

Add unit test for DCC plugin's ip<->long methods

git-svn-id: http://svn.dmdirc.com/trunk@3632 00569f92-eb28-0410-84fd-f71c24880f
tags/0.6
Chris Smith 16 yıl önce
ebeveyn
işleme
fa6b78251b
1 değiştirilmiş dosya ile 71 ekleme ve 0 silme
  1. 71
    0
      test/com/dmdirc/addons/dcc/IpToLongTest.java

+ 71
- 0
test/com/dmdirc/addons/dcc/IpToLongTest.java Dosyayı Görüntüle

@@ -0,0 +1,71 @@
1
+/*
2
+ * Copyright (c) 2006-2008 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.addons.dcc;
24
+
25
+import java.util.Arrays;
26
+import java.util.List;
27
+
28
+import org.junit.Test;
29
+import org.junit.runner.RunWith;
30
+import org.junit.runners.Parameterized;
31
+import static org.junit.Assert.*;
32
+
33
+@RunWith(Parameterized.class)
34
+public class IpToLongTest {
35
+    
36
+    private String stringip;
37
+    private long longip;
38
+
39
+    public IpToLongTest(String stringip, Long longip) {
40
+        this.stringip = stringip;
41
+        this.longip = longip;
42
+    }
43
+    
44
+    @Test
45
+    public void testToLong() {
46
+        assertEquals(longip, DCC.ipToLong(stringip));
47
+    }
48
+    
49
+    @Test
50
+    public void testToString() {
51
+        assertEquals(stringip, DCC.longToIP(longip));
52
+    }
53
+    
54
+    @Parameterized.Parameters
55
+    public static List<Object[]> data() {
56
+        final Object[][] tests = {
57
+            {"0.0.0.0", 0L},
58
+            {"0.0.0.255", 255L},
59
+            {"127.0.0.1", 2130706433L},
60
+            {"255.0.0.0", 4278190080L},
61
+            {"255.255.255.255", 4294967295L},
62
+        };
63
+
64
+        return Arrays.asList(tests);
65
+    }
66
+    
67
+    public static junit.framework.Test suite() {
68
+        return new junit.framework.JUnit4TestAdapter(IpToLongTest.class);
69
+    }
70
+    
71
+}

Loading…
İptal
Kaydet