[poppler] [PATCH] make test (check_lexer) failure
fabiodurso at hotmail.it
Sat Dec 1 17:14:56 PST 2012
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
Actual (obj.getReal()): -2.14748e+09
Expected ((double)-2147483649): 2.14748e+09
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.
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 992 bytes
Desc: not available
More information about the poppler