2022-03-20 01:38:51 +00:00
|
|
|
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
|
2022-03-20 01:38:51 +00:00
|
|
|
end
|