33 |
// |
// |
34 |
// TODO: Test extractions for PartialMatch/Consume |
// TODO: Test extractions for PartialMatch/Consume |
35 |
|
|
36 |
|
#ifdef HAVE_CONFIG_H |
37 |
|
#include <config.h> |
38 |
|
#endif |
39 |
|
|
40 |
#include <stdio.h> |
#include <stdio.h> |
41 |
#include <cassert> |
#include <cassert> |
42 |
#include <vector> |
#include <vector> |
|
#include "config.h" |
|
43 |
#include "pcrecpp.h" |
#include "pcrecpp.h" |
44 |
|
|
45 |
using pcrecpp::StringPiece; |
using pcrecpp::StringPiece; |
908 |
CHECK(!RE("(\\d+)").FullMatch("4294967296", &v)); |
CHECK(!RE("(\\d+)").FullMatch("4294967296", &v)); |
909 |
} |
} |
910 |
#ifdef HAVE_LONG_LONG |
#ifdef HAVE_LONG_LONG |
911 |
|
# if defined(__MINGW__) || defined(__MINGW32__) |
912 |
|
# define LLD "%I64d" |
913 |
|
# define LLU "%I64u" |
914 |
|
# else |
915 |
|
# define LLD "%lld" |
916 |
|
# define LLU "%llu" |
917 |
|
# endif |
918 |
{ |
{ |
919 |
long long v; |
long long v; |
920 |
static const long long max_value = 0x7fffffffffffffffLL; |
static const long long max_value = 0x7fffffffffffffffLL; |
924 |
CHECK(RE("(-?\\d+)").FullMatch("100", &v)); CHECK_EQ(v, 100); |
CHECK(RE("(-?\\d+)").FullMatch("100", &v)); CHECK_EQ(v, 100); |
925 |
CHECK(RE("(-?\\d+)").FullMatch("-100",&v)); CHECK_EQ(v, -100); |
CHECK(RE("(-?\\d+)").FullMatch("-100",&v)); CHECK_EQ(v, -100); |
926 |
|
|
927 |
snprintf(buf, sizeof(buf), "%lld", max_value); |
snprintf(buf, sizeof(buf), LLD, max_value); |
928 |
CHECK(RE("(-?\\d+)").FullMatch(buf,&v)); CHECK_EQ(v, max_value); |
CHECK(RE("(-?\\d+)").FullMatch(buf,&v)); CHECK_EQ(v, max_value); |
929 |
|
|
930 |
snprintf(buf, sizeof(buf), "%lld", min_value); |
snprintf(buf, sizeof(buf), LLD, min_value); |
931 |
CHECK(RE("(-?\\d+)").FullMatch(buf,&v)); CHECK_EQ(v, min_value); |
CHECK(RE("(-?\\d+)").FullMatch(buf,&v)); CHECK_EQ(v, min_value); |
932 |
|
|
933 |
snprintf(buf, sizeof(buf), "%lld", max_value); |
snprintf(buf, sizeof(buf), LLD, max_value); |
934 |
assert(buf[strlen(buf)-1] != '9'); |
assert(buf[strlen(buf)-1] != '9'); |
935 |
buf[strlen(buf)-1]++; |
buf[strlen(buf)-1]++; |
936 |
CHECK(!RE("(-?\\d+)").FullMatch(buf, &v)); |
CHECK(!RE("(-?\\d+)").FullMatch(buf, &v)); |
937 |
|
|
938 |
snprintf(buf, sizeof(buf), "%lld", min_value); |
snprintf(buf, sizeof(buf), LLD, min_value); |
939 |
assert(buf[strlen(buf)-1] != '9'); |
assert(buf[strlen(buf)-1] != '9'); |
940 |
buf[strlen(buf)-1]++; |
buf[strlen(buf)-1]++; |
941 |
CHECK(!RE("(-?\\d+)").FullMatch(buf, &v)); |
CHECK(!RE("(-?\\d+)").FullMatch(buf, &v)); |
951 |
CHECK(RE("(-?\\d+)").FullMatch("100",&v)); CHECK_EQ(v, 100); |
CHECK(RE("(-?\\d+)").FullMatch("100",&v)); CHECK_EQ(v, 100); |
952 |
CHECK(RE("(-?\\d+)").FullMatch("-100",&v2)); CHECK_EQ(v2, -100); |
CHECK(RE("(-?\\d+)").FullMatch("-100",&v2)); CHECK_EQ(v2, -100); |
953 |
|
|
954 |
snprintf(buf, sizeof(buf), "%llu", max_value); |
snprintf(buf, sizeof(buf), LLU, max_value); |
955 |
CHECK(RE("(-?\\d+)").FullMatch(buf,&v)); CHECK_EQ(v, max_value); |
CHECK(RE("(-?\\d+)").FullMatch(buf,&v)); CHECK_EQ(v, max_value); |
956 |
|
|
957 |
assert(buf[strlen(buf)-1] != '9'); |
assert(buf[strlen(buf)-1] != '9'); |