PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ test_zigzag()

static void test_zigzag ( void  )
static

Definition at line 213 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().

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