@@ -302,7 +302,8 @@ class TestOther : public TestFixture {
302
302
TEST_CASE(knownPointerToBool);
303
303
TEST_CASE(iterateByValue);
304
304
305
- TEST_CASE(alwaysTrueFloating);
305
+ TEST_CASE(knownConditionFloating);
306
+ TEST_CASE(knownConditionPrefixed);
306
307
}
307
308
308
309
#define check(...) check_(__FILE__, __LINE__, __VA_ARGS__)
@@ -12888,7 +12889,7 @@ class TestOther : public TestFixture {
12888
12889
errout_str());
12889
12890
}
12890
12891
12891
- void alwaysTrueFloating ()
12892
+ void knownConditionFloating ()
12892
12893
{
12893
12894
check("void foo() {\n" // #11200
12894
12895
" float f = 1.0;\n"
@@ -12905,9 +12906,16 @@ class TestOther : public TestFixture {
12905
12906
" float f = 1.0;\n"
12906
12907
" if (f > +1.0) {}\n"
12907
12908
"}\n");
12908
- TODO_ASSERT_EQUALS (
12909
+ ASSERT_EQUALS (
12909
12910
"[test.cpp:2] -> [test.cpp:3]: (style) The comparison 'f > +1.0' is always false.\n",
12910
- "",
12911
+ errout_str());
12912
+
12913
+ check("void foo() {\n"
12914
+ " float f = 1.0;\n"
12915
+ " if (f < +1.0) {}\n"
12916
+ "}\n");
12917
+ ASSERT_EQUALS(
12918
+ "[test.cpp:2] -> [test.cpp:3]: (style) The comparison 'f < 1.0' is always false.\n",
12911
12919
errout_str());
12912
12920
12913
12921
check("void foo() {\n" // #11200
@@ -12925,9 +12933,16 @@ class TestOther : public TestFixture {
12925
12933
" float pf = +1.0;\n"
12926
12934
" if (pf > +1.0) {}\n"
12927
12935
"}\n");
12928
- TODO_ASSERT_EQUALS (
12936
+ ASSERT_EQUALS (
12929
12937
"[test.cpp:2] -> [test.cpp:3]: (style) The comparison 'pf > +1.0' is always false.\n",
12930
- "",
12938
+ errout_str());
12939
+
12940
+ check("void foo() {\n"
12941
+ " float pf = +1.0;\n"
12942
+ " if (pf < +1.0) {}\n"
12943
+ "}\n");
12944
+ ASSERT_EQUALS(
12945
+ "[test.cpp:2] -> [test.cpp:3]: (style) The comparison 'pf < 1.0' is always false.\n",
12931
12946
errout_str());
12932
12947
12933
12948
check("void foo() {\n" // #11200
@@ -12941,7 +12956,7 @@ class TestOther : public TestFixture {
12941
12956
"[test.cpp:2] -> [test.cpp:4]: (style) The comparison 'nf > -1.0' is always false.\n",
12942
12957
errout_str());
12943
12958
12944
- check("void foo() {\n" // #13506
12959
+ check("void foo() {\n" // #13508
12945
12960
" float nf = -1.0;\n"
12946
12961
" if (nf > +1.0) {}\n"
12947
12962
"}\n");
@@ -12984,6 +12999,25 @@ class TestOther : public TestFixture {
12984
12999
"",
12985
13000
errout_str());
12986
13001
}
13002
+
13003
+ void knownConditionPrefixed()
13004
+ {
13005
+ check("void foo() {\n"
13006
+ " int i = 1;\n"
13007
+ " if (i < +1) {}\n"
13008
+ "}\n");
13009
+ ASSERT_EQUALS(
13010
+ "[test.cpp:2] -> [test.cpp:3]: (style) The comparison 'i < 1' is always false.\n",
13011
+ errout_str());
13012
+
13013
+ check("void foo() {\n" // #13506
13014
+ " int i = 1;\n"
13015
+ " if (i > +1) {}\n"
13016
+ "}\n");
13017
+ ASSERT_EQUALS(
13018
+ "[test.cpp:2] -> [test.cpp:3]: (style) The comparison 'i > +1' is always false.\n",
13019
+ errout_str());
13020
+ }
12987
13021
};
12988
13022
12989
13023
REGISTER_TEST(TestOther)
0 commit comments