Skip to content

Commit a718c2e

Browse files
Update testfunctions.cpp
1 parent 06739d1 commit a718c2e

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

‎test/testfunctions.cpp‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ class TestFunctions : public TestFixture {
5959

6060
// Invalid function argument
6161
TEST_CASE(invalidFunctionArg1);
62+
TEST_CASE(invalidFunctionArgErrorPath);
6263

6364
// Math function usage
6465
TEST_CASE(mathfunctionCall_fmod);
@@ -793,6 +794,22 @@ class TestFunctions : public TestFixture {
793794
ASSERT_EQUALS("", errout_str());
794795
}
795796

797+
void invalidFunctionArgErrorPath() {
798+
setMultiline();
799+
Settings s = settings;
800+
s.templateLocation = "{file}:{line}:note:{info}\n";
801+
check("double f(bool b) {\n"
802+
" double d = -1.0;\n"
803+
" if (b)\n"
804+
" return d;\n"
805+
" return std::log(d);\n"
806+
"}\n", s);
807+
ASSERT_EQUALS("[test.cpp:5:21]: warning: Invalid std::log() argument nr 1. The value is -1 but the valid values are '4.94066e-324:'. [invalidFunctionArg]\n"
808+
"[test.cpp:2:18]: note: Assignment 'd=-1.0', assigned value is -1.0\n"
809+
"[test.cpp:3:9]: note: Assuming condition is false\n"
810+
"[test.cpp:5:21]: note: Invalid argument\n", errout_str());
811+
}
812+
796813
void mathfunctionCall_sqrt() {
797814
// sqrt, sqrtf, sqrtl
798815
check("void foo()\n"

0 commit comments

Comments
 (0)