From 0c95d388026349fe6ac6bf718eff007953ac1f7e Mon Sep 17 00:00:00 2001 From: firewave Date: Thu, 16 Jan 2025 20:12:30 +0100 Subject: [PATCH] added tests for #11200 and #13508 --- test/testcondition.cpp | 51 ++++++++++++++++++++++++++++++++++++++++++ test/testother.cpp | 38 ++++++++++++++++++++++--------- 2 files changed, 79 insertions(+), 10 deletions(-) diff --git a/test/testcondition.cpp b/test/testcondition.cpp index c36a9f876d9..374119eb67e 100644 --- a/test/testcondition.cpp +++ b/test/testcondition.cpp @@ -6362,6 +6362,57 @@ class TestCondition : public TestFixture { ASSERT_EQUALS( "[test.cpp:3]: (style) Condition 'nf>+1.0' is always false\n", errout_str()); + + check("void foo() {\n" // #11200 + " float f = 1.0;\n" + " if (f > -1.0) {}\n" + "}\n"); + ASSERT_EQUALS( + "[test.cpp:3]: (style) Condition 'f>-1.0' is always true\n", + errout_str()); + + check("void foo() {\n" // #13508 + " float f = 1.0;\n" + " if (f > 1.0) {}\n" + "}\n"); + TODO_ASSERT_EQUALS( + "[test.cpp:3]: (style) Condition 'f>1.0' is always true\n", + "", + errout_str()); + + check("void foo() {\n" // #11200 + " float pf = +1.0;\n" + " if (pf > -1.0) {}\n" + "}\n"); + ASSERT_EQUALS( + "[test.cpp:3]: (style) Condition 'pf>-1.0' is always true\n", + errout_str()); + + check("void foo() {\n" // #13508 + " float pf = +1.0;\n" + " if (pf > 1.0) {}\n" + "}\n"); + TODO_ASSERT_EQUALS( + "[test.cpp:3]: (style) Condition 'pf>1.0' is always true\n", + "", + errout_str()); + + check("void foo() {\n" // #11200 + " float nf = -1.0;\n" + " if (nf > 1.0) {}\n" + "}\n"); + ASSERT_EQUALS( + "[test.cpp:3]: (style) Condition 'nf>1.0' is always false\n", + errout_str()); + + check("void foo() {\n" // / #13508 + " float nf = -1.0;\n" + " if (nf > -1.0) {}\n" + "}\n"); + TODO_ASSERT_EQUALS( + "[test.cpp:3]: (style) Condition 'nf>-1.0' is always false\n", + "", + errout_str()); } }; diff --git a/test/testother.cpp b/test/testother.cpp index 27a715de81e..f71d93151e4 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -12894,12 +12894,18 @@ class TestOther : public TestFixture { check("void foo() {\n" // #11200 " float f = 1.0;\n" " if (f > 1.0) {}\n" + "}\n"); + ASSERT_EQUALS( + "[test.cpp:2] -> [test.cpp:3]: (style) The comparison 'f > 1.0' is always false.\n", + errout_str()); + + check("void foo() {\n" // #13508 + " float f = 1.0;\n" " if (f > -1.0) {}\n" "}\n"); TODO_ASSERT_EQUALS( - "[test.cpp:2] -> [test.cpp:3]: (style) The comparison 'f > 1.0' is always false.\n" - "[test.cpp:2] -> [test.cpp:4]: (style) The comparison 'f > -1.0' is always false.\n", - "[test.cpp:2] -> [test.cpp:3]: (style) The comparison 'f > 1.0' is always false.\n", + "[test.cpp:2] -> [test.cpp:3]: (style) The comparison 'f > -1.0' is always false.\n", + "", errout_str()); check("void foo() {\n" // #13506 @@ -12921,12 +12927,18 @@ class TestOther : public TestFixture { check("void foo() {\n" // #11200 " float pf = +1.0;\n" " if (pf > 1.0) {}\n" + "}\n"); + ASSERT_EQUALS( + "[test.cpp:2] -> [test.cpp:3]: (style) The comparison 'pf > 1.0' is always false.\n", + errout_str()); + + check("void foo() {\n" // #13508 + " float pf = +1.0;\n" " if (pf > -1.0) {}\n" "}\n"); TODO_ASSERT_EQUALS( - "[test.cpp:2] -> [test.cpp:3]: (style) The comparison 'pf > 1.0' is always false.\n" - "[test.cpp:2] -> [test.cpp:4]: (style) The comparison 'pf > -1.0' is always false.\n", - "[test.cpp:2] -> [test.cpp:3]: (style) The comparison 'pf > 1.0' is always false.\n", + "[test.cpp:2] -> [test.cpp:3]: (style) The comparison 'pf > -1.0' is always false.\n", + "", errout_str()); check("void foo() {\n" // #13506 @@ -12947,13 +12959,19 @@ class TestOther : public TestFixture { check("void foo() {\n" // #11200 " float nf = -1.0;\n" - " if (nf > 1.0) {}\n" " if (nf > -1.0) {}\n" "}\n"); + ASSERT_EQUALS( + "[test.cpp:2] -> [test.cpp:3]: (style) The comparison 'nf > -1.0' is always false.\n", + errout_str()); + + check("void foo() {\n" // #13508 + " float nf = -1.0;\n" + " if (nf > 1.0) {}\n" + "}\n"); TODO_ASSERT_EQUALS( - "[test.cpp:2] -> [test.cpp:3]: (style) The comparison 'nf > 1.0' is always false.\n" - "[test.cpp:2] -> [test.cpp:4]: (style) The comparison 'nf > -1.0' is always false.\n", - "[test.cpp:2] -> [test.cpp:4]: (style) The comparison 'nf > -1.0' is always false.\n", + "[test.cpp:2] -> [test.cpp:3]: (style) The comparison 'nf > 1.0' is always false.\n", + "", errout_str()); check("void foo() {\n" // #13508