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.139 tracks/julia/exercises/phone-number/runtests.jl
trackler-2.2.1.138 tracks/julia/exercises/phone-number/runtests.jl
trackler-2.2.1.137 tracks/julia/exercises/phone-number/runtests.jl
trackler-2.2.1.136 tracks/julia/exercises/phone-number/runtests.jl
trackler-2.2.1.135 tracks/julia/exercises/phone-number/runtests.jl
trackler-2.2.1.134 tracks/julia/exercises/phone-number/runtests.jl
trackler-2.2.1.133 tracks/julia/exercises/phone-number/runtests.jl
trackler-2.2.1.132 tracks/julia/exercises/phone-number/runtests.jl
trackler-2.2.1.131 tracks/julia/exercises/phone-number/runtests.jl
trackler-2.2.1.130 tracks/julia/exercises/phone-number/runtests.jl
trackler-2.2.1.129 tracks/julia/exercises/phone-number/runtests.jl
trackler-2.2.1.128 tracks/julia/exercises/phone-number/runtests.jl
trackler-2.2.1.127 tracks/julia/exercises/phone-number/runtests.jl
trackler-2.2.1.126 tracks/julia/exercises/phone-number/runtests.jl
trackler-2.2.1.125 tracks/julia/exercises/phone-number/runtests.jl
trackler-2.2.1.124 tracks/julia/exercises/phone-number/runtests.jl
trackler-2.2.1.123 tracks/julia/exercises/phone-number/runtests.jl
trackler-2.2.1.122 tracks/julia/exercises/phone-number/runtests.jl
trackler-2.2.1.121 tracks/julia/exercises/phone-number/runtests.jl
trackler-2.2.1.120 tracks/julia/exercises/phone-number/runtests.jl