diff options
author | Daniel Teske <qt@squorn.de> | 2017-06-27 15:10:35 +0200 |
---|---|---|
committer | Daniel Teske <qt@squorn.de> | 2017-07-13 14:59:17 +0000 |
commit | 70515726181a7e97e1a7096f6b63d4320581d5c1 (patch) | |
tree | 161ef666c0dc06c59552059827870b1278d6028b /tests/auto/widgets | |
parent | bdca35e8154d6a8cb2232bd32c64c9e0ba3775c4 (diff) |
QLineEdit: Fix length calculation for input mask "\\\\"
Consider the raw string \\\\. The previous algorithm would consider
the last 3 \ to be escaped because the previous character is a \ and
thus calculating a maxLength of 3.
But this should be treated as two escaped \ with a maxLength of 2.
Change-Id: I6c4b8d090a2e1c6e85195d5920ce8b80aea1bc2d
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
Diffstat (limited to 'tests/auto/widgets')
-rw-r--r-- | tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp b/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp index a0ba91ba4a..3f7fdd6f6f 100644 --- a/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp +++ b/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp @@ -3106,7 +3106,6 @@ void tst_QLineEdit::inputMaskAndValidator() void tst_QLineEdit::maxLengthAndInputMask() { - // Really a test for #30447 QLineEdit *testWidget = ensureTestWidget(); QVERIFY(testWidget->inputMask().isNull()); testWidget->setMaxLength(10); @@ -3114,6 +3113,16 @@ void tst_QLineEdit::maxLengthAndInputMask() testWidget->setInputMask(QString()); QVERIFY(testWidget->inputMask().isNull()); QCOMPARE(testWidget->maxLength(), 10); + + testWidget->setInputMask("XXXX"); + QCOMPARE(testWidget->maxLength(), 4); + + testWidget->setMaxLength(15); + QCOMPARE(testWidget->maxLength(), 4); + + // 8 \ => raw string with 4 \ => input mask with 2 \ => maxLength = 2 + testWidget->setInputMask("\\\\\\\\"); + QCOMPARE(testWidget->maxLength(), 2); } |