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.159 tracks/julia/exercises/phone-number/runtests.jl
trackler-2.2.1.158 tracks/julia/exercises/phone-number/runtests.jl
trackler-2.2.1.157 tracks/julia/exercises/phone-number/runtests.jl
trackler-2.2.1.156 tracks/julia/exercises/phone-number/runtests.jl
trackler-2.2.1.155 tracks/julia/exercises/phone-number/runtests.jl
trackler-2.2.1.154 tracks/julia/exercises/phone-number/runtests.jl
trackler-2.2.1.153 tracks/julia/exercises/phone-number/runtests.jl
trackler-2.2.1.152 tracks/julia/exercises/phone-number/runtests.jl
trackler-2.2.1.151 tracks/julia/exercises/phone-number/runtests.jl
trackler-2.2.1.150 tracks/julia/exercises/phone-number/runtests.jl
trackler-2.2.1.149 tracks/julia/exercises/phone-number/runtests.jl
trackler-2.2.1.148 tracks/julia/exercises/phone-number/runtests.jl
trackler-2.2.1.147 tracks/julia/exercises/phone-number/runtests.jl
trackler-2.2.1.146 tracks/julia/exercises/phone-number/runtests.jl
trackler-2.2.1.145 tracks/julia/exercises/phone-number/runtests.jl
trackler-2.2.1.144 tracks/julia/exercises/phone-number/runtests.jl
trackler-2.2.1.143 tracks/julia/exercises/phone-number/runtests.jl
trackler-2.2.1.142 tracks/julia/exercises/phone-number/runtests.jl
trackler-2.2.1.141 tracks/julia/exercises/phone-number/runtests.jl
trackler-2.2.1.140 tracks/julia/exercises/phone-number/runtests.jl