lex_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 #include <config.h>
00018 
00019 #include <atf-c.h>
00020 
00021 #include <stdio.h>
00022 #include <stdlib.h>
00023 #include <string.h>
00024 #include <unistd.h>
00025 
00026 #include <isc/buffer.h>
00027 #include <isc/lex.h>
00028 #include <isc/mem.h>
00029 #include <isc/util.h>
00030 
00031 ATF_TC(lex);
00032 ATF_TC_HEAD(lex, tc) {
00033         atf_tc_set_md_var(tc, "descr", "check handling of 0xff");
00034 }
00035 ATF_TC_BODY(lex, tc) {
00036         isc_mem_t *mctx = NULL;
00037         isc_result_t result;
00038         isc_lex_t *lex = NULL;
00039         isc_buffer_t death_buf;
00040         isc_token_t token;
00041 
00042         unsigned char death[] = { EOF, 'A' };
00043 
00044         UNUSED(tc);
00045 
00046         result = isc_mem_create(0, 0, &mctx);
00047         ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
00048 
00049         result = isc_lex_create(mctx, 1024, &lex);
00050         ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
00051 
00052         isc_buffer_init(&death_buf, &death[0], sizeof(death));
00053         isc_buffer_add(&death_buf, sizeof(death));
00054 
00055         result = isc_lex_openbuffer(lex, &death_buf);
00056         ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
00057 
00058         result = isc_lex_gettoken(lex, 0, &token);
00059         ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
00060 }
00061 
00062 /*
00063  * Main
00064  */
00065 ATF_TP_ADD_TCS(tp) {
00066         ATF_TP_ADD_TC(tp, lex);
00067         return (atf_no_error());
00068 }
00069 

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