mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-08-13 01:26:58 +00:00
update to pcre 7.9
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@13706 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
@@ -32,10 +32,19 @@
|
||||
// Unittest for scanner, especially GetNextComments and GetComments()
|
||||
// functionality.
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <pcre_stringpiece.h>
|
||||
#include <pcre_scanner.h>
|
||||
|
||||
#include "pcrecpp.h"
|
||||
#include "pcre_stringpiece.h"
|
||||
#include "pcre_scanner.h"
|
||||
|
||||
#define FLAGS_unittest_stack_size 49152
|
||||
|
||||
// Dies with a fatal error if the two values are not equal.
|
||||
#define CHECK_EQ(a, b) do { \
|
||||
@@ -116,8 +125,31 @@ static void TestScanner() {
|
||||
comments.resize(0);
|
||||
}
|
||||
|
||||
static void TestBigComment() {
|
||||
string input;
|
||||
for (int i = 0; i < 1024; ++i) {
|
||||
char buf[1024]; // definitely big enough
|
||||
sprintf(buf, " # Comment %d\n", i);
|
||||
input += buf;
|
||||
}
|
||||
input += "name = value;\n";
|
||||
|
||||
Scanner s(input.c_str());
|
||||
s.SetSkipExpression("\\s+|#.*\n");
|
||||
|
||||
string name;
|
||||
string value;
|
||||
s.Consume("(\\w+) = (\\w+);", &name, &value);
|
||||
CHECK_EQ(name, "name");
|
||||
CHECK_EQ(value, "value");
|
||||
}
|
||||
|
||||
// TODO: also test scanner and big-comment in a thread with a
|
||||
// small stack size
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
TestScanner();
|
||||
TestBigComment();
|
||||
|
||||
// Done
|
||||
printf("OK\n");
|
||||
|
Reference in New Issue
Block a user