Remove building with NOCRYPTO option
[minix.git] / external / bsd / bind / dist / lib / isc / tests / counter_test.c
blob74a1926abf07c1548b178710ec8c58827cceaa64
1 /* $NetBSD: counter_test.c,v 1.1.1.2 2014/12/10 03:34:44 christos Exp $ */
3 /*
4 * Copyright (C) 2014 Internet Systems Consortium, Inc. ("ISC")
6 * Permission to use, copy, modify, and/or distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above
8 * copyright notice and this permission notice appear in all copies.
10 * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
11 * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
12 * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
13 * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
14 * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
15 * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
16 * PERFORMANCE OF THIS SOFTWARE.
19 #include <config.h>
20 #include <stdlib.h>
22 #include <atf-c.h>
24 #include <isc/counter.h>
25 #include <isc/result.h>
27 #include "isctest.h"
29 ATF_TC(isc_counter);
30 ATF_TC_HEAD(isc_counter, tc) {
31 atf_tc_set_md_var(tc, "descr", "isc counter object");
33 ATF_TC_BODY(isc_counter, tc) {
34 isc_result_t result;
35 isc_counter_t *counter = NULL;
36 int i;
38 result = isc_test_begin(NULL, ISC_TRUE);
39 ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
41 result = isc_counter_create(mctx, 0, &counter);
42 ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
44 for (i = 0; i < 10; i++) {
45 result = isc_counter_increment(counter);
46 ATF_CHECK_EQ(result, ISC_R_SUCCESS);
49 ATF_CHECK_EQ(isc_counter_used(counter), 10);
51 isc_counter_setlimit(counter, 15);
52 for (i = 0; i < 10; i++) {
53 result = isc_counter_increment(counter);
54 if (result != ISC_R_SUCCESS)
55 break;
58 ATF_CHECK_EQ(isc_counter_used(counter), 15);
60 isc_counter_detach(&counter);
61 isc_test_end();
65 * Main
67 ATF_TP_ADD_TCS(tp) {
68 ATF_TP_ADD_TC(tp, isc_counter);
69 return (atf_no_error());