diff options
author | Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> | 2012-10-14 04:12:35 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2012-10-22 22:42:26 +0200 |
commit | bbda968a0a3230b1ddb55b27e4dcc627fc087bbd (patch) | |
tree | 66b30d489ca776c1d8f0fcd1f9c866c5d9fd07ea /tests/auto/gui | |
parent | 6fe8a3d5a1c1f2b963fe25e9032b562f6c6467e6 (diff) |
Fix QRegExpValidator::validate docs about the pos parameter
The code sets it to input.length() iff the regexp doesn't
match the string, while the docs say it's *always* set.
Therefore, make the docs match what the code does and
add a simple test to enforce it.
We're not changing the code to match the docs because
1) it's better to stay conservative (we don't want
to break existing behaviour);
2) this behaviour mimics what the int/double validators do
(they don't move pos at all).
Change-Id: I958074558de6b0fc5944101c6535fc7e00442ae9
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
Diffstat (limited to 'tests/auto/gui')
-rw-r--r-- | tests/auto/gui/util/qregexpvalidator/tst_qregexpvalidator.cpp | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/tests/auto/gui/util/qregexpvalidator/tst_qregexpvalidator.cpp b/tests/auto/gui/util/qregexpvalidator/tst_qregexpvalidator.cpp index 7a2006b62e..d09a8e566b 100644 --- a/tests/auto/gui/util/qregexpvalidator/tst_qregexpvalidator.cpp +++ b/tests/auto/gui/util/qregexpvalidator/tst_qregexpvalidator.cpp @@ -116,8 +116,15 @@ void tst_QRegExpValidator::validate() QSignalSpy changedSpy(&rv, SIGNAL(changed())); rv.setRegExp( QRegExp( rx ) ); - int dummy; - QCOMPARE( (int)rv.validate( value, dummy ), state ); + int pos = -1; + + QCOMPARE( (int)rv.validate( value, pos ), state ); + + if (state == QValidator::Invalid) + QCOMPARE(pos, value.length()); + else + QCOMPARE(pos, -1); // untouched on Acceptable or Intermediate + QCOMPARE(spy.count(), 1); QCOMPARE(changedSpy.count(), 1); } |