1 /* -*- Mode: C; indent-tabs-mode: t; tab-width: 4 -*-
2 // ---------------------------------------------------------------------------
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 // -------------------------------------------------------------------------*/
17 #include "sjme/traverse.h"
18 #include "testTraverse.h"
21 * Tests filling the tree past the maximum.
25 SJME_TEST_DECLARE(testTraversePutOverfill
)
27 sjme_traverse_test_data traverse
;
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
));
41 test
->error
= sjme_traverse_put(traverse
,
42 &value
, 0, 31, test_data
, 0);
43 sjme_unit_equalI(test
, test
->error
, SJME_ERROR_NONE
,
46 /* Adding the next one should fail. */
47 memset(&value
, 0, sizeof(value
));
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?");
61 return SJME_TEST_RESULT_PASS
;