Collect all of the various spread out 3rd party licenses to a single file.
[SquirrelJME.git] / nanocoat / tests / testListFlattenArgs.c
blob079d6fc88509a57627d7d42902d389823bb2c8a8
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 "proto.h"
11 #include "sjme/list.h"
12 #include "test.h"
13 #include "unit.h"
15 /** Test argument count. */
16 static const sjme_jint testArgC = 4;
18 /** Test argv values. */
19 static sjme_lpcstr testArgV[4] = {
20 "squirrels",
21 "are",
22 "so",
23 "cute!"
26 /**
27 * Tests flattening of argc/argv.
29 * @since 2023/12/17
31 SJME_TEST_DECLARE(testListFlattenArgs)
33 sjme_list_sjme_lpcstr* list;
34 sjme_jint i;
36 /* Test array load of list. */
37 list = NULL;
38 if (sjme_error_is(sjme_list_flattenArgCV(test->pool,
39 &list, testArgC, testArgV)) || list == NULL)
40 sjme_unit_fail(test, "Could not build flattened list?");
42 /* Test resultant list values. */
43 sjme_unit_equalI(test, list->length, testArgC, "Length invalid?");
44 for (i = 0; i < testArgC; i++)
46 /* The strings should be equal. */
47 sjme_unit_equalS(test, list->elements[i], testArgV[i],
48 "Array element %d not set correctly?", i);
50 /* However the pointers should not be the same, as it is a copy. */
51 sjme_unit_notEqualP(test, list->elements[i], testArgV[i],
52 "Value element %d was not copied?", i);
55 /* Success! */
56 return SJME_TEST_RESULT_PASS;