Skip to content

Commit 960862b

Browse files
authored
added tests for #11200 and #13508 (#7236)
1 parent 7002b45 commit 960862b

File tree

2 files changed

+79
-10
lines changed

2 files changed

+79
-10
lines changed

test/testcondition.cpp

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6377,6 +6377,57 @@ class TestCondition : public TestFixture {
63776377
ASSERT_EQUALS(
63786378
"[test.cpp:3]: (style) Condition 'nf>+1.0' is always false\n",
63796379
errout_str());
6380+
6381+
check("void foo() {\n" // #11200
6382+
" float f = 1.0;\n"
6383+
" if (f > -1.0) {}\n"
6384+
"}\n");
6385+
ASSERT_EQUALS(
6386+
"[test.cpp:3]: (style) Condition 'f>-1.0' is always true\n",
6387+
errout_str());
6388+
6389+
check("void foo() {\n" // #13508
6390+
" float f = 1.0;\n"
6391+
" if (f > 1.0) {}\n"
6392+
"}\n");
6393+
TODO_ASSERT_EQUALS(
6394+
"[test.cpp:3]: (style) Condition 'f>1.0' is always true\n",
6395+
"",
6396+
errout_str());
6397+
6398+
check("void foo() {\n" // #11200
6399+
" float pf = +1.0;\n"
6400+
" if (pf > -1.0) {}\n"
6401+
"}\n");
6402+
ASSERT_EQUALS(
6403+
"[test.cpp:3]: (style) Condition 'pf>-1.0' is always true\n",
6404+
errout_str());
6405+
6406+
check("void foo() {\n" // #13508
6407+
" float pf = +1.0;\n"
6408+
" if (pf > 1.0) {}\n"
6409+
"}\n");
6410+
TODO_ASSERT_EQUALS(
6411+
"[test.cpp:3]: (style) Condition 'pf>1.0' is always true\n",
6412+
"",
6413+
errout_str());
6414+
6415+
check("void foo() {\n" // #11200
6416+
" float nf = -1.0;\n"
6417+
" if (nf > 1.0) {}\n"
6418+
"}\n");
6419+
ASSERT_EQUALS(
6420+
"[test.cpp:3]: (style) Condition 'nf>1.0' is always false\n",
6421+
errout_str());
6422+
6423+
check("void foo() {\n" // / #13508
6424+
" float nf = -1.0;\n"
6425+
" if (nf > -1.0) {}\n"
6426+
"}\n");
6427+
TODO_ASSERT_EQUALS(
6428+
"[test.cpp:3]: (style) Condition 'nf>-1.0' is always false\n",
6429+
"",
6430+
errout_str());
63806431
}
63816432
};
63826433

test/testother.cpp

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12894,12 +12894,18 @@ class TestOther : public TestFixture {
1289412894
check("void foo() {\n" // #11200
1289512895
" float f = 1.0;\n"
1289612896
" if (f > 1.0) {}\n"
12897+
"}\n");
12898+
ASSERT_EQUALS(
12899+
"[test.cpp:2] -> [test.cpp:3]: (style) The comparison 'f > 1.0' is always false.\n",
12900+
errout_str());
12901+
12902+
check("void foo() {\n" // #13508
12903+
" float f = 1.0;\n"
1289712904
" if (f > -1.0) {}\n"
1289812905
"}\n");
1289912906
TODO_ASSERT_EQUALS(
12900-
"[test.cpp:2] -> [test.cpp:3]: (style) The comparison 'f > 1.0' is always false.\n"
12901-
"[test.cpp:2] -> [test.cpp:4]: (style) The comparison 'f > -1.0' is always false.\n",
12902-
"[test.cpp:2] -> [test.cpp:3]: (style) The comparison 'f > 1.0' is always false.\n",
12907+
"[test.cpp:2] -> [test.cpp:3]: (style) The comparison 'f > -1.0' is always false.\n",
12908+
"",
1290312909
errout_str());
1290412910

1290512911
check("void foo() {\n" // #13506
@@ -12921,12 +12927,18 @@ class TestOther : public TestFixture {
1292112927
check("void foo() {\n" // #11200
1292212928
" float pf = +1.0;\n"
1292312929
" if (pf > 1.0) {}\n"
12930+
"}\n");
12931+
ASSERT_EQUALS(
12932+
"[test.cpp:2] -> [test.cpp:3]: (style) The comparison 'pf > 1.0' is always false.\n",
12933+
errout_str());
12934+
12935+
check("void foo() {\n" // #13508
12936+
" float pf = +1.0;\n"
1292412937
" if (pf > -1.0) {}\n"
1292512938
"}\n");
1292612939
TODO_ASSERT_EQUALS(
12927-
"[test.cpp:2] -> [test.cpp:3]: (style) The comparison 'pf > 1.0' is always false.\n"
12928-
"[test.cpp:2] -> [test.cpp:4]: (style) The comparison 'pf > -1.0' is always false.\n",
12929-
"[test.cpp:2] -> [test.cpp:3]: (style) The comparison 'pf > 1.0' is always false.\n",
12940+
"[test.cpp:2] -> [test.cpp:3]: (style) The comparison 'pf > -1.0' is always false.\n",
12941+
"",
1293012942
errout_str());
1293112943

1293212944
check("void foo() {\n" // #13506
@@ -12947,13 +12959,19 @@ class TestOther : public TestFixture {
1294712959

1294812960
check("void foo() {\n" // #11200
1294912961
" float nf = -1.0;\n"
12950-
" if (nf > 1.0) {}\n"
1295112962
" if (nf > -1.0) {}\n"
1295212963
"}\n");
12964+
ASSERT_EQUALS(
12965+
"[test.cpp:2] -> [test.cpp:3]: (style) The comparison 'nf > -1.0' is always false.\n",
12966+
errout_str());
12967+
12968+
check("void foo() {\n" // #13508
12969+
" float nf = -1.0;\n"
12970+
" if (nf > 1.0) {}\n"
12971+
"}\n");
1295312972
TODO_ASSERT_EQUALS(
12954-
"[test.cpp:2] -> [test.cpp:3]: (style) The comparison 'nf > 1.0' is always false.\n"
12955-
"[test.cpp:2] -> [test.cpp:4]: (style) The comparison 'nf > -1.0' is always false.\n",
12956-
"[test.cpp:2] -> [test.cpp:4]: (style) The comparison 'nf > -1.0' is always false.\n",
12973+
"[test.cpp:2] -> [test.cpp:3]: (style) The comparison 'nf > 1.0' is always false.\n",
12974+
"",
1295712975
errout_str());
1295812976

1295912977
check("void foo() {\n" // #13508

0 commit comments

Comments
 (0)