File tree Expand file tree Collapse file tree 2 files changed +12
-0
lines changed Expand file tree Collapse file tree 2 files changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -130,6 +130,7 @@ bson_strerror_r (int err_code, /* IN */
130
130
// required) by the POSIX spec (see:
131
131
// https://pubs.opengroup.org/onlinepubs/9699919799/functions/strerror.html#tag_16_574_08).
132
132
(void ) strerror_r (err_code , buf , buflen );
133
+ ret = buf ;
133
134
#elif defined(_XOPEN_SOURCE ) && _XOPEN_SOURCE >= 700
134
135
// The behavior (of `strerror_l`) is undefined if the locale argument to
135
136
// `strerror_l()` is the special locale object LC_GLOBAL_LOCALE or is not a
Original file line number Diff line number Diff line change @@ -30,9 +30,20 @@ test_bson_error_basic (void)
30
30
ASSERT_CMPUINT32 (error .code , = = , 456u );
31
31
}
32
32
33
+ static void
34
+ test_bson_strerror_r (void )
35
+ {
36
+ FILE * f = fopen ("file-that-does-not-exist" , "r" );
37
+ ASSERT (!f );
38
+ char errmsg_buf [BSON_ERROR_BUFFER_SIZE ];
39
+ char * errmsg = bson_strerror_r (errno , errmsg_buf , sizeof errmsg_buf );
40
+ // Check a message is returned. Do not check platform-dependent contents:
41
+ ASSERT (errmsg );
42
+ }
33
43
34
44
void
35
45
test_bson_error_install (TestSuite * suite )
36
46
{
37
47
TestSuite_Add (suite , "/bson/error/basic" , test_bson_error_basic );
48
+ TestSuite_Add (suite , "/bson/strerror_r" , test_bson_strerror_r );
38
49
}
You can’t perform that action at this time.
0 commit comments