OSDN Git Service

(LibGoblin)
[drdeamon64/drdeamon64.git] / libgoblin / test_libgoblin_proginfo.c
1 /*DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64
2
3                          D r . D e a m o n  6 4
4                         for INTEL64(R), AMD64(R)
5         
6    Copyright(C) 2007-2009 Koine Yuusuke(koinec). All rights reserved.
7
8 Redistribution and use in source and binary forms, with or without
9 modification, are permitted provided that the following conditions are met:
10
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.
16
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.
28
29 DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64*/
30
31 /* File Info -----------------------------------------------------------
32 File: drd64_.c
33 Function: 
34 Comment: 
35 ----------------------------------------------------------------------*/
36
37 #define DRD64_SRC_TEST_LIBGOBLIN_PROGINFO
38 #include"drd64_libgoblin.h"
39 #include"test_libgoblin.h"
40
41
42 /* ProgInfo_AllocProgInfo() & FreeProgInfo() *******************/
43 /*--------------------------------------------------------------------*/
44 void Test_ProgInfo_AllocFree_test00_001( void )
45 {
46         int             i_bid;
47         int             i_result;
48         
49         i_result        = LibBrownie_Init();
50         CU_ASSERT( 0x00 == i_result );
51
52         i_result        = ProgInfo_Init();
53         CU_ASSERT( 0x00 == i_result );
54
55         i_bid   = LibGoblin_AllocProgInfo();
56         CU_ASSERT( 0x00 == i_bid );
57
58         i_result        = LibGoblin_FreeProgInfo( i_bid );
59         CU_ASSERT( 0x00 == i_result );
60
61         i_result        = ProgInfo_Term();
62         CU_ASSERT( 0x00 == i_result );
63
64         LibBrownie_Term();
65
66         return;
67 }
68
69
70 /*--------------------------------------------------------------------*/
71 void Test_ProgInfo_AllocFree_test00_002( void )
72 {
73         int             i_cnt;
74         int             i_bid;
75         int             i_result;
76
77         i_result        = LibBrownie_Init();
78         CU_ASSERT( 0x00 == i_result );
79
80         i_result        = ProgInfo_Init();
81         CU_ASSERT( 0x00 == i_result );
82
83         for( i_cnt = 0; i_cnt < 33; i_cnt++ )   {
84                 i_bid   = LibGoblin_AllocProgInfo();
85                 CU_ASSERT( i_cnt == i_bid );
86         }
87
88         for( i_cnt = 0; i_cnt < 8; i_cnt++ )    {
89                 i_result        = LibGoblin_FreeProgInfo( i_cnt );
90                 CU_ASSERT( 0x00 == i_result );
91         }
92
93         for( i_cnt = 0; i_cnt < 8; i_cnt++ )    {
94                 i_bid   = LibGoblin_AllocProgInfo();
95                 CU_ASSERT( i_cnt == i_bid );
96         }
97
98         for( i_cnt = 0; i_cnt < 33; i_cnt++ )   {
99                 i_result        = LibGoblin_FreeProgInfo( i_cnt );
100                 CU_ASSERT( 0x00 == i_result );
101         }
102
103         i_result        = LibGoblin_FreeProgInfo( i_cnt );
104         CU_ASSERT( 0x00 > i_result );
105
106         i_result        = LibGoblin_FreeProgInfo( 0 );
107         CU_ASSERT( 0x00 > i_result );
108
109         i_result        = ProgInfo_Term();
110         CU_ASSERT( 0x00 == i_result );
111
112         LibBrownie_Term();
113
114         return;
115 }
116
117
118 /* ProgInfo_Init() & Term() **********************************/
119 /*--------------------------------------------------------------------*/
120 void Test_ProgInfo_InitTerm_test00_001( void )
121 {
122         int             i_result;
123
124         i_result        = LibBrownie_Init();
125         CU_ASSERT( 0x00 == i_result );
126
127         i_result        = ProgInfo_Init();
128         CU_ASSERT( 0x00 == i_result );
129
130         i_result        = ProgInfo_Term();
131         CU_ASSERT( 0x00 == i_result );
132
133         LibBrownie_Term();
134
135         return;
136 }
137
138
139 /*----------------------------------------------------------------------
140 ----------------------------------------------------------------------*/
141 DRD64_TEST_LIBGOBLIN_PROGINFO_EXTERN
142 int
143         Test_LibGoblin_ProgInfo(
144                 void )
145 {
146         CU_pSuite       pt_goblin;
147
148         pt_goblin       = CU_add_suite( "ProgramInfo", NULL, NULL );
149
150         CU_add_test( pt_goblin, "ProgInfo_InitTerm_test00_001",
151                                                                  Test_ProgInfo_InitTerm_test00_001 );
152         CU_add_test( pt_goblin, "ProgInfo_AllocFree_test00_001",
153                                                                  Test_ProgInfo_AllocFree_test00_001 );
154         CU_add_test( pt_goblin, "ProgInfo_AllocFree_test00_002",
155                                                                  Test_ProgInfo_AllocFree_test00_002 );
156
157
158         return 0x00;
159 }
160
161
162 /* EOF of drd64_.c ----------------------------------- */