| 1 |
/* |
| 2 |
* Copyright (C) Internet Systems Consortium, Inc. ("ISC") |
| 3 |
* |
| 4 |
* SPDX-License-Identifier: MPL-2.0 |
| 5 |
* |
| 6 |
* This Source Code Form is subject to the terms of the Mozilla Public |
| 7 |
* License, v. 2.0. If a copy of the MPL was not distributed with this |
| 8 |
* file, you can obtain one at https://mozilla.org/MPL/2.0/. |
| 9 |
* |
| 10 |
* See the COPYRIGHT file distributed with this work for additional |
| 11 |
* information regarding copyright ownership. |
| 12 |
*/ |
| 13 |
|
| 14 |
#include <inttypes.h> |
| 15 |
#include <sched.h> /* IWYU pragma: keep */ |
| 16 |
#include <setjmp.h> |
| 17 |
#include <stdarg.h> |
| 18 |
#include <stddef.h> |
| 19 |
#include <stdio.h> |
| 20 |
#include <stdlib.h> |
| 21 |
#include <string.h> |
| 22 |
|
| 23 |
#define UNIT_TESTING |
| 24 |
#include <cmocka.h> |
| 25 |
|
| 26 |
#include <isc/result.h> |
| 27 |
#include <isc/util.h> |
| 28 |
|
| 29 |
#include <tests/isc.h> |
| 30 |
|
| 31 |
/* convert result to identifier string */ |
| 32 |
ISC_RUN_TEST_IMPL(isc_result_toid) { |
| 33 |
const char *id; |
| 34 |
|
| 35 |
UNUSED(state); |
| 36 |
|
| 37 |
id = isc_result_toid(ISC_R_SUCCESS); |
| 38 |
assert_string_equal("ISC_R_SUCCESS", id); |
| 39 |
|
| 40 |
id = isc_result_toid(ISC_R_FAILURE); |
| 41 |
assert_string_equal("ISC_R_FAILURE", id); |
| 42 |
} |
| 43 |
|
| 44 |
/* convert result to description string */ |
| 45 |
ISC_RUN_TEST_IMPL(isc_result_totext) { |
| 46 |
const char *str; |
| 47 |
|
| 48 |
UNUSED(state); |
| 49 |
|
| 50 |
str = isc_result_totext(ISC_R_SUCCESS); |
| 51 |
assert_string_equal("success", str); |
| 52 |
|
| 53 |
str = isc_result_totext(ISC_R_FAILURE); |
| 54 |
assert_string_equal("failure", str); |
| 55 |
} |
| 56 |
|
| 57 |
ISC_TEST_LIST_START |
| 58 |
|
| 59 |
ISC_TEST_ENTRY(isc_result_toid) |
| 60 |
ISC_TEST_ENTRY(isc_result_totext) |
| 61 |
|
| 62 |
ISC_TEST_LIST_END |
| 63 |
|
| 64 |
ISC_TEST_MAIN |