First set of licensing changes
[mono.git] / mono / unit-tests / test-mono-handle.c
1 /*
2  * test-mono-handle: tests for MonoHandle and MonoHandleArena
3  *
4  * Authors:
5  *   Aleksey Kliger <aleksey@xamarin.com>
6  *
7  * Copyright 2015 Xamarin, Inc. (www.xamarin.com)
8  * Licensed under the MIT license. See LICENSE file in the project root for full license information.
9  */
10
11 #include <config.h>
12 #include <glib.h>
13 #include <mono/metadata/handle.h>
14
15 static void
16 test2_arena_push_pop ()
17 {
18         MonoHandleArena *top = NULL;
19
20         MonoHandleArena *new_arena1 = g_malloc0 (mono_handle_arena_size ());
21         mono_handle_arena_stack_push (&top, new_arena1);
22
23         MonoHandleArena *new_arena2 = g_malloc0 (mono_handle_arena_size ());
24
25         mono_handle_arena_stack_push (&top, new_arena2);
26
27         g_assert (top == new_arena2);
28
29         mono_handle_arena_stack_pop (&top, new_arena2);
30
31         g_free (new_arena2);
32
33         g_assert (top == new_arena1);
34
35         mono_handle_arena_stack_pop (&top, new_arena1);
36
37         g_assert (top == NULL);
38         
39         g_free (new_arena1);
40 }
41
42
43
44 int
45 main (int argc, const char* argv[])
46 {
47         test2_arena_push_pop ();
48
49         return 0;
50 }