4298d3e095d536528271e7c3434555d0e022e1b1
[yaz-moved-to-github.git] / test / test_zgdu.c
1 /* This file is part of the YAZ toolkit.
2  * Copyright (C) 1995-2013 Index Data
3  * See the file LICENSE for details.
4  */
5 #if HAVE_CONFIG_H
6 #include <config.h>
7 #endif
8
9 #include <stdlib.h>
10 #include <string.h>
11 #include <stdio.h>
12
13 #include <yaz/test.h>
14 #include <yaz/comstack.h>
15 #include <yaz/tcpip.h>
16 #include <yaz/zgdu.h>
17
18 static void tst_http_response(void)
19 {
20     {
21         /* response, content  */
22         const char *http_buf =
23             /*123456789012345678 */
24             "HTTP/1.1 200 OK\r\n"
25             "Content-Length: 2\r\n"
26             "\r\n"
27             "12";
28
29         int r;
30         Z_GDU *zgdu;
31         ODR odr = odr_createmem(ODR_DECODE);
32         odr_setbuf(odr, (char *) http_buf, strlen(http_buf), 0);
33         r = z_GDU(odr, &zgdu, 0, 0);
34         YAZ_CHECK(r);
35         if (r)
36         {
37             YAZ_CHECK_EQ(zgdu->which, Z_GDU_HTTP_Response);
38         }
39         odr_destroy(odr);
40     }
41 }
42
43
44 int main (int argc, char **argv)
45 {
46     YAZ_CHECK_INIT(argc, argv);
47     YAZ_CHECK_LOG();
48     tst_http_response();
49     YAZ_CHECK_TERM;
50 }
51
52 /*
53  * Local variables:
54  * c-basic-offset: 4
55  * c-file-style: "Stroustrup"
56  * indent-tabs-mode: nil
57  * End:
58  * vim: shiftwidth=4 tabstop=8 expandtab
59  */
60