| OLD | NEW |
| 1 package org.adblockplus.libadblockplus.tests; | 1 package org.adblockplus.libadblockplus.tests; |
| 2 | 2 |
| 3 import org.adblockplus.libadblockplus.android.Utils; | 3 import org.adblockplus.libadblockplus.android.Utils; |
| 4 import org.junit.Test; | 4 import org.junit.Test; |
| 5 | 5 |
| 6 import java.util.Arrays; | 6 import java.util.Arrays; |
| 7 import java.util.LinkedList; | 7 import java.util.LinkedList; |
| 8 import java.util.List; | 8 import java.util.List; |
| 9 | 9 |
| 10 /** | 10 /** |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 } | 45 } |
| 46 | 46 |
| 47 @Test | 47 @Test |
| 48 public void testJson_singleWithNull() | 48 public void testJson_singleWithNull() |
| 49 { | 49 { |
| 50 final List<String> list = new LinkedList<String>(); | 50 final List<String> list = new LinkedList<String>(); |
| 51 list.add(null); | 51 list.add(null); |
| 52 String json = Utils.stringListToJsonArray(list); | 52 String json = Utils.stringListToJsonArray(list); |
| 53 assertEquals("[]", json); | 53 assertEquals("[]", json); |
| 54 } | 54 } |
| 55 |
| 56 @Test |
| 57 public void testUrlWithoutParams_null() |
| 58 { |
| 59 try |
| 60 { |
| 61 Utils.getUrlWithoutParams(null); |
| 62 fail(); |
| 63 } |
| 64 catch (IllegalArgumentException ignored) |
| 65 { |
| 66 // ignored |
| 67 } |
| 68 } |
| 69 |
| 70 @Test |
| 71 public void testUrlWithoutParams_empty() |
| 72 { |
| 73 String url = Utils.getUrlWithoutParams("https://www.google.com?"); |
| 74 assertNotNull(url); |
| 75 assertEquals("https://www.google.com", url); |
| 76 } |
| 77 |
| 78 @Test |
| 79 public void testUrlWithoutParams_withoutParams() |
| 80 { |
| 81 final String originalUrl = "http://www.google.com"; |
| 82 String url = Utils.getUrlWithoutParams(originalUrl); |
| 83 assertNotNull(url); |
| 84 assertEquals(originalUrl, url); |
| 85 } |
| 86 |
| 87 @Test |
| 88 public void testUrlWithoutParams_ok() |
| 89 { |
| 90 String url = Utils.getUrlWithoutParams("https://www.google.com?q=adblockplus
"); |
| 91 assertNotNull(url); |
| 92 assertEquals("https://www.google.com", url); |
| 93 } |
| 94 |
| 95 @Test |
| 96 public void testUrlWithoutParams_multipleParams() |
| 97 { |
| 98 String url = Utils.getUrlWithoutParams("https://www.google.com?q=adblockplus
&gws_rd=cr"); |
| 99 assertNotNull(url); |
| 100 assertEquals("https://www.google.com", url); |
| 101 } |
| 102 |
| 103 @Test |
| 104 public void testUrlWithoutParams_language() |
| 105 { |
| 106 String url = Utils.getUrlWithoutParams("http://почта.рф?q=myemail"); // non-
English characters in URL |
| 107 assertNotNull(url); |
| 108 assertEquals("http://почта.рф", url); |
| 109 } |
| 110 |
| 111 @Test |
| 112 public void testUrlWithoutParams_digits() |
| 113 { |
| 114 String url = Utils.getUrlWithoutParams("https://www.google.com?q=123"); |
| 115 assertNotNull(url); |
| 116 assertEquals("https://www.google.com", url); |
| 117 } |
| 118 |
| 119 @Test |
| 120 public void testUrlWithoutParams_multipleQuestionMarks() |
| 121 { |
| 122 String url = Utils.getUrlWithoutParams("https://www.google.com?q=123?t=123")
; // invalid URL |
| 123 assertNotNull(url); |
| 124 assertEquals("https://www.google.com", url); |
| 125 } |
| 55 } | 126 } |
| OLD | NEW |