PostGIS  2.2.8dev-r@@SVN_REVISION@@

◆ test_zigzag()

static void test_zigzag ( void  )
static

Definition at line 210 of file cu_varint.c.

References INT32_MAX, INT8_MAX, unzigzag32(), unzigzag64(), unzigzag8(), varint_suite_setup(), zigzag32(), zigzag64(), and zigzag8().

Referenced by varint_suite_setup().

211 {
212  int64_t a;
213  int32_t b;
214  int i;
215 
216  for ( i = 1; i < 1024; i += 31 )
217  {
218  a = b = i;
219  CU_ASSERT_EQUAL(a, unzigzag64(zigzag64(a)));
220  CU_ASSERT_EQUAL(b, unzigzag32(zigzag32(b)));
221 
222  a = b = -1 * i;
223  CU_ASSERT_EQUAL(a, unzigzag64(zigzag64(a)));
224  CU_ASSERT_EQUAL(b, unzigzag32(zigzag32(b)));
225  }
226 
227  //8
228  CU_ASSERT_EQUAL(-INT8_MAX, unzigzag8(zigzag8(-INT8_MAX)));
229  CU_ASSERT_EQUAL(INT8_MAX, unzigzag8(zigzag8(INT8_MAX)));
230  CU_ASSERT_EQUAL(0, unzigzag8(zigzag8(0)));
231 
232  //32
233  CU_ASSERT_EQUAL(-INT32_MAX, unzigzag32(zigzag32(-INT32_MAX)));
234  CU_ASSERT_EQUAL(INT32_MAX, unzigzag32(zigzag32(INT32_MAX)));
235  CU_ASSERT_EQUAL(0, unzigzag32(zigzag32(0)));
236 
237  //64
238  CU_ASSERT_EQUAL(-INT64_MAX, unzigzag64(zigzag64(-INT64_MAX)));
239  CU_ASSERT_EQUAL(INT64_MAX, unzigzag64(zigzag64(INT64_MAX)));
240  CU_ASSERT_EQUAL(0, unzigzag64(zigzag64(0)));
241 }
int32_t unzigzag32(uint32_t val)
Definition: varint.c:188
#define INT8_MAX
Definition: lwin_wkt_lex.c:328
uint8_t zigzag8(int8_t val)
Definition: varint.c:174
#define INT32_MAX
Definition: lwin_wkt_lex.c:334
uint64_t zigzag64(int64_t val)
Definition: varint.c:160
int64_t unzigzag64(uint64_t val)
Definition: varint.c:181
uint32_t zigzag32(int32_t val)
Definition: varint.c:167
int8_t unzigzag8(uint8_t val)
Definition: varint.c:195
Here is the call graph for this function:
Here is the caller graph for this function: