File tree Expand file tree Collapse file tree 2 files changed +47
-0
lines changed
src/test/java/org/mozilla/reference/browser/ext Expand file tree Collapse file tree 2 files changed +47
-0
lines changed Original file line number Diff line number Diff line change @@ -290,6 +290,8 @@ dependencies {
290290 implementation libs. mozilla. ui. tabcounter
291291 implementation libs. mozilla. ui. widgets
292292
293+ testImplementation libs. junit
294+
293295 androidTestImplementation libs. androidx. test. espresso. core
294296 androidTestImplementation libs. androidx. test. espresso. idling. resources
295297 constraints {
Original file line number Diff line number Diff line change 1+ /* This Source Code Form is subject to the terms of the Mozilla Public
2+ * License, v. 2.0. If a copy of the MPL was not distributed with this
3+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4+
5+ package org.mozilla.reference.browser.ext
6+
7+ import org.junit.Assert.assertEquals
8+ import org.junit.Test
9+
10+ class StringKtTest {
11+ @Test
12+ fun `replace should replace all keys with their corresponding values` () {
13+ val input = " The quick brown fox jumps over the lazy dog"
14+ val pairs = mapOf (
15+ " quick" to " slow" ,
16+ " brown" to " red" ,
17+ " fox" to " cat" ,
18+ " dog" to " mouse" ,
19+ )
20+
21+ val result = input.replace(pairs)
22+
23+ assertEquals(" The slow red cat jumps over the lazy mouse" , result)
24+ }
25+
26+ @Test
27+ fun `replace should return the same string if the map is empty` () {
28+ val input = " Hello world"
29+ val pairs = emptyMap<String , String >()
30+
31+ val result = input.replace(pairs)
32+
33+ assertEquals(input, result)
34+ }
35+
36+ @Test
37+ fun `replace should handle keys that are not present in the string` () {
38+ val input = " Hello world"
39+ val pairs = mapOf (" foo" to " bar" )
40+
41+ val result = input.replace(pairs)
42+
43+ assertEquals(" Hello world" , result)
44+ }
45+ }
You can’t perform that action at this time.
0 commit comments