forked from arthurdejong/python-stdnum
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve malaysian ITN implementation
Note that TF prefix is not implemented because that might be a typo, since it doesn't appear on the lists. Fixes arthurdejong#113 Closes arthurdejong#237
- Loading branch information
Showing
3 changed files
with
167 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
test_my_itn.doctest - more detailed doctests for stdnum.my.itn module | ||
|
||
Copyright (C) 2023 Leandro Regueiro | ||
|
||
This library is free software; you can redistribute it and/or | ||
modify it under the terms of the GNU Lesser General Public | ||
License as published by the Free Software Foundation; either | ||
version 2.1 of the License, or (at your option) any later version. | ||
|
||
This library is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
Lesser General Public License for more details. | ||
|
||
You should have received a copy of the GNU Lesser General Public | ||
License along with this library; if not, write to the Free Software | ||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA | ||
02110-1301 USA | ||
|
||
|
||
This file contains more detailed doctests for the stdnum.my.itn module. It | ||
tries to test more corner cases and detailed functionality that is not really | ||
useful as module documentation. | ||
|
||
>>> from stdnum.my import itn | ||
|
||
|
||
Tests for some corner cases. | ||
|
||
>>> itn.validate('SG 10234567090') | ||
'SG10234567090' | ||
>>> itn.validate('OG 25845632021') | ||
'OG25845632021' | ||
>>> itn.validate('C 2584563202') | ||
'C2584563202' | ||
>>> itn.validate('X 12345') | ||
Traceback (most recent call last): | ||
... | ||
InvalidComponent: ... | ||
>>> itn.validate('12345') | ||
Traceback (most recent call last): | ||
... | ||
InvalidComponent: ... | ||
>>> itn.validate('C') | ||
Traceback (most recent call last): | ||
... | ||
InvalidComponent: ... | ||
>>> itn.validate('SG 123456789012') | ||
Traceback (most recent call last): | ||
... | ||
InvalidComponent: ... | ||
>>> itn.validate('C 12345678901') | ||
Traceback (most recent call last): | ||
... | ||
InvalidComponent: ... | ||
>>> itn.validate('C 12345X') | ||
Traceback (most recent call last): | ||
... | ||
InvalidFormat: ... | ||
>>> itn.format('C2584563202') | ||
'C 2584563202' | ||
>>> itn.format('SG10234567090') | ||
'SG 10234567090' | ||
|
||
|
||
These have been found online and should all be valid numbers. | ||
|
||
>>> numbers = ''' | ||
... | ||
... C 2128186207 | ||
... C 2354867110 | ||
... C 2493192407 | ||
... F 1064671704 | ||
... OG 04455987090 | ||
... SG 2178656-09 | ||
... SG 10234567090 | ||
... OG 25845632021 | ||
... C 2584563202 | ||
... | ||
... ''' | ||
>>> [x for x in numbers.splitlines() if x and not itn.is_valid(x)] | ||
[] |