Sha256: a90a51c61a1589f6efaebdb405663bfd1d0be8ca881e05bdf5603791e8b47ab0

Contents?: true

Size: 1.17 KB

Versions: 131

Compression:

Stored size: 1.17 KB

Contents

using Base.Test

include("phone-number.jl")


# Tests adapted from `problem-specifications//canonical-data.json` @ v1.2.0
# Returns the cleaned phone number as a digit string if given number is valid,
# else returns `nothing`.

const expected_number = "2234567890"
const valid_10digit_num = (
        "(223) 456-7890",
        "223.456.7890",
        "223 456   7890   ",
)
const valid_11digit_num = (
        "12234567890",
        "  1 223 456 7890 ",
        "+1 (223) 456-7890",
)
const invalid_num = (
        "1223456789",
        "22234567890",
        "321234567890",
        "223-abc-7890",
        "223-@:!-7890",
        "(023) 456-7890",
        "(123) 456-7890",
        "(223) 056-7890",
        "(223) 156-7890",
)

@testset "clean 10-digit number" begin
    @testset "$number" for number in valid_10digit_num
        @test clean(number) == expected_number
    end
end

@testset "clean 11-digit number starting with 1" begin
    @testset "$number" for number in valid_11digit_num
        @test clean(number) == expected_number
    end
end

@testset "detect invalid number" begin
    @testset "$number" for number in invalid_num
        @test clean(number) == nothing
    end
end

Version data entries

131 entries across 131 versions & 1 rubygems

Version Path
trackler-2.2.1.180 tracks/julia/exercises/phone-number/runtests.jl
trackler-2.2.1.179 tracks/julia/exercises/phone-number/runtests.jl
trackler-2.2.1.178 tracks/julia/exercises/phone-number/runtests.jl
trackler-2.2.1.177 tracks/julia/exercises/phone-number/runtests.jl
trackler-2.2.1.176 tracks/julia/exercises/phone-number/runtests.jl
trackler-2.2.1.175 tracks/julia/exercises/phone-number/runtests.jl
trackler-2.2.1.174 tracks/julia/exercises/phone-number/runtests.jl
trackler-2.2.1.173 tracks/julia/exercises/phone-number/runtests.jl
trackler-2.2.1.172 tracks/julia/exercises/phone-number/runtests.jl
trackler-2.2.1.171 tracks/julia/exercises/phone-number/runtests.jl
trackler-2.2.1.170 tracks/julia/exercises/phone-number/runtests.jl
trackler-2.2.1.169 tracks/julia/exercises/phone-number/runtests.jl
trackler-2.2.1.167 tracks/julia/exercises/phone-number/runtests.jl
trackler-2.2.1.166 tracks/julia/exercises/phone-number/runtests.jl
trackler-2.2.1.165 tracks/julia/exercises/phone-number/runtests.jl
trackler-2.2.1.164 tracks/julia/exercises/phone-number/runtests.jl
trackler-2.2.1.163 tracks/julia/exercises/phone-number/runtests.jl
trackler-2.2.1.162 tracks/julia/exercises/phone-number/runtests.jl
trackler-2.2.1.161 tracks/julia/exercises/phone-number/runtests.jl
trackler-2.2.1.160 tracks/julia/exercises/phone-number/runtests.jl