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 // -------------------------------------------------------------------------*/
14 #include "sjme/romInternal.h"
18 /** Just easily returned accordingly. */
19 static sjme_list_sjme_rom_library testFakeSuiteList
=
22 .elementSize
= sizeof(sjme_rom_library
)
25 static sjme_errorCode
testSuiteList(
26 sjme_attrInNotNull sjme_rom_suite targetSuite
,
27 sjme_attrOutNotNull sjme_list_sjme_rom_library
** outLibraries
)
29 *outLibraries
= &testFakeSuiteList
;
30 return SJME_ERROR_NONE
;
33 static sjme_jboolean
configRomSuiteLibraries(
34 sjme_attrInNotNull sjme_mock
* inState
,
35 sjme_attrInNotNull sjme_mock_configWork
* inCurrent
)
37 sjme_mock_configDataRomSuite
* romSuite
;
39 romSuite
= &inCurrent
->data
.romSuite
;
41 if (inCurrent
->type
== SJME_MOCK_DO_TYPE_ROM_SUITE
)
42 romSuite
->functions
.list
= testSuiteList
;
47 /** Mock set for test. */
48 static const sjme_mock_configSet mockRomSuiteLibraries
=
50 configRomSuiteLibraries
,
61 * Tests that suite libraries can be obtained.
65 SJME_TEST_DECLARE(testRomSuiteLibraries
)
69 sjme_list_sjme_rom_library
* libraries
;
72 /* Initialize mocks. */
73 memset(&mockState
, 0, sizeof(mockState
));
74 if (!sjme_mock_act(test
, &mockState
,
75 &mockRomSuiteLibraries
, 0))
76 return sjme_unit_fail(test
, "Could not run mocks.");
78 /* Get the suite we created. */
79 suite
= mockState
.romSuites
[0];
81 /* Call the libraries list. */
83 if (sjme_error_is(error
= sjme_rom_suiteLibraries(suite
,
84 &libraries
)) || libraries
== NULL
)
85 return sjme_unit_fail(test
, "Could not get libraries list: %d", error
);
87 /* The result should be our fake libraries. */
88 sjme_unit_equalP(test
, libraries
, &testFakeSuiteList
,
89 "Different set of libraries returned?");
91 /* The cache should get our libraries. */
92 sjme_unit_equalP(test
, suite
->cache
.libraries
, &testFakeSuiteList
,
93 "Library list was not cached?");
96 return SJME_TEST_RESULT_PASS
;