Nanoid.jl/test/runtests.jl

27 lines
599 B
Julia
Raw Permalink Normal View History

using Nanoid
using Test
@testset "Nanoid.jl" begin
2022-03-20 03:01:53 +00:00
@testset "Randomness" begin
@test nanoid() != nanoid()
end
@testset "Length" begin
@test length(nanoid()) == 21
@test length(nanoid(1)) == 1
@test length(nanoid(255)) == 255
@test length(nanoid(25)) == 25
end
@testset "Errors" begin
@test_throws ErrorException("size must be at least 1") nanoid(-1)
end
@testset "Custom alphabet" begin
output = nanoid(;alphabet = "ABCDE")
for chars in output
@test chars in "ABCDE"
end
end
end