1 /* $NetBSD: lex_test.c,v 1.3 2014/12/10 04:38:01 christos Exp $ */
2
3 /*
4 * Copyright (C) 2013 Internet Systems Consortium, Inc. ("ISC")
5 *
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.
9 *
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.
17 */
18
19 #include <config.h>
20
21 #include <atf-c.h>
22
23 #include <stdio.h>
24 #include <stdlib.h>
25 #include <string.h>
26 #include <unistd.h>
27
28 #include <isc/buffer.h>
29 #include <isc/lex.h>
30 #include <isc/mem.h>
31 #include <isc/util.h>
32
33 ATF_TC(lex);
ATF_TC_HEAD(lex,tc)34 ATF_TC_HEAD(lex, tc) {
35 atf_tc_set_md_var(tc, "descr", "check handling of 0xff");
36 }
ATF_TC_BODY(lex,tc)37 ATF_TC_BODY(lex, tc) {
38 isc_mem_t *mctx = NULL;
39 isc_result_t result;
40 isc_lex_t *lex = NULL;
41 isc_buffer_t death_buf;
42 isc_token_t token;
43
44 unsigned char death[] = { EOF, 'A' };
45
46 UNUSED(tc);
47
48 result = isc_mem_create(0, 0, &mctx);
49 ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
50
51 result = isc_lex_create(mctx, 1024, &lex);
52 ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
53
54 isc_buffer_init(&death_buf, &death[0], sizeof(death));
55 isc_buffer_add(&death_buf, sizeof(death));
56
57 result = isc_lex_openbuffer(lex, &death_buf);
58 ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
59
60 result = isc_lex_gettoken(lex, 0, &token);
61 ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
62 }
63
64 /*
65 * Main
66 */
ATF_TP_ADD_TCS(tp)67 ATF_TP_ADD_TCS(tp) {
68 ATF_TP_ADD_TC(tp, lex);
69 return (atf_no_error());
70 }
71
72