Reify bytevector? in the correct module
[bpt/guile.git] / test-suite / standalone / test-scm-take-u8vector.c
CommitLineData
f538a070
LC
1/* Copyright (C) 2009 Free Software Foundation, Inc.
2 *
3 * This library is free software; you can redistribute it and/or
4 * modify it under the terms of the GNU Lesser General Public License
5 * as published by the Free Software Foundation; either version 3 of
6 * the License, or (at your option) any later version.
7 *
8 * This library is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public
14 * License along with this library; if not, write to the Free Software
15 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
16 * 02110-1301 USA
17 */
18
19/* Make sure `scm_take_u8vector ()' returns a u8vector that actually uses the
20 provided storage. */
21
22
23#ifdef HAVE_CONFIG_H
24# include <config.h>
25#endif
26
27#include <libguile.h>
28
29#include <stdlib.h>
30
31\f
32static void *
33do_test (void *result)
34{
35#define LEN 123
36 SCM u8v;
37 scm_t_uint8 *data;
38 scm_t_array_handle handle;
39
40 data = scm_malloc (LEN);
41 u8v = scm_take_u8vector (data, LEN);
42
43 scm_array_get_handle (u8v, &handle);
44
45 if (scm_array_handle_u8_writable_elements (&handle) == data
46 && scm_array_handle_u8_elements (&handle) == data)
47 * (int *) result = EXIT_SUCCESS;
48 else
49 * (int *) result = EXIT_FAILURE;
50
51 scm_array_handle_release (&handle);
52
53 return NULL;
54#undef LEN
55}
56
57int
58main (int argc, char *argv[])
59{
60 int result;
61
62 scm_with_guile (do_test, &result);
63
64 return result;
65}