Skip to content

Commit

Permalink
added tests for #11200 and #13508 (#7236)
Browse files Browse the repository at this point in the history
  • Loading branch information
firewave authored Jan 19, 2025
1 parent 7002b45 commit 960862b
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 10 deletions.
51 changes: 51 additions & 0 deletions test/testcondition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6377,6 +6377,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());
}
};

Expand Down
38 changes: 28 additions & 10 deletions test/testother.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 960862b

Please sign in to comment.