Compile fixes.
[SquirrelJME.git] / nanocoat / tests / testTraversePutOverfill.c
blob499718933833997139f9641bd266f71f408a1c41
1 /* -*- Mode: C; indent-tabs-mode: t; tab-width: 4 -*-
2 // ---------------------------------------------------------------------------
3 // SquirrelJME
4 // Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
5 // ---------------------------------------------------------------------------
6 // SquirrelJME is under the Mozilla Public License Version 2.0.
7 // See license.mkd for licensing and copyright information.
8 // -------------------------------------------------------------------------*/
10 #include <string.h>
12 #include "test.h"
13 #include "proto.h"
14 #include "mock.h"
15 #include "unit.h"
17 #include "sjme/traverse.h"
18 #include "testTraverse.h"
20 /**
21 * Tests filling the tree past the maximum.
23 * @since 2024/09/02
25 SJME_TEST_DECLARE(testTraversePutOverfill)
27 sjme_traverse_test_data traverse;
28 test_data value;
29 sjme_jint i;
31 /* Setup traverse. */
32 traverse = NULL;
33 if (sjme_error_is(test->error = sjme_traverse_new(test->pool,
34 &traverse, MAX_ELEMENTS, test_data, 0)) || traverse == NULL)
35 return sjme_unit_fail(test, "Could not create traverse?");
37 /* Force creation of 32 nodes. */
38 memset(&value, 0, sizeof(value));
39 value.a = 1;
40 value.b = 10;
41 test->error = sjme_traverse_put(traverse,
42 &value, 0, 31, test_data, 0);
43 sjme_unit_equalI(test, test->error, SJME_ERROR_NONE,
44 "Adding 31 failed?");
46 /* Adding the next one should fail. */
47 memset(&value, 0, sizeof(value));
48 value.a = 2;
49 value.b = 20;
50 test->error = sjme_traverse_put(traverse,
51 &value, 1, 1, test_data, 0);
52 sjme_unit_equalI(test, test->error, SJME_ERROR_TRAVERSE_FULL,
53 "Adding just one more succeeded?");
55 /* Destroy traverse. */
56 if (sjme_error_is(test->error = sjme_traverse_destroy(
57 SJME_AS_TRAVERSE(traverse))))
58 return sjme_unit_fail(test, "Could not destroy traverse?");
60 /* Success! */
61 return SJME_TEST_RESULT_PASS;