File tree Expand file tree Collapse file tree 3 files changed +26
-0
lines changed Expand file tree Collapse file tree 3 files changed +26
-0
lines changed Original file line number Diff line number Diff line change
1
+ import unittest
2
+ import validator
3
+
4
+ class TestIsFullWidth (unittest .TestCase ):
5
+
6
+ def test_valid_full_width (self ):
7
+ self .assertTrue (validator .is_full_width ('ひらがな・カタカナ、.漢字' ))
8
+ self .assertTrue (validator .is_full_width ('3ー0 a@com' ))
9
+ self .assertTrue (validator .is_full_width ('Fカタカナ゙ᆲ' ))
10
+ self .assertTrue (validator .is_full_width ('Ğood=Parts' ))
11
+ print ('OK - test_valid_full_width' )
12
+
13
+ def test_invalid_full_width (self ):
14
+ self .assertFalse (validator .is_full_width ('abc' ))
15
+ self .assertFalse (validator .is_full_width ('abc123' ))
16
+ self .assertFalse (validator .is_full_width ('!"#$%&()<>/+=-_? ~^|.,@`{}[]' ))
17
+ print ('OK - test_invalid_full_width' )
Original file line number Diff line number Diff line change 30
30
from .is_mongo_id import *
31
31
from .is_uppercase import *
32
32
from .is_slug import *
33
+ from .is_full_width import *
Original file line number Diff line number Diff line change
1
+ from .utils .Classes .RegEx import RegEx
2
+ from .utils .assert_string import assert_string
3
+
4
+ full_width_pattern = RegEx ("[^\u0020 -\u007E \uFF61 -\uFF9F \uFFA0 -\uFFDC \uFFE8 -\uFFEE 0-9a-zA-Z]" )
5
+
6
+ def is_full_width (input : str ) -> bool :
7
+ input = assert_string (input )
8
+ return full_width_pattern .match (input )
You can’t perform that action at this time.
0 commit comments