Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
L
libzmq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
libzmq
Commits
27f9be11
Unverified
Commit
27f9be11
authored
Jun 12, 2019
by
Luca Boccassi
Committed by
GitHub
Jun 12, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3542 from guillon/fix-test-asserts
Problem: test assertions not reporting the right line number
parents
aa6b6440
f2030643
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
20 deletions
+21
-20
testutil_unity.cpp
tests/testutil_unity.cpp
+10
-10
testutil_unity.hpp
tests/testutil_unity.hpp
+11
-10
No files found.
tests/testutil_unity.cpp
View file @
27f9be11
...
...
@@ -37,7 +37,8 @@
int
test_assert_success_message_errno_helper
(
int
rc_
,
const
char
*
msg_
,
const
char
*
expr_
)
const
char
*
expr_
,
int
line
)
{
if
(
rc_
==
-
1
)
{
char
buffer
[
512
];
...
...
@@ -47,14 +48,15 @@ int test_assert_success_message_errno_helper (int rc_,
"%s failed%s%s%s, errno = %i (%s)"
,
expr_
,
msg_
?
" (additional info: "
:
""
,
msg_
?
msg_
:
""
,
msg_
?
")"
:
""
,
zmq_errno
(),
zmq_strerror
(
zmq_errno
()));
TEST_FAIL_MESSAGE
(
buffer
);
UNITY_TEST_FAIL
(
line
,
buffer
);
}
return
rc_
;
}
int
test_assert_success_message_raw_errno_helper
(
int
rc_
,
const
char
*
msg_
,
const
char
*
expr_
)
const
char
*
expr_
,
int
line
)
{
if
(
rc_
==
-
1
)
{
#if defined ZMQ_HAVE_WINDOWS
...
...
@@ -69,15 +71,13 @@ int test_assert_success_message_raw_errno_helper (int rc_,
snprintf
(
buffer
,
sizeof
(
buffer
)
-
1
,
"%s failed%s%s%s, errno = %i"
,
expr_
,
msg_
?
" (additional info: "
:
""
,
msg_
?
msg_
:
""
,
msg_
?
")"
:
""
,
current_errno
);
TEST_FAIL_MESSAGE
(
buffer
);
UNITY_TEST_FAIL
(
line
,
buffer
);
}
return
rc_
;
}
int
test_assert_failure_message_raw_errno_helper
(
int
rc_
,
int
expected_errno_
,
const
char
*
msg_
,
const
char
*
expr_
)
int
test_assert_failure_message_raw_errno_helper
(
int
rc_
,
int
expected_errno_
,
const
char
*
msg_
,
const
char
*
expr_
,
int
line
)
{
char
buffer
[
512
];
buffer
[
sizeof
(
buffer
)
-
1
]
=
...
...
@@ -88,7 +88,7 @@ int test_assert_failure_message_raw_errno_helper (int rc_,
"errno = %i, actual return value = %i"
,
expr_
,
msg_
?
" (additional info: "
:
""
,
msg_
?
msg_
:
""
,
msg_
?
")"
:
""
,
expected_errno_
,
rc_
);
TEST_FAIL_MESSAGE
(
buffer
);
UNITY_TEST_FAIL
(
line
,
buffer
);
}
else
{
#if defined ZMQ_HAVE_WINDOWS
int
current_errno
=
WSAGetLastError
();
...
...
@@ -102,7 +102,7 @@ int test_assert_failure_message_raw_errno_helper (int rc_,
expr_
,
msg_
?
" (additional info: "
:
""
,
msg_
?
msg_
:
""
,
msg_
?
")"
:
""
,
expected_errno_
,
current_errno
);
TEST_FAIL_MESSAGE
(
buffer
);
UNITY_TEST_FAIL
(
line
,
buffer
);
}
}
return
rc_
;
...
...
tests/testutil_unity.hpp
View file @
27f9be11
...
...
@@ -40,16 +40,16 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
int
test_assert_success_message_errno_helper
(
int
rc_
,
const
char
*
msg_
,
const
char
*
expr_
);
const
char
*
expr_
,
int
line
);
int
test_assert_success_message_raw_errno_helper
(
int
rc_
,
const
char
*
msg_
,
const
char
*
expr_
);
const
char
*
expr_
,
int
line
);
int
test_assert_failure_message_raw_errno_helper
(
int
rc_
,
int
expected_errno_
,
const
char
*
msg_
,
const
char
*
expr_
);
int
test_assert_failure_message_raw_errno_helper
(
int
rc_
,
int
expected_errno_
,
const
char
*
msg_
,
const
char
*
expr_
,
int
line
);
/////////////////////////////////////////////////////////////////////////////
// Macros extending Unity's TEST_ASSERT_* macros in a similar fashion.
...
...
@@ -70,7 +70,7 @@ int test_assert_failure_message_raw_errno_helper (int rc_,
// determined by zmq_errno(), and the additional 'msg'.
// In case of success, the result of the macro is the result of 'expr'.
#define TEST_ASSERT_SUCCESS_MESSAGE_ERRNO(expr, msg) \
test_assert_success_message_errno_helper (expr, msg, #expr)
test_assert_success_message_errno_helper (expr, msg, #expr
, __LINE__
)
// Asserts that the libzmq API 'expr' is successful. In case of a failure, the
// assertion message includes the literal 'expr' and the error code.
...
...
@@ -81,7 +81,7 @@ int test_assert_failure_message_raw_errno_helper (int rc_,
// If an additional message should be displayed in case of a failure, use
// TEST_ASSERT_SUCCESS_MESSAGE_ERRNO.
#define TEST_ASSERT_SUCCESS_ERRNO(expr) \
test_assert_success_message_errno_helper (expr, NULL, #expr)
test_assert_success_message_errno_helper (expr, NULL, #expr
, __LINE__
)
// Asserts that the socket API 'expr' is successful. In case of a failure, the
// assertion message includes the literal 'expr' and the error code.
...
...
@@ -89,14 +89,15 @@ int test_assert_failure_message_raw_errno_helper (int rc_,
// TEST_ASSERT_SUCCESS_RAW_ERRNO (send (fd, buffer, 64, 0));
// In case of success, the result of the macro is the result of 'expr'.
#define TEST_ASSERT_SUCCESS_RAW_ERRNO(expr) \
test_assert_success_message_raw_errno_helper (expr, NULL, #expr)
test_assert_success_message_raw_errno_helper (expr, NULL, #expr
, __LINE__
)
// Asserts that the socket API 'expr' is not successful, and the error code is
// 'error_code'. In case of an unexpected succces, or a failure with an
// unexpected error code, the assertion message includes the literal 'expr'
// and, in case of a failure, the actual error code.
#define TEST_ASSERT_FAILURE_RAW_ERRNO(error_code, expr) \
test_assert_failure_message_raw_errno_helper (expr, error_code, NULL, #expr)
test_assert_failure_message_raw_errno_helper (expr, error_code, NULL, \
#expr, __LINE__)
// Asserts that the libzmq API 'expr' is not successful, and the error code is
// 'error_code'. In case of an unexpected succces, or a failure with an
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment