Skip to content

Commit

Permalink
Merge pull request d4rken-org#1291 from d4rken-org/additional-tests
Browse files Browse the repository at this point in the history
Additional tests for segment matching
  • Loading branch information
d4rken authored Jul 8, 2024
2 parents c331687 + 695d243 commit a9013de
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,12 @@ class SegmentsExtensionTest : BaseTest() {
segs("ABc", "def").startsWith(segs("ab")) shouldBe false
segs("ABc", "def").startsWith(segs("ab"), ignoreCase = true, allowPartial = false) shouldBe false
segs("ABc", "def").startsWith(segs("ab"), ignoreCase = true, allowPartial = true) shouldBe true

segs("abc", "def", "").startsWith(segs("abc", "def"), ignoreCase = true, allowPartial = false) shouldBe true
segs("abc", "def", "").startsWith(segs("abc", "def"), ignoreCase = true, allowPartial = true) shouldBe true

segs("abc", "def", "ghi").startsWith(segs("abc", "def", ""), allowPartial = false) shouldBe false
segs("abc", "def", "ghi").startsWith(segs("abc", "def", ""), allowPartial = true) shouldBe true
}

@Test fun `segment endsWith`() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,10 @@ import okio.buffer
class JsonBasedSieve @AssistedInject constructor(
@Assisted private val assetPath: String,
@ApplicationContext private val context: Context,
private val baseMoshi: Moshi
private val moshi: Moshi
) {

private val filterDb: SieveJsonDb = run {
val moshi = baseMoshi.newBuilder().apply {
// add(RegexAdapter(caseInsensitive = true))
}.build()
val source: BufferedSource = context.openAsset(assetPath).buffer()
moshi.adapter<SieveJsonDb>().fromJson(source)!!
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ abstract class BaseFilterTest : BaseTest() {
return JsonBasedSieve(
context = context,
assetPath = assetPath,
baseMoshi = SerializationAppModule().moshi(),
moshi = SerializationAppModule().moshi(),
)
}
}
Expand Down

0 comments on commit a9013de

Please sign in to comment.