Skip to content

Commit aacb31f

Browse files
ismailsunninyalldawson
authored andcommittedMay 17, 2020
Add unit test for conversion from small negative longlong.
1 parent 23562ab commit aacb31f

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed
 

‎tests/src/core/testqgsfield.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -550,6 +550,16 @@ void TestQgsField::convertCompatible()
550550
QVERIFY( intField.convertCompatible( smallLonglong ) );
551551
QCOMPARE( smallLonglong.type(), QVariant::Int );
552552
QCOMPARE( smallLonglong, QVariant( 99 ) );
553+
// negative longlong to int
554+
QVariant negativeLonglong( -99999999999999999LL );
555+
QVERIFY( !intField.convertCompatible( negativeLonglong ) );
556+
QCOMPARE( negativeLonglong.type(), QVariant::Int );
557+
QVERIFY( negativeLonglong.isNull() );
558+
// small negative longlong to int
559+
QVariant smallNegativeLonglong( -99LL );
560+
QVERIFY( intField.convertCompatible( smallNegativeLonglong ) );
561+
QCOMPARE( smallNegativeLonglong.type(), QVariant::Int );
562+
QCOMPARE( smallNegativeLonglong, QVariant( -99 ) );
553563

554564
//string representation of an int
555565
QVariant stringInt( "123456" );

0 commit comments

Comments
 (0)
Please sign in to comment.