File tree Expand file tree Collapse file tree 4 files changed +50
-2
lines changed
src/test/java/org/mozilla/reference/browser/ext Expand file tree Collapse file tree 4 files changed +50
-2
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+ }
Original file line number Diff line number Diff line change @@ -88,12 +88,13 @@ subprojects {
8888 afterEvaluate {
8989 if (it. hasProperty(' android' )) {
9090 jacoco {
91- toolVersion = libs. versions. jacoco
91+ toolVersion = libs. versions. jacoco. get()
9292 }
9393
9494 android {
9595
9696 testOptions {
97+
9798 unitTests {
9899 includeAndroidResources = true
99100 }
Original file line number Diff line number Diff line change @@ -48,7 +48,7 @@ ktlint = "1.8.0"
4848
4949# Third Party Testing
5050hamcrest = " 1.3"
51- jacoco = " 0.8.14 "
51+ jacoco = " 0.8.12 "
5252junit = " 4.13.2"
5353okhttp = " 5.3.2"
5454okio = " 3.16.4"
You can’t perform that action at this time.
0 commit comments