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