1 /*DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64
4 for INTEL64(R), AMD64(R)
6 Copyright(C) 2007-2009 Koine Yuusuke(koinec). All rights reserved.
8 Redistribution and use in source and binary forms, with or without
9 modification, are permitted provided that the following conditions are met:
11 1. Redistributions of source code must retain the above copyright notice,
12 this list of conditions and the following disclaimer.
13 2. Redistributions in binary form must reproduce the above copyright
14 notice, this list of conditions and the following disclaimer in the
15 documentation and/or other materials provided with the distribution.
17 THIS SOFTWARE IS PROVIDED BY Koine Yuusuke(koinec) ``AS IS'' AND ANY
18 EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20 DISCLAIMED. IN NO EVENT SHALL Koine Yuusuke(koinec) OR CONTRIBUTORS BE
21 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
27 OF THE POSSIBILITY OF SUCH DAMAGE.
29 DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64*/
31 /* File Info -----------------------------------------------------------
35 ----------------------------------------------------------------------*/
37 #define DRD64_SRC_TEST_LIBGOBLIN_BINARYFILE
38 #include"drd64_libgoblin.h"
39 #include"test_libgoblin.h"
42 /* BinaryFile_AllocBinaryFile() & FreeBinaryFile() *****************/
43 /*--------------------------------------------------------------------*/
44 void Test_BinaryFile_AllocFree_test00_001( void )
47 LibGoblin_BinaryFile *p_binfile;
49 i_result = LibBrownie_Init();
50 CU_ASSERT( 0x00 == i_result );
52 i_result = BinaryFile_Init();
53 CU_ASSERT( 0x00 == i_result );
55 p_binfile = BinaryFile_AllocBinaryFile();
56 CU_ASSERT( NULL != p_binfile );
58 i_result = BinaryFile_FreeBinaryFile( p_binfile );
59 CU_ASSERT( 0x00 == i_result );
61 i_result = BinaryFile_Term();
62 CU_ASSERT( 0x00 == i_result );
70 /*--------------------------------------------------------------------*/
71 void Test_BinaryFile_AllocFree_test00_002( void )
75 LibGoblin_BinaryFile *p_binfile;
77 i_result = LibBrownie_Init();
78 CU_ASSERT( 0x00 == i_result );
80 i_result = BinaryFile_Init();
81 CU_ASSERT( 0x00 == i_result );
84 for( i_cnt = 0; i_cnt < 128; i_cnt++ ) {
85 p_binfile = BinaryFile_AllocBinaryFile();
86 CU_ASSERT( NULL != p_binfile );
87 CU_ASSERT( i_cnt == p_binfile->i_id );
90 for( i_cnt = 0; i_cnt < 128; i_cnt += 8 ) {
92 p_binfile = BinaryFile_GetBinaryFile( i_cnt );
93 CU_ASSERT( NULL != p_binfile );
95 i_result = BinaryFile_FreeBinaryFile( p_binfile );
96 CU_ASSERT( 0x00 == i_result );
99 for( i_cnt = 0; i_cnt < 16; i_cnt++ ) {
101 p_binfile = BinaryFile_AllocBinaryFile();
102 CU_ASSERT( NULL != p_binfile );
103 CU_ASSERT( (i_cnt * 8) == p_binfile->i_id );
106 for( i_cnt = 0; i_cnt < 128; i_cnt++ ) {
108 p_binfile = BinaryFile_GetBinaryFile( i_cnt );
109 CU_ASSERT( NULL != p_binfile );
111 i_result = BinaryFile_FreeBinaryFile( p_binfile );
112 CU_ASSERT( 0x00 == i_result );
115 p_binfile = BinaryFile_GetBinaryFile( 0 );
116 CU_ASSERT( NULL == p_binfile );
118 i_result = BinaryFile_Term();
119 CU_ASSERT( 0x00 == i_result );
127 /* BinaryFile_Init() & Term() ****************************************/
128 /*--------------------------------------------------------------------*/
129 void Test_BinaryFile_InitTerm_test00_001( void )
133 i_result = LibBrownie_Init();
134 CU_ASSERT( 0x00 == i_result );
136 i_result = BinaryFile_Init();
137 CU_ASSERT( 0x00 == i_result );
139 i_result = BinaryFile_Term();
140 CU_ASSERT( 0x00 == i_result );
148 /*----------------------------------------------------------------------
149 ----------------------------------------------------------------------*/
150 DRD64_TEST_LIBGOBLIN_BINARYFILE_EXTERN
152 Test_LibGoblin_BinaryFile(
157 pt_goblin = CU_add_suite( "LibGoblin_BinaryFile", NULL, NULL );
159 CU_add_test( pt_goblin, "BinaryFile_InitTerm_test00_001",
160 Test_BinaryFile_InitTerm_test00_001 );
161 CU_add_test( pt_goblin, "BinaryFile_AllocFree_test00_001",
162 Test_BinaryFile_AllocFree_test00_001 );
163 CU_add_test( pt_goblin, "BinaryFile_AllocFree_test00_002",
164 Test_BinaryFile_AllocFree_test00_002 );
171 /* EOF of drd64_.c ----------------------------------- */