Skip to content

Commit

Permalink
Fix test, because we only accept comma for compatible locales
Browse files Browse the repository at this point in the history
  • Loading branch information
elpaso committed Jun 9, 2018
1 parent bf810e9 commit cb3eb96
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions tests/src/python/test_qgsfieldvalidator.py
Expand Up @@ -59,21 +59,26 @@ def _test(value, expected):

# Valid
_test('0.1234', QValidator.Acceptable)
_test('0,1234', QValidator.Acceptable)

# Apparently we accept comma only when locale say so
if DECIMAL_SEPARATOR != '.':
_test('0,1234', QValidator.Acceptable)

# If precision is > 0, regexp validator is used (and it does not support sci notation)
if field.precision() == 0:
_test('12345.1234e+123', QValidator.Acceptable)
_test('12345.1234e-123', QValidator.Acceptable)
_test('12345,1234e+123', QValidator.Acceptable)
_test('12345,1234e-123', QValidator.Acceptable)
if DECIMAL_SEPARATOR != '.':
_test('12345,1234e+123', QValidator.Acceptable)
_test('12345,1234e-123', QValidator.Acceptable)
_test('', QValidator.Acceptable)

# Out of range
_test('12345.1234e+823', QValidator.Intermediate)
_test('12345.1234e-823', QValidator.Intermediate)
_test('12345,1234e+823', QValidator.Intermediate)
_test('12345,1234e-823', QValidator.Intermediate)
if DECIMAL_SEPARATOR != '.':
_test('12345,1234e+823', QValidator.Intermediate)
_test('12345,1234e-823', QValidator.Intermediate)

# Invalid
_test('12345-1234', QValidator.Invalid)
Expand Down

0 comments on commit cb3eb96

Please sign in to comment.