Skip to content

Commit

Permalink
Unit test: Error message if "localhost" cannot be resolved
Browse files Browse the repository at this point in the history
This seems to be a special case of container test environments.
  • Loading branch information
bel2125 committed Aug 29, 2021
1 parent 0d80b11 commit 9660ca5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
6 changes: 3 additions & 3 deletions examples/embedded_c/embedded_c.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
* License http://opensource.org/licenses/mit-license.php MIT License
*/

/* Note: This example ommits some error checking and input validation for a better
* clarity/readability of the code. Example codes undergo less quality management
* than the main source files of this project. */
/* Note: This example ommits some error checking and input validation for a
* better clarity/readability of the code. Example codes undergo less quality
* management than the main source files of this project. */

#ifdef NO_SSL
#define TEST_WITHOUT_SSL
Expand Down
8 changes: 6 additions & 2 deletions unittest/private.c
Original file line number Diff line number Diff line change
Expand Up @@ -698,9 +698,13 @@ START_TEST(test_parse_port_string)
vec.ptr = "localhost:123";
vec.len = strlen(vec.ptr);
ret = parse_port_string(&vec, &so, &ip_family);
ck_assert_int_eq(ret, 1);
if (ret != 1) {
ck_abort_msg("IP of localhost seems to be unknown on this system (%i)",
(int)ret);
}
if ((ip_family != 4) && (ip_family != 6)) {
ck_abort_msg("IP family must be 4 or 6 but is %i", (int)ip_family);
ck_abort_msg("IP family for localhost must be 4 or 6 but is %i",
(int)ip_family);
}
ck_assert_int_eq((int)htons(so.lsa.sin.sin_port), (int)123);
}
Expand Down

0 comments on commit 9660ca5

Please sign in to comment.