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 static sjme_jboolean
funcRomLibraryFindResourceJar(
18 sjme_attrInNotNull sjme_mock
* inState
,
19 sjme_attrInNotNull sjme_mock_configWork
* inCurrent
)
21 if (inState
== NULL
|| inCurrent
== NULL
)
22 return SJME_JNI_FALSE
;
24 if (inCurrent
->type
== SJME_MOCK_DO_TYPE_ROM_MOCK_LIBRARY
)
25 inCurrent
->data
.romMockLibrary
.isJar
= SJME_JNI_TRUE
;
30 static const sjme_mock_configSet configRomLibraryFindResourceJar
=
32 funcRomLibraryFindResourceJar
,
36 sjme_mock_doRomMockLibrary
,
42 * Tests finding a single resource.
46 SJME_TEST_DECLARE(testRomLibraryFindResourceJar
)
48 sjme_rom_library library
;
50 sjme_stream_input inputStream
;
52 /* Initialize mocks. */
53 memset(&mock
, 0, sizeof(mock
));
54 if (!sjme_mock_act(test
, &mock
,
55 &configRomLibraryFindResourceJar
, 0))
56 return sjme_unit_fail(test
, "Could not initialize mocks");
58 /* Get the library to test. */
59 library
= mock
.romLibraries
[0];
61 /* Try to find a resource. */
63 if (sjme_error_is(sjme_rom_libraryResourceAsStream(library
,
64 &inputStream
, "hello.txt")) || inputStream
== NULL
)
65 return sjme_unit_fail(test
, "Did not find resource?");
67 /* Just close the stream. */
68 if (sjme_error_is(sjme_stream_inputClose(inputStream
)))
69 return sjme_unit_fail(test
, "Could not close stream?");
72 return SJME_TEST_RESULT_PASS
;