Compile fixes.
[SquirrelJME.git] / nanocoat / tests / testZipOpenClose.c
blob7e851c849cd1e6c6e59c92109eb831198140fe79
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 "mock.h"
11 #include "proto.h"
12 #include "test.h"
13 #include "unit.h"
14 #include "sjme/zip.h"
15 #include "mock.jar.h"
17 /**
18 * Tests the opening and closing of Zip files.
20 * @since 2023/12/31
22 SJME_TEST_DECLARE(testZipOpenClose)
24 sjme_zip zip;
25 sjme_errorCode error;
27 /* Attempt open of Zip. */
28 zip = NULL;
29 if (sjme_error_is(sjme_zip_openMemory(test->pool, &zip,
30 mock_jar__bin, mock_jar__len)) || zip == NULL)
31 return sjme_unit_fail(test, "Could not open Zip");
33 /* Reference up, since the Zip is valid. */
34 if (sjme_error_is(sjme_alloc_weakRef(zip, NULL)))
35 return sjme_unit_fail(test, "Could not count up Zip?");
37 /* Immediately close it without doing anything. */
38 if (sjme_error_is(error = sjme_closeable_close(
39 SJME_AS_CLOSEABLE(zip))))
40 return sjme_unit_fail(test, "Could not close Zip: %d", error);
42 /* Passed! */
43 return SJME_TEST_RESULT_PASS;