1 /*
2 * Library file_system_data_handle type test program
3 *
4 * Copyright (C) 2018-2021, Joachim Metz <joachim.metz@gmail.com>
5 *
6 * Refer to AUTHORS for acknowledgements.
7 *
8 * This program is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU Lesser General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public License
19 * along with this program. If not, see <https://www.gnu.org/licenses/>.
20 */
21
22 #include <common.h>
23 #include <file_stream.h>
24 #include <types.h>
25
26 #if defined( HAVE_STDLIB_H ) || defined( WINAPI )
27 #include <stdlib.h>
28 #endif
29
30 #include "fsapfs_test_libcerror.h"
31 #include "fsapfs_test_libfsapfs.h"
32 #include "fsapfs_test_macros.h"
33 #include "fsapfs_test_memory.h"
34 #include "fsapfs_test_unused.h"
35
36 #include "../libfsapfs/libfsapfs_file_system_data_handle.h"
37
38 #if defined( __GNUC__ ) && !defined( LIBFSAPFS_DLL_IMPORT )
39
40 /* Tests the libfsapfs_file_system_data_handle_free function
41 * Returns 1 if successful or 0 if not
42 */
fsapfs_test_file_system_data_handle_free(void)43 int fsapfs_test_file_system_data_handle_free(
44 void )
45 {
46 libcerror_error_t *error = NULL;
47 int result = 0;
48
49 /* Test error cases
50 */
51 result = libfsapfs_file_system_data_handle_free(
52 NULL,
53 &error );
54
55 FSAPFS_TEST_ASSERT_EQUAL_INT(
56 "result",
57 result,
58 -1 );
59
60 FSAPFS_TEST_ASSERT_IS_NOT_NULL(
61 "error",
62 error );
63
64 libcerror_error_free(
65 &error );
66
67 return( 1 );
68
69 on_error:
70 if( error != NULL )
71 {
72 libcerror_error_free(
73 &error );
74 }
75 return( 0 );
76 }
77
78 #endif /* defined( __GNUC__ ) && !defined( LIBFSAPFS_DLL_IMPORT ) */
79
80 /* The main program
81 */
82 #if defined( HAVE_WIDE_SYSTEM_CHARACTER )
wmain(int argc FSAPFS_TEST_ATTRIBUTE_UNUSED,wchar_t * const argv[]FSAPFS_TEST_ATTRIBUTE_UNUSED)83 int wmain(
84 int argc FSAPFS_TEST_ATTRIBUTE_UNUSED,
85 wchar_t * const argv[] FSAPFS_TEST_ATTRIBUTE_UNUSED )
86 #else
87 int main(
88 int argc FSAPFS_TEST_ATTRIBUTE_UNUSED,
89 char * const argv[] FSAPFS_TEST_ATTRIBUTE_UNUSED )
90 #endif
91 {
92 FSAPFS_TEST_UNREFERENCED_PARAMETER( argc )
93 FSAPFS_TEST_UNREFERENCED_PARAMETER( argv )
94
95 #if defined( __GNUC__ ) && !defined( LIBFSAPFS_DLL_IMPORT )
96
97 /* TODO: add tests for libfsapfs_file_system_data_handle_initialize */
98
99 FSAPFS_TEST_RUN(
100 "libfsapfs_file_system_data_handle_free",
101 fsapfs_test_file_system_data_handle_free );
102
103 /* TODO: add tests for libfsapfs_file_system_data_handle_read_data_block */
104
105 #endif /* defined( __GNUC__ ) && !defined( LIBFSAPFS_DLL_IMPORT ) */
106
107 return( EXIT_SUCCESS );
108
109 on_error:
110 return( EXIT_FAILURE );
111 }
112
113