Bump year
[yaz-moved-to-github.git] / test / test_shared_ptr.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
6 /**
7  * \file test_shared_ptr.c
8  * \brief test shared pointer
9  */
10
11 #if HAVE_CONFIG_H
12 #include <config.h>
13 #endif
14
15 #include <stdio.h>
16 #include <stdlib.h>
17 #include <string.h>
18
19 #include <yaz/shptr.h>
20 #include <yaz/wrbuf.h>
21 #include <yaz/test.h>
22
23 YAZ_SHPTR_TYPE(WRBUF)
24
25 static void test(void)
26 {
27     WRBUF w = wrbuf_alloc();
28
29     WRBUF_shptr_t t = 0;
30
31     YAZ_SHPTR_INIT(t, w);
32     YAZ_CHECK(t);
33
34     YAZ_SHPTR_INC(t);
35     YAZ_CHECK(t);
36
37     YAZ_SHPTR_DEC(t, wrbuf_destroy);
38     YAZ_CHECK(t);
39
40     YAZ_SHPTR_DEC(t, wrbuf_destroy);
41     YAZ_CHECK(!t);
42 }
43
44 int main (int argc, char **argv)
45 {
46     YAZ_CHECK_INIT(argc, argv);
47     test();
48     YAZ_CHECK_TERM;
49 }
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