update
This commit is contained in:
@@ -1,15 +1,35 @@
|
||||
using Test
|
||||
using GeneralUtils
|
||||
using GeneralUtils: detect_keyword
|
||||
|
||||
@testset "ealierElementsIndex" begin
|
||||
@test GeneralUtils.ealierElementsIndex([1,2,3,4,5], 2) == 1:3
|
||||
@test GeneralUtils.ealierElementsIndex([1,2,3], 0) == 1:3
|
||||
@test GeneralUtils.ealierElementsIndex([1], 1) == 1:0
|
||||
@test GeneralUtils.ealierElementsIndex([], 0) == 1:0
|
||||
@test GeneralUtils.ealierElementsIndex([1,2,3,4], 4) == 1:0
|
||||
@test GeneralUtils.ealierElementsIndex([1,2,3,4], 5) == 1:0
|
||||
@test GeneralUtils.ealierElementsIndex(collect(1:10), 3) == 1:7
|
||||
@test_throws ErrorException GeneralUtils.ealierElementsIndex([1,2,3], -1)
|
||||
@testset "detect_keyword tests" begin
|
||||
@test detect_keyword(["test"], "this is a test") == Dict("test" => 1)
|
||||
|
||||
@test detect_keyword(["hello", "world"], "hello world hello") == Dict("hello" => 2, "world" => 1)
|
||||
|
||||
@test detect_keyword(["cat"], "category") == Dict("cat" => 1)
|
||||
|
||||
@test detect_keyword(["cat"], "category"; mode="individual") == Dict("cat" => 0)
|
||||
|
||||
@test detect_keyword(["dog"], "dogs and cats"; mode="individual", delimiter=[' ']) == Dict("dog" => 0)
|
||||
|
||||
@test detect_keyword(["test"], "test.case"; mode="individual", delimiter=['.']) == Dict("test" => 1)
|
||||
|
||||
@test detect_keyword(["word"], "") == Dict("word" => 0)
|
||||
|
||||
@test detect_keyword(String[], "some text") == Dict{String, Integer}()
|
||||
|
||||
@test detect_keyword(["a", "b"], "a.b\nc"; delimiter=['.', '\n']) == Dict("a" => 1, "b" => 1)
|
||||
|
||||
multiline_text = """
|
||||
first line
|
||||
second line
|
||||
first word
|
||||
"""
|
||||
@test detect_keyword(["first"], multiline_text) == Dict("first" => 2)
|
||||
|
||||
@test detect_keyword(["word"], "word"; mode="individual") == Dict("word" => 1)
|
||||
|
||||
@test detect_keyword(["test"], "testing.test.tester"; mode="individual", delimiter=['.']) == Dict("test" => 1)
|
||||
end
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user