Package: grantlee / 0.4.0-2

variantIsTrue-float-fix.diff Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
Author: Pino Toscano <toscano.pino@tiscali.it>
Description: Fix variantIsTrue for float variants
 The test data for TestDefaultTags::testIfTag() has been expaded to
 include if-truthiness data explicitly for double and float values,
 so the they can be both tested no matter what qreal is.
Last-Update: 2013-12-08
Forwarded: https://www.gitorious.org/grantlee/grantlee/merge_requests/10

--- a/templates/tests/testdefaulttags.cpp
+++ b/templates/tests/testdefaulttags.cpp
@@ -617,6 +617,20 @@ void TestDefaultTags::testIfTag_data()
   dict.insert( QLatin1String( "var" ), r );
   QTest::newRow( "if-truthiness10" ) << QString::fromLatin1( "{% if var %}Yes{% else %}No{% endif %}" ) << dict << QString::fromLatin1( "Yes" ) << NoError;
 
+  double d = 0.0;
+  dict.insert( QLatin1String( "var" ), d );
+  QTest::newRow( "if-truthiness11" ) << QString::fromLatin1( "{% if var %}Yes{% else %}No{% endif %}" ) << dict << QString::fromLatin1( "No" ) << NoError;
+  d = 7.1;
+  dict.insert( QLatin1String( "var" ), d );
+  QTest::newRow( "if-truthiness12" ) << QString::fromLatin1( "{% if var %}Yes{% else %}No{% endif %}" ) << dict << QString::fromLatin1( "Yes" ) << NoError;
+
+  float f = 0.0;
+  dict.insert( QLatin1String( "var" ), f );
+  QTest::newRow( "if-truthiness13" ) << QString::fromLatin1( "{% if var %}Yes{% else %}No{% endif %}" ) << dict << QString::fromLatin1( "No" ) << NoError;
+  f = 7.1;
+  dict.insert( QLatin1String( "var" ), f );
+  QTest::newRow( "if-truthiness14" ) << QString::fromLatin1( "{% if var %}Yes{% else %}No{% endif %}" ) << dict << QString::fromLatin1( "Yes" ) << NoError;
+
   dict.clear();
   QTest::newRow( "if-tag-badarg01" ) << QString::fromLatin1( "{% if x|default_if_none:y %}yes{% endif %}" ) << dict << QString() << NoError;