pcrecpp_unittest.cc File Reference

#include <stdio.h>
#include <cassert>
#include <vector>
#include "pcrecpp.h"

Go to the source code of this file.

Defines

#define CHECK(condition)
#define CHECK_EQ(a, b)   CHECK(a == b)
#define CHECK_HEX(type, value)
#define CHECK_OCTAL(type, value)
#define CHECK_DECIMAL(type, value)

Functions

static void Timing1 (int num_iters)
static void Timing2 (int num_iters)
static void Timing3 (int num_iters)
static void RadixTests ()
static void TestReplace ()
static void TestExtract ()
static void TestConsume ()
static void TestFindAndConsume ()
static void TestMatchNumberPeculiarity ()
static void TestRecursion ()
static void TestQuoteMeta (string unquoted, RE_Options options=RE_Options())
static void NegativeTestQuoteMeta (string unquoted, string should_not_match, RE_Options options=RE_Options())
static void TestQuotaMetaSimple ()
static void TestQuoteMetaSimpleNegative ()
static void TestQuoteMetaLatin1 ()
static void TestQuoteMetaUtf8 ()
static void TestQuoteMetaAll ()
static void GetOneOptionResult (const char *option_name, const char *regex, const char *str, RE_Options options, bool full, string expected)
static void TestOneOption (const char *option_name, const char *regex, const char *str, RE_Options options, bool full, bool assertive=true)
static void Test_CASELESS ()
static void Test_MULTILINE ()
static void Test_DOTALL ()
static void Test_DOLLAR_ENDONLY ()
static void Test_EXTRA ()
static void Test_EXTENDED ()
static void Test_NO_AUTO_CAPTURE ()
static void Test_UNGREEDY ()
static void Test_all_options ()
static void TestOptions ()
static void TestConstructors ()
int main (int argc, char **argv)

Variables

static bool VERBOSE_TEST = false


Define Documentation

#define CHECK ( condition   ) 

Value:

do {                           \
  if (!(condition)) {                                   \
    fprintf(stderr, "%s:%d: Check failed: %s\n",        \
            __FILE__, __LINE__, #condition);            \
    exit(1);                                            \
  }                                                     \
} while (0)

Definition at line 58 of file pcrecpp_unittest.cc.

#define CHECK_DECIMAL ( type,
value   ) 

Value:

do { \
    type v; \
    CHECK(RE("(-?[0-9]+)[uUlL]*").FullMatch(#value, &v)); \
    CHECK_EQ(v, value); \
    CHECK(RE("(-?[0-9a-fA-FxX]+)[uUlL]*").FullMatch(#value, CRadix(&v))); \
    CHECK_EQ(v, value); \
  } while(0)

Referenced by RadixTests().

#define CHECK_EQ ( a,
b   )     CHECK(a == b)

Definition at line 66 of file pcrecpp_unittest.cc.

#define CHECK_HEX ( type,
value   ) 

Value:

do { \
    type v; \
    CHECK(RE("([0-9a-fA-F]+)[uUlL]*").FullMatch(#value, Hex(&v))); \
    CHECK_EQ(v, 0x ## value); \
    CHECK(RE("([0-9a-fA-FxX]+)[uUlL]*").FullMatch("0x" #value, CRadix(&v))); \
    CHECK_EQ(v, 0x ## value); \
  } while(0)

Referenced by RadixTests().

#define CHECK_OCTAL ( type,
value   ) 

Value:

do { \
    type v; \
    CHECK(RE("([0-7]+)[uUlL]*").FullMatch(#value, Octal(&v))); \
    CHECK_EQ(v, 0 ## value); \
    CHECK(RE("([0-9a-fA-FxX]+)[uUlL]*").FullMatch("0" #value, CRadix(&v))); \
    CHECK_EQ(v, 0 ## value); \
  } while(0)

Referenced by RadixTests().


Function Documentation

static void GetOneOptionResult ( const char *  option_name,
const char *  regex,
const char *  str,
RE_Options  options,
bool  full,
string  expected 
) [static]

Definition at line 550 of file pcrecpp_unittest.cc.

References CHECK_EQ, and VERBOSE_TEST.

Referenced by Test_UNGREEDY().

int main ( int  argc,
char **  argv 
)

Definition at line 796 of file pcrecpp_unittest.cc.

References a, buf, c, CHECK, CHECK_EQ, pcrecpp::StringPiece::data(), pcrecpp::RE::error(), pcrecpp::RE::FullMatch(), getenv(), i, NULL, pcrecpp::RE::PartialMatch(), pcrecpp::RE::pattern(), RadixTests(), s, pcrecpp::StringPiece::size(), sprintf(), TestConstructors(), TestConsume(), TestExtract(), TestFindAndConsume(), TestMatchNumberPeculiarity(), TestOptions(), TestQuoteMetaAll(), TestRecursion(), TestReplace(), Timing1(), Timing2(), Timing3(), pcrecpp::UTF8(), and VERBOSE_TEST.

static void NegativeTestQuoteMeta ( string  unquoted,
string  should_not_match,
RE_Options  options = RE_Options() 
) [static]

Definition at line 480 of file pcrecpp_unittest.cc.

References CHECK, and pcrecpp::RE::FullMatch().

Referenced by TestQuoteMetaSimpleNegative(), and TestQuoteMetaUtf8().

static void RadixTests (  )  [static]

Definition at line 126 of file pcrecpp_unittest.cc.

References CHECK_DECIMAL, CHECK_HEX, CHECK_OCTAL, and RooFitShortHand::L().

Referenced by main().

static void Test_all_options (  )  [static]

Definition at line 724 of file pcrecpp_unittest.cc.

References PCRE_CASELESS, PCRE_DOTALL, PCRE_EXTENDED, PCRE_MULTILINE, pcrecpp::RE_Options::set_all_options(), str, and TestOneOption().

Referenced by TestOptions().

static void Test_CASELESS (  )  [static]

Definition at line 599 of file pcrecpp_unittest.cc.

References pcrecpp::CASELESS(), pcrecpp::RE_Options::set_caseless(), and TestOneOption().

Referenced by TestOptions().

static void Test_DOLLAR_ENDONLY (  )  [static]

Definition at line 640 of file pcrecpp_unittest.cc.

References pcrecpp::RE_Options::set_dollar_endonly(), str, and TestOneOption().

Referenced by TestOptions().

static void Test_DOTALL (  )  [static]

Definition at line 627 of file pcrecpp_unittest.cc.

References pcrecpp::DOTALL(), pcrecpp::RE_Options::set_dotall(), str, and TestOneOption().

Referenced by TestOptions().

static void Test_EXTENDED (  )  [static]

Definition at line 662 of file pcrecpp_unittest.cc.

References pcrecpp::EXTENDED(), pcrecpp::RE_Options::set_extended(), str, and TestOneOption().

Referenced by TestOptions().

static void Test_EXTRA (  )  [static]

Definition at line 651 of file pcrecpp_unittest.cc.

References pcrecpp::RE_Options::set_extra(), str, and TestOneOption().

Referenced by TestOptions().

static void Test_MULTILINE (  )  [static]

Definition at line 614 of file pcrecpp_unittest.cc.

References pcrecpp::MULTILINE(), pcrecpp::RE_Options::set_multiline(), str, and TestOneOption().

Referenced by TestOptions().

static void Test_NO_AUTO_CAPTURE (  )  [static]

Definition at line 691 of file pcrecpp_unittest.cc.

References CHECK, CHECK_EQ, pcrecpp::RE::Extract(), pcrecpp::RE_Options::set_no_auto_capture(), str, and VERBOSE_TEST.

Referenced by TestOptions().

static void Test_UNGREEDY (  )  [static]

Definition at line 710 of file pcrecpp_unittest.cc.

References GetOneOptionResult(), pcrecpp::RE_Options::set_ungreedy(), and str.

Referenced by TestOptions().

static void TestConstructors (  )  [static]

Definition at line 767 of file pcrecpp_unittest.cc.

References CHECK, pcrecpp::RE::FullMatch(), pcrecpp::RE_Options::set_dotall(), and str.

Referenced by main().

static void TestConsume (  )  [static]

Definition at line 367 of file pcrecpp_unittest.cc.

References CHECK, CHECK_EQ, and s.

Referenced by main().

static void TestExtract (  )  [static]

Definition at line 352 of file pcrecpp_unittest.cc.

References CHECK, CHECK_EQ, and s.

Referenced by main().

static void TestFindAndConsume (  )  [static]

Definition at line 383 of file pcrecpp_unittest.cc.

References CHECK, CHECK_EQ, and s.

Referenced by main().

static void TestMatchNumberPeculiarity (  )  [static]

Definition at line 401 of file pcrecpp_unittest.cc.

References a, CHECK, and CHECK_EQ.

Referenced by main().

static void TestOneOption ( const char *  option_name,
const char *  regex,
const char *  str,
RE_Options  options,
bool  full,
bool  assertive = true 
) [static]

Definition at line 572 of file pcrecpp_unittest.cc.

References CHECK, and VERBOSE_TEST.

Referenced by Test_all_options(), Test_CASELESS(), Test_DOLLAR_ENDONLY(), Test_DOTALL(), Test_EXTENDED(), Test_EXTRA(), and Test_MULTILINE().

static void TestOptions (  )  [static]

Definition at line 754 of file pcrecpp_unittest.cc.

References Test_all_options(), Test_CASELESS(), Test_DOLLAR_ENDONLY(), Test_DOTALL(), Test_EXTENDED(), Test_EXTRA(), Test_MULTILINE(), Test_NO_AUTO_CAPTURE(), and Test_UNGREEDY().

Referenced by main().

static void TestQuotaMetaSimple (  )  [static]

Definition at line 489 of file pcrecpp_unittest.cc.

References TestQuoteMeta().

Referenced by TestQuoteMetaAll().

static void TestQuoteMeta ( string  unquoted,
RE_Options  options = RE_Options() 
) [static]

Definition at line 472 of file pcrecpp_unittest.cc.

References CHECK, and pcrecpp::RE::FullMatch().

Referenced by TestQuotaMetaSimple(), TestQuoteMetaLatin1(), and TestQuoteMetaUtf8().

static void TestQuoteMetaAll (  )  [static]

Definition at line 537 of file pcrecpp_unittest.cc.

References TestQuotaMetaSimple(), TestQuoteMetaLatin1(), TestQuoteMetaSimpleNegative(), and TestQuoteMetaUtf8().

Referenced by main().

static void TestQuoteMetaLatin1 (  )  [static]

Definition at line 518 of file pcrecpp_unittest.cc.

References TestQuoteMeta().

Referenced by TestQuoteMetaAll().

static void TestQuoteMetaSimpleNegative (  )  [static]

Definition at line 503 of file pcrecpp_unittest.cc.

References NegativeTestQuoteMeta().

Referenced by TestQuoteMetaAll().

static void TestQuoteMetaUtf8 (  )  [static]

Definition at line 522 of file pcrecpp_unittest.cc.

References NegativeTestQuoteMeta(), TestQuoteMeta(), and pcrecpp::UTF8().

Referenced by TestQuoteMetaAll().

static void TestRecursion (  )  [static]

Definition at line 428 of file pcrecpp_unittest.cc.

References CHECK, pcrecpp::RE::FullMatch(), pcrecpp::RE::PartialMatch(), and pcrecpp::RE_Options::set_match_limit().

Referenced by main().

static void TestReplace (  )  [static]

Definition at line 207 of file pcrecpp_unittest.cc.

References CHECK, CHECK_EQ, pcrecpp::RE::error(), pcrecpp::RE::GlobalReplace(), NULL, PCRE_NEWLINE_CR, PCRE_NEWLINE_CRLF, PCRE_NEWLINE_LF, regexp(), t, and tests().

Referenced by main().

static void Timing1 ( int  num_iters  )  [static]

Definition at line 68 of file pcrecpp_unittest.cc.

References CHECK, pcrecpp::RE::FullMatch(), j, and p.

Referenced by main().

static void Timing2 ( int  num_iters  )  [static]

Definition at line 77 of file pcrecpp_unittest.cc.

References CHECK, CHECK_EQ, pcrecpp::RE::FullMatch(), i, and j.

Referenced by main().

static void Timing3 ( int  num_iters  )  [static]

Definition at line 87 of file pcrecpp_unittest.cc.

References pcrecpp::RE::Consume(), j, line, and text().

Referenced by main().


Variable Documentation

bool VERBOSE_TEST = false [static]

Definition at line 52 of file pcrecpp_unittest.cc.

Referenced by GetOneOptionResult(), main(), Test_NO_AUTO_CAPTURE(), and TestOneOption().


Generated on Tue Jul 5 15:57:29 2011 for ROOT_528-00b_version by  doxygen 1.5.1