safe_test.c

Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2013  Internet Systems Consortium, Inc. ("ISC")
00003  *
00004  * Permission to use, copy, modify, and/or distribute this software for any
00005  * purpose with or without fee is hereby granted, provided that the above
00006  * copyright notice and this permission notice appear in all copies.
00007  *
00008  * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
00009  * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
00010  * AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
00011  * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
00012  * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
00013  * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
00014  * PERFORMANCE OF THIS SOFTWARE.
00015  */
00016 
00017 /* $Id$ */
00018 
00019 /* ! \file */
00020 
00021 #include <config.h>
00022 
00023 #include <atf-c.h>
00024 
00025 #include <stdio.h>
00026 #include <string.h>
00027 
00028 #include <isc/safe.h>
00029 #include <isc/util.h>
00030 
00031 ATF_TC(isc_safe_memcmp);
00032 ATF_TC_HEAD(isc_safe_memcmp, tc) {
00033         atf_tc_set_md_var(tc, "descr", "safe memcmp()");
00034 }
00035 ATF_TC_BODY(isc_safe_memcmp, tc) {
00036         UNUSED(tc);
00037 
00038         ATF_CHECK(isc_safe_memcmp("test", "test", 4));
00039         ATF_CHECK(!isc_safe_memcmp("test", "tesc", 4));
00040         ATF_CHECK(isc_safe_memcmp("\x00\x00\x00\x00", "\x00\x00\x00\x00", 4));
00041         ATF_CHECK(!isc_safe_memcmp("\x00\x00\x00\x00", "\x00\x00\x00\x01", 4));
00042         ATF_CHECK(!isc_safe_memcmp("\x00\x00\x00\x02", "\x00\x00\x00\x00", 4));
00043 }
00044 
00045 /*
00046  * Main
00047  */
00048 ATF_TP_ADD_TCS(tp) {
00049         ATF_TP_ADD_TC(tp, isc_safe_memcmp);
00050         return (atf_no_error());
00051 }
00052 

Generated on Tue Apr 28 17:41:05 2015 by Doxygen 1.5.4 for BIND9 Internals 9.11.0pre-alpha