Hi, I'm on a 32-bit machine with GCC 4.6.3 and check_lexer fails: ********* Start testing of TestLexer ********* Config: Using QTest library 4.7.4, Qt 4.7.4 PASS : TestLexer::initTestCase() FAIL! : TestLexer::testNumbers() Compared doubles are not the same (fuzzy compare) Actual (obj.getReal()): -2.14748e+09 Expected ((double)-2147483649): 2.14748e+09 Loc: [/home/fabio/ok/poppler/qt4/tests/check_lexer.cpp(65)] PASS : TestLexer::cleanupTestCase() Totals: 2 passed, 1 failed, 0 skipped ********* Finished testing of TestLexer *********
During compilation I get the two following warnings: 1) qt4/tests/check_lexer.cpp:55:5: warning: this decimal constant is unsigned only in ISO C90 [enabled by default] 2) qt4/tests/check_lexer.cpp:65:5: warning: this decimal constant is unsigned only in ISO C90 [enabled by default] ← This is what makes the test fail! I'm attaching a patch that solves both warnings: 1) (int)-2147483648 is INT_MIN in 32-bit systems. However it seems that the way it is written is not very portable [http://www.hardtoc.com/archives/119]. The patch rewrites it as -2147483647-1 which, according to the linked page, is a better way to write it. 2) This is the one that makes the test fail. According to the output (double)-2147483649 is transformed by the compiler into a positive number (2.14748e+09). My guess is that 2147483649 is interpreted a signed number and, since it overflows, it is actually interpreted as -2147483647. The minus sign makes it positive 2147483647 again. The patch bypasses these details by writing the number directly as double literal, i.e. -2147483649.0 (well, actually the minus sign is not part of the number, but let's not be too picky ;)) I'm confident that these changes work on 64-bit systems too, but I have NOT tested actually. Please let me know if you find any issue. Fabio
From 058a59f3064eb88c8eaa9618abb037c501c24a74 Mon Sep 17 00:00:00 2001 From: Fabio D'Urso <[email protected]> Date: Sun, 2 Dec 2012 01:41:05 +0100 Subject: [PATCH] Fixed check_lexer on 32-bit systems --- qt4/tests/check_lexer.cpp | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/qt4/tests/check_lexer.cpp b/qt4/tests/check_lexer.cpp index 8611b8f..1ae849f 100644 --- a/qt4/tests/check_lexer.cpp +++ b/qt4/tests/check_lexer.cpp @@ -52,7 +52,7 @@ void TestLexer::testNumbers() lexer->getObj(&obj); QCOMPARE(obj.getType(), objInt); - QCOMPARE(obj.getInt(), (int)-2147483648); + QCOMPARE(obj.getInt(), -2147483647-1); obj.free(); lexer->getObj(&obj); @@ -62,7 +62,7 @@ void TestLexer::testNumbers() lexer->getObj(&obj); QCOMPARE(obj.getType(), objReal); - QCOMPARE(obj.getReal(), (double)-2147483649); + QCOMPARE(obj.getReal(), -2147483649.); obj.free(); lexer->getObj(&obj); -- 1.7.6.5
_______________________________________________ poppler mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/poppler
