Changeset 953 for pjproject/trunk/pjlib/src/pjlib-test/pool.c
- Timestamp:
- Feb 16, 2007 9:44:36 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjlib/src/pjlib-test/pool.c
r65 r953 18 18 */ 19 19 #include <pj/pool.h> 20 #include <pj/pool_buf.h> 20 21 #include <pj/rand.h> 21 22 #include <pj/log.h> 23 #include <pj/except.h> 22 24 #include "test.h" 23 25 … … 140 142 } 141 143 144 /* Test the buffer based pool */ 145 static int pool_buf_test(void) 146 { 147 enum { STATIC_BUF_SIZE = 40 }; 148 /* 16 is the internal struct in pool_buf */ 149 static char buf[ STATIC_BUF_SIZE + sizeof(pj_pool_t) + 150 sizeof(pj_pool_block) + 16]; 151 pj_pool_t *pool; 152 void *p; 153 PJ_USE_EXCEPTION; 154 155 PJ_LOG(3,("test", "...pool_buf test")); 156 157 pool = pj_pool_create_on_buf("no name", buf, sizeof(buf)); 158 if (!pool) 159 return -70; 160 161 /* Drain the pool */ 162 PJ_TRY { 163 if ((p=pj_pool_alloc(pool, STATIC_BUF_SIZE/2)) == NULL) 164 return -75; 165 166 if ((p=pj_pool_alloc(pool, STATIC_BUF_SIZE/2)) == NULL) 167 return -76; 168 } 169 PJ_CATCH_ANY { 170 return -77; 171 } 172 PJ_END; 173 174 /* On the next alloc, exception should be thrown */ 175 PJ_TRY { 176 p = pj_pool_alloc(pool, STATIC_BUF_SIZE); 177 if (p != NULL) { 178 /* This is unexpected, the alloc should fail */ 179 return -78; 180 } 181 } 182 PJ_CATCH_ANY { 183 /* This is the expected result */ 184 } 185 PJ_END; 186 187 /* Done */ 188 return 0; 189 } 190 191 142 192 int pool_test(void) 143 193 { … … 161 211 } 162 212 213 rc = pool_buf_test(); 214 if (rc != 0) 215 return rc; 216 217 163 218 return 0; 164 219 }
Note: See TracChangeset
for help on using the changeset viewer.