Files
GeneralUtils/test/runtests.jl
2025-03-20 16:05:39 +07:00

24 lines
1.0 KiB
Julia

using Test
using GeneralUtils
@testset "detect_keyword tests" begin
@test GeneralUtils.detect_keyword(["test"], "this is a test string") == Dict("test" => 1)
@test GeneralUtils.detect_keyword(["hello", "world"], "hello world") == Dict("hello" => 1, "world" => 1)
@test GeneralUtils.detect_keyword(["missing"], "no keyword here") == Dict("missing" => nothing)
@test GeneralUtils.detect_keyword(["a", "b"], "a a b b b") == Dict("a" => 2, "b" => 3)
@test GeneralUtils.detect_keyword(String[], "empty keywords") == Dict{String, Any}()
@test GeneralUtils.detect_keyword(["keyword"], "") == Dict("keyword" => nothing)
@test GeneralUtils.detect_keyword(["case"], "CASE case Case cAsE") == Dict("case" => 4)
mixed_results = GeneralUtils.detect_keyword(["found", "notfound"], "found found found")
@test mixed_results["found"] == 3
@test mixed_results["notfound"] === nothing
special_chars = GeneralUtils.detect_keyword(["test!"], "test! test? test.")
@test special_chars["test!"] == 1
end