PostgreSQL Source Code: src/test/modules/test_lfind/test_lfind.c Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
13
15
18
19
20
21
22
23#define LEN_NO_TAIL(vectortype) (2 * sizeof(vectortype))
24#define LEN_WITH_TAIL(vectortype) (LEN_NO_TAIL(vectortype) + 3)
25
27
28
29static void
31{
35
36 memset(charbuf, 0xFF, len_with_tail);
37
38 charbuf[len_with_tail - 1] = key;
39 if (key > 0x00 && pg_lfind8(key - 1, charbuf, len_with_tail))
40 elog(ERROR, "pg_lfind8() found nonexistent element '0x%x'", key - 1);
41 if (key < 0xFF && (key, charbuf, len_with_tail))
42 elog(ERROR, "pg_lfind8() did not find existing element '0x%x'", key);
43 if (key < 0xFE && pg_lfind8(key + 1, charbuf, len_with_tail))
44 elog(ERROR, "pg_lfind8() found nonexistent element '0x%x'", key + 1);
45
46 memset(charbuf, 0xFF, len_with_tail);
47
48 charbuf[len_no_tail - 1] = key;
49 if (key > 0x00 && pg_lfind8(key - 1, charbuf, len_no_tail))
50 elog(ERROR, "pg_lfind8() found nonexistent element '0x%x'", key - 1);
52 elog(ERROR, "pg_lfind8() did not find existing element '0x%x'", key);
53 if (key < 0xFE && pg_lfind8(key + 1, charbuf, len_no_tail))
54 elog(ERROR, "pg_lfind8() found nonexistent element '0x%x'", key + 1);
55}
56
60{
69
71}
72
73
74static void
76{
80
81 memset(charbuf, 0xFF, len_with_tail);
82
83 charbuf[len_with_tail - 1] = key;
85 elog(ERROR, "pg_lfind8_le() found nonexistent element <= '0x%x'", key - 1);
87 elog(ERROR, "pg_lfind8_le() did not find existing element <= '0x%x'", key);
89 elog(ERROR, "pg_lfind8_le() did not find existing element <= '0x%x'", key + 1);
90
91 memset(charbuf, 0xFF, len_with_tail);
92
93 charbuf[len_no_tail - 1] = key;
95 elog(ERROR, "pg_lfind8_le() found nonexistent element <= '0x%x'", key - 1);
97 elog(ERROR, "pg_lfind8_le() did not find existing element <= '0x%x'", key);
99 elog(ERROR, "pg_lfind8_le() did not find existing element <= '0x%x'", key + 1);
100}
101
105{
114
116}
117
121{
122#define TEST_ARRAY_SIZE 135
124
125 test_array[8] = 1;
126 test_array[64] = 2;
128
130 elog(ERROR, "pg_lfind32() found nonexistent element");
132 elog(ERROR, "pg_lfind32() did not find existing element");
133
135 elog(ERROR, "pg_lfind32() found nonexistent element");
137 elog(ERROR, "pg_lfind32() did not find existing element");
138
140 elog(ERROR, "pg_lfind32() found nonexistent element");
142 elog(ERROR, "pg_lfind32() did not find existing element");
143
145 elog(ERROR, "pg_lfind32() found nonexistent element");
146
148}
static bool pg_lfind8_le(uint8 key, uint8 *base, uint32 nelem)
static bool pg_lfind32(uint32 key, const uint32 *base, uint32 nelem)
static bool pg_lfind8(uint8 key, uint8 *base, uint32 nelem)
#define LEN_NO_TAIL(vectortype)
PG_FUNCTION_INFO_V1(test_lfind8)
Datum test_lfind8(PG_FUNCTION_ARGS)
Datum test_lfind32(PG_FUNCTION_ARGS)
Datum test_lfind8_le(PG_FUNCTION_ARGS)
#define LEN_WITH_TAIL(vectortype)
static void test_lfind8_le_internal(uint8 key)
static void test_lfind8_internal(uint8 key)