Problem-specifications: phone-number: Does not properly specifiy test for numbers with length greater than 11

Created on 22 Feb 2017  路  5Comments  路  Source: exercism/problem-specifications

The specification for the phone-number exercise says

  • If the phone number is more than 11 digits assume that it is a bad number

But the phone-number/canonical-data.json does not specify checking this properly. It checks for length of 11 without leading double 1 to be invalid and for length of 12 to be invalid. It should instead (according to the brief in the readme)check for any number greater than 11 to be invalid.

Most helpful comment

Current

        {
          "description": "invalid when 12 digits",
          "property": "clean",
          "phrase": "321234567890",
          "expected": null
        },

New

        {
          "description": "invalid when more than 11 digits",
          "property": "clean",
          "phrase": "321234567890",
          "expected": null
        },

The old version means that tests will check for implementations to use an input check similar to
```c
if (length == 12) {
return ERROR;
}

When in fact it should be 
 ```c
    if (length > 11) {
        return ERROR;
    }

I.E: All lengths greater than 11 are invalid, not just lengths of 12.

All 5 comments

@wolf99 If I understand correctly what you mean, the test for length 12 should be enough checking the case of greater than 11. Or maybe we need just one more testcase of arbitrary length greater than 11. What do others think? cc @rbasso @kotp

@wolf99, maybe I got the idea, but I'm not sure. Could you clarify what exactly you want to be changed, preferable with the old and new json fragments?

Current

        {
          "description": "invalid when 12 digits",
          "property": "clean",
          "phrase": "321234567890",
          "expected": null
        },

New

        {
          "description": "invalid when more than 11 digits",
          "property": "clean",
          "phrase": "321234567890",
          "expected": null
        },

The old version means that tests will check for implementations to use an input check similar to
```c
if (length == 12) {
return ERROR;
}

When in fact it should be 
 ```c
    if (length > 11) {
        return ERROR;
    }

I.E: All lengths greater than 11 are invalid, not just lengths of 12.

All lengths greater than 11 are invalid, not just lengths of 12.

Got it 馃槂 Nice catch! Would you mind sending a PR for this? Or else I can do the change.

Added #719 then

Was this page helpful?
0 / 5 - 0 ratings