PostGIS  2.2.8dev-r@@SVN_REVISION@@

◆ test_varint()

static void test_varint ( void  )
static

Definition at line 105 of file cu_varint.c.

References do_test_s32_varint(), do_test_s64_varint(), do_test_u32_varint(), and do_test_u64_varint().

Referenced by varint_suite_setup().

106 {
107 
108  do_test_u64_varint(1, 1, "01");
109  do_test_u64_varint(300, 2, "AC02");
110  do_test_u64_varint(150, 2, "9601");
111  do_test_u64_varint(240, 2, "F001");
112  do_test_u64_varint(0x4000, 3, "808001");
113  /*
114  0100:0000 0000:0000 - input (0x4000)
115  1000:0000 1000:0000 0000:0001 - output (0x808001)
116  000:0000 000:0000 000:0001 - chop
117  000:0001 000:0000 000:0000 - swap
118  0:0000 0100:0000 0000:0000 - concat = input
119  */
120  do_test_u64_varint(2147483647, 5, "FFFFFFFF07");
121  /*
122  0111:1111 1111:1111 1111:1111 1111:1111 - input (0x7FFFFFFF)
123  1111:1111 1111:1111 1111:1111 1111:1111 0000:0111 - output(0xFFFFFFFF07)
124  111:1111 111:1111 111:1111 111:1111 000:0111 - chop
125  000:0111 111:1111 111:1111 111:1111 111:1111 - swap
126  0111:1111 1111:1111 1111:1111 1111:1111 - concat = input
127  | | | |
128  2^32 2^16 2^8 2^0
129  */
130  do_test_s64_varint(1, 1, "02");
131  do_test_s64_varint(-1, 1, "01");
132  do_test_s64_varint(-2, 1, "03");
133 
134  do_test_u32_varint(2147483647, 5, "FFFFFFFF07");
135  /*
136  0111:1111 1111:1111 1111:1111 1111:1111 - input (7fffffff)
137  1111:1111 1111:1111 1111:1111 1111:1111 0000:0111 - output (ffffff07)
138  111:1111 111:1111 111:1111 111:1111 000:0111 - chop
139  000:0111 111:1111 111:1111 111:1111 111:1111 - swap
140  0111:1111 1111:1111 1111:1111 1111:1111 - concat = input
141  | | | |
142  2^32 2^16 2^8 2^0
143  */
144  do_test_s32_varint(2147483647, 5, "FEFFFFFF0F");
145  /*
146  0111:1111 1111:1111 1111:1111 1111:1111 - input (7fffffff)
147  1111:1110 1111:1111 1111:1111 1111:1111 0000:1111 - output(feffffff0f)
148  1111:1111 1111:1111 1111:1111 1111:1111 0000:0111 - zigzag (ffffff07)
149  111:1111 111:1111 111:1111 111:1111 000:0111 - chop
150  000:0111 111:1111 111:1111 111:1111 111:1111 - swap
151  0111:1111 1111:1111 1111:1111 1111:1111 - concat = input
152  | | | |
153  2^32 2^16 2^8 2^0
154  */
155  do_test_s32_varint(-2147483648, 5, "FFFFFFFF0F");
156 
157  do_test_s32_varint(1, 1, "02");
158  /*
159  0000:0001 - input (01)
160  0000:0010 - A: input << 1
161  0000:0000 - B: input >> 31
162  0000:0010 - zigzag (A xor B) == output
163  */
164 
165  do_test_s32_varint(-1, 1, "01");
166  /*
167  1111:1111 ... 1111:1111 - input (FFFFFFFF)
168  1111:1111 ... 1111:1110 - A: input << 1
169  1111:1111 ... 1111:1111 - B: input >> 31
170  0000:0000 ... 0000:0001 - zigzag (A xor B) == output
171  */
172 
173 
174 }
static void do_test_u64_varint(uint64_t nr, int expected_size, char *expected_res)
Definition: cu_varint.c:69
static void do_test_s32_varint(int32_t nr, int expected_size, char *expected_res)
Definition: cu_varint.c:51
static void do_test_s64_varint(int64_t nr, int expected_size, char *expected_res)
Definition: cu_varint.c:87
static void do_test_u32_varint(uint32_t nr, int expected_size, char *expected_res)
Definition: cu_varint.c:34
Here is the call graph for this function:
Here is the caller graph for this function: