This commit is contained in:
narawat lamaiin
2025-03-31 21:30:29 +07:00
parent 562f528c01
commit 1da05f5cae
2 changed files with 63 additions and 19 deletions

View File

@@ -1,14 +1,15 @@
using Test
using GeneralUtils
@testset "lastElementsIndex" begin
@test GeneralUtils.lastElementsIndex([1,2,3,4,5], 3) == 3:5
@test GeneralUtils.lastElementsIndex([1,2,3], 5) == 1:3
@test GeneralUtils.lastElementsIndex([1], 1) == 1:1
@test GeneralUtils.lastElementsIndex(collect(1:10), 4) == 7:10
@test GeneralUtils.lastElementsIndex(Float64[], 2) == 1:0
@test GeneralUtils.lastElementsIndex([1,2,3], 0) == length([1,2,3])+1:length([1,2,3])
@test GeneralUtils.lastElementsIndex(["a","b","c"], 2) == 2:3
@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)
end