74 tout <<
"constructor\n";
83 tout <<
"destructor\n";
120 bool deleted =
false;
127 # if __has_warning("-Wself-assign-overloaded") 130 # pragma clang diagnostic push 131 # pragma clang diagnostic ignored "-Wself-assign-overloaded" 136 # if __has_warning("-Wself-assign-overloaded") 137 # pragma clang diagnostic pop 149 tout <<
"test_autoptr constructor\n";
153 tout <<
"test_autoptr destructor\n";
160 bool deleted =
false;
164 AutoPtr<test_autoptr> ptr(raw_ptr);
169 ptr.reset(ptr.release());
190 bool deleted2 =
false;
192 AutoPtr<test_autoptr> ptr(raw_ptr2);
217 if ((s1 != s2) || (s1 > s2)) {
218 FAIL_TEST(
"String comparisons BADLY wrong");
223 if ((s1 == s2) || (s1 < s2)) {
224 FAIL_TEST(
"String comparisons don't cope with extra nulls");
232 if ((s1.length() != 5) || (s2.length() != 5)) {
233 FAIL_TEST(
"Lengths with added nulls wrong");
236 if ((s1 == s2) || !(s1 < s2)) {
237 FAIL_TEST(
"Characters after a null ignored in comparisons");
267 for (
unsigned int i = 0; i != 1000; ++i) {
270 const char* ptr = packed.data();
271 const char* end = ptr + packed.size();
277 swap(prev_packed, packed);
279 for (
unsigned int i = 2345; i < 65000; i += 113) {
282 const char* ptr = packed.data();
283 const char* end = ptr + packed.size();
289 swap(prev_packed, packed);
291 unsigned int prev = 64999;
292 for (
unsigned int i = 65000; i > prev; prev = i, i = (i << 1) ^ 1337) {
295 const char* ptr = packed.data();
296 const char* end = ptr + packed.size();
302 swap(prev_packed, packed);
307 for (
unsigned int i = 23456; i < 765432; i += 1131) {
310 const char* ptr = packed.data();
311 const char* end = ptr + packed.size();
312 for (
unsigned int i = 23456; i < 765432; i += 1131) {
324 for (
unsigned int i = 0; i != 1000; ++i) {
327 const char * ptr = packed.data();
328 const char * end = ptr + packed.size();
334 swap(prev_packed, packed);
336 for (
unsigned int i = 2345; i < 65000; i += 113) {
339 const char * ptr = packed.data();
340 const char * end = ptr + packed.size();
346 swap(prev_packed, packed);
348 unsigned int prev = 64999;
349 for (
unsigned int i = 65000; i > prev; prev = i, i = (i << 1) ^ 1337) {
352 const char * ptr = packed.data();
353 const char * end = ptr + packed.size();
359 swap(prev_packed, packed);
364 for (
unsigned int i = 23456; i < 765432; i += 1131) {
367 const char * ptr = packed.data();
368 const char * end = ptr + packed.size();
369 for (
unsigned int i = 23456; i < 765432; i += 1131) {
381 memset(tested, 0,
sizeof(tested));
382 for (
int ch =
'0'; ch !=
'9' + 1; ++ch) {
405 for (
int ch =
'A'; ch !=
'F' + 1; ++ch) {
421 int v = ch -
'A' + 10;
428 for (
int ch =
'G'; ch !=
'Z' + 1; ++ch) {
446 for (
int ch =
'a'; ch !=
'f' + 1; ++ch) {
462 int v = ch -
'a' + 10;
469 for (
int ch =
'g'; ch !=
'z' + 1; ++ch) {
487 for (
const char* p =
"\t\n\f\r "; *p; ++p) {
507 for (
int ch = 0; ch != 128; ++ch) {
508 if (tested[ch])
continue;
526 for (
unsigned char ch = 128; ch != 0; ++ch) {
544 for (
signed char ch = -128; ch != 0; ++ch) {
574 TESTCASE(pack_uint_preserving_sort1),
575 TESTCASE(pack_uint_preserving_sort2),
580 int main(
int argc,
char** argv)
584 }
catch (
const char* e) {
int main(int argc, char **argv)
Xapian::Internal::intrusive_ptr< const test_refcnt > test()
test_refcnt(bool &deleted_)
static TempDtorTest factory()
#define TEST(a)
Test a condition, without an additional explanation for failure.
static void parse_command_line(int argc, char **argv)
Parse the command line arguments.
static void test_exception1()
Test_Exception(int value_)
static void test_temporarydtor1()
#define TEST_AND_EXPLAIN(a, b)
Test a condition, and display the test with an extra explanation if the condition fails...
unsigned _refs
Reference count.
a generic test suite engine
Convert types to std::string.
#define TEST_REL(A, REL, B)
Test a relation holds,e.g. TEST_REL(a,>,b);.
std::ostringstream tout
The debug printing stream.
void C_pack_uint_preserving_sort(std::string &s, U value)
Append an encoded unsigned integer to a string, preserving the sort order.
bool C_unpack_uint_preserving_sort(const char **p, const char *end, U *result)
Decode an "sort preserved" unsigned integer from a string.
Public interfaces for the Xapian library.
bool C_isnotalpha(char ch)
static void test_pack_uint_preserving_sort2()
Test C_pack_uint_preserving_sort()
static void test_stringcomp1()
static void test_autoptr1()
static void test_chartype1()
Test C_isupper() etc.
static const test_desc tests[]
The lists of tests to perform.
bool unpack_uint_preserving_sort(const char **p, const char *end, U *result)
Decode a "sort preserved" unsigned integer from a string.
Base class for objects managed by intrusive_ptr.
#define FAIL_TEST(MSG)
Fail the current testcase with message MSG.
Pack types into strings and unpack them again.
Xapian-specific test helper functions and macros.
char hex_decode(char ch1, char ch2)
Decode a pair of ASCII hex digits.
bool C_isnotlower(char ch)
static int run(const test_desc *tests)
static void test_pack_uint_preserving_sort1()
Test pack_uint_preserving_sort()
static void test_refcnt2()
Structure holding a description of a test.
#define TEST_EQUAL(a, b)
Test for equality of two things.
bool C_isnotdigit(char ch)
A smart pointer that uses intrusive reference counting.
bool C_isnotxdigit(char ch)
bool C_isnotspace(char ch)
test_autoptr(bool &deleted_)
bool C_isnotupper(char ch)
static void test_refcnt1()
Wrapper around standard unique_ptr template.
bool C_isnotalnum(char ch)
void pack_uint_preserving_sort(std::string &s, U value)
Append an encoded unsigned integer to a string, preserving the sort order.