Adds a couple fixed tests from here that are unambiguously correct by the spec (the '34 567890' one is unclear on its correctness, and the author solution disagrees with the issue on how it should be handled).
Adds random tests with somewhat decent coverage, please suggest more cases.
Looks like there are not enough tests for the numbers that start with region code.
Namely, '0034 567890' and '34 567890' should not yield a match.
Most of the published solutions fail on these examples.
hkmt and friends are the only ones who nailed it. All glory to them!
' 034 567890' (with a leading space) probably should yield a match (there were tests with a leading space before the country code that were supposed to yeald a match).
This one fails for all published solutions. Including mine :)
Also, some of the published solutions fail on '0012 34 567890'.
How on earth could they be submitted in the first place?
The tests in the java-version does not use assertEquals correctly. When checking the number of groups, it does
assertEquals("found too many or too few groups.", m.groupCount(), 3);
but Syntax of assertEquals is
assertEquals (<text>,<expected>, <actual>)
so it needs to be
assertEquals("found too many or too few groups.",3, m.groupCount());
It's not explicitly stated how many digits make up a country code, though, based on the examples and the tests, it appears to be 2 (like the 12 in +12/0012). If this is the case, there should be a test that checks for invalid country codes (e.g. +123 55 678990)
Python fork
'34 567890'
one is unclear on its correctness, and the author solution disagrees with the issue on how it should be handled).No random tests
Python tests beyond busted.
I'm confused about what our function is supposed to return -- phone numbers that are valid or the regex pattern used to match them?
Looks like there are not enough tests for the numbers that start with region code.
Namely, '0034 567890' and '34 567890' should not yield a match.
Most of the published solutions fail on these examples.
hkmt and friends are the only ones who nailed it. All glory to them!
' 034 567890' (with a leading space) probably should yield a match (there were tests with a leading space before the country code that were supposed to yeald a match).
This one fails for all published solutions. Including mine :)
Also, some of the published solutions fail on '0012 34 567890'.
How on earth could they be submitted in the first place?
There should be tests with nation code but no area code.
The tests in the java-version does not use assertEquals correctly. When checking the number of groups, it does
assertEquals("found too many or too few groups.", m.groupCount(), 3);
but Syntax of assertEquals is
assertEquals (<text>,<expected>, <actual>)
so it needs to be
assertEquals("found too many or too few groups.",3, m.groupCount());
It's not explicitly stated how many digits make up a country code, though, based on the examples and the tests, it appears to be
2
(like the12
in+12
/0012
). If this is the case, there should be a test that checks for invalid country codes (e.g.+123 55 678990
)