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.58 tracks/julia/exercises/phone-number/runtests.jl
trackler-2.2.1.57 tracks/julia/exercises/phone-number/runtests.jl
trackler-2.2.1.56 tracks/julia/exercises/phone-number/runtests.jl
trackler-2.2.1.55 tracks/julia/exercises/phone-number/runtests.jl
trackler-2.2.1.54 tracks/julia/exercises/phone-number/runtests.jl
trackler-2.2.1.53 tracks/julia/exercises/phone-number/runtests.jl
trackler-2.2.1.52 tracks/julia/exercises/phone-number/runtests.jl
trackler-2.2.1.51 tracks/julia/exercises/phone-number/runtests.jl
trackler-2.2.1.50 tracks/julia/exercises/phone-number/runtests.jl
trackler-2.2.1.49 tracks/julia/exercises/phone-number/runtests.jl
trackler-2.2.1.48 tracks/julia/exercises/phone-number/runtests.jl