forked from boostorg/regex
Compare commits
1 Commits
issue183
...
svn-branch
Author | SHA1 | Date | |
---|---|---|---|
61741228da |
@ -1,94 +0,0 @@
|
||||
# copyright John Maddock 2003
|
||||
|
||||
#
|
||||
# This Jamfile tests the ability of some Windows compilers
|
||||
# to automatically link to the right lib file,
|
||||
# it is not generally applicable.
|
||||
#
|
||||
|
||||
subproject libs/regex/test/auto-link-test ;
|
||||
|
||||
# bring in the rules for testing
|
||||
import testing ;
|
||||
|
||||
run
|
||||
# sources
|
||||
<template>../../build/regex-options
|
||||
../regress/parse.cpp
|
||||
../regress/regress.cpp
|
||||
../regress/tests.cpp
|
||||
<lib>../../../test/build/boost_prg_exec_monitor
|
||||
:
|
||||
: # input files
|
||||
../regress/tests.txt
|
||||
: # requirements
|
||||
<library-path>../../../../stage/lib
|
||||
<define>BOOST_LIB_DIAGNOSTIC=1
|
||||
: # program name
|
||||
regex_regress
|
||||
|
||||
;
|
||||
|
||||
run
|
||||
# sources
|
||||
<template>../../build/regex-options
|
||||
../regress/parse.cpp
|
||||
../regress/regress.cpp
|
||||
../regress/tests.cpp
|
||||
<lib>../../../test/build/boost_prg_exec_monitor
|
||||
:
|
||||
: # input files
|
||||
../regress/tests.txt
|
||||
: # requirements
|
||||
<library-path>../../../../stage/lib
|
||||
<define>TEST_UNICODE=1
|
||||
<define>BOOST_LIB_DIAGNOSTIC=1
|
||||
: # program name
|
||||
wide_regex_regress
|
||||
|
||||
;
|
||||
|
||||
# and now the dll versions:
|
||||
|
||||
run
|
||||
# sources
|
||||
<template>../../build/regex-options
|
||||
../regress/parse.cpp
|
||||
../regress/regress.cpp
|
||||
../regress/tests.cpp
|
||||
<lib>../../../test/build/boost_prg_exec_monitor
|
||||
:
|
||||
: # input files
|
||||
../regress/tests.txt
|
||||
: # requirements
|
||||
<library-path>../../../../stage/lib
|
||||
<define>BOOST_ALL_DYN_LINK=1
|
||||
<runtime-link>dynamic
|
||||
<define>BOOST_LIB_DIAGNOSTIC=1
|
||||
: # program name
|
||||
regex_regress_dll
|
||||
|
||||
;
|
||||
|
||||
run
|
||||
# sources
|
||||
<template>../../build/regex-options
|
||||
../regress/parse.cpp
|
||||
../regress/regress.cpp
|
||||
../regress/tests.cpp
|
||||
<lib>../../../test/build/boost_prg_exec_monitor
|
||||
:
|
||||
: # input files
|
||||
../regress/tests.txt
|
||||
: # requirements
|
||||
<define>BOOST_ALL_DYN_LINK=1
|
||||
<runtime-link>dynamic
|
||||
<library-path>../../../../stage/lib
|
||||
<define>TEST_UNICODE=1
|
||||
<define>BOOST_LIB_DIAGNOSTIC=1
|
||||
: # program name
|
||||
wide_regex_regress_dll
|
||||
|
||||
;
|
||||
|
||||
|
@ -1,16 +0,0 @@
|
||||
# copyright John Maddock 2003
|
||||
|
||||
subproject libs/regex/test/captures ;
|
||||
|
||||
EX_SOURCES = c_regex_traits c_regex_traits_common cpp_regex_traits
|
||||
cregex fileiter posix_api regex regex_debug
|
||||
regex_synch w32_regex_traits wide_posix_api instances winstances ;
|
||||
|
||||
lib boost_regex_extra : ../../src/$(EX_SOURCES).cpp <template>../../build/regex-options
|
||||
:
|
||||
<define>BOOST_REGEX_MATCH_EXTRA=1
|
||||
:
|
||||
;
|
||||
|
||||
|
||||
|
@ -1,90 +0,0 @@
|
||||
|
||||
#include <boost/regex.hpp>
|
||||
#include <boost/test/test_tools.hpp>
|
||||
#include <boost/array.hpp>
|
||||
|
||||
#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
|
||||
|
||||
template <class T>
|
||||
void test_captures(const std::string& regx, const std::string& text, T& expected)
|
||||
{
|
||||
boost::regex e(regx);
|
||||
boost::smatch what;
|
||||
if(boost::regex_match(text, what, e, boost::match_extra))
|
||||
{
|
||||
unsigned i, j;
|
||||
BOOST_TEST(what.size() == ARRAY_SIZE(expected));
|
||||
for(i = 0; i < what.size(); ++i)
|
||||
{
|
||||
BOOST_TEST(what.captures(i).size() <= ARRAY_SIZE(expected[i]));
|
||||
for(j = 0; j < what.captures(i).size(); ++j)
|
||||
{
|
||||
BOOST_TEST(what.captures(i)[j] == expected[i][j]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int test_main(int , char* [])
|
||||
{
|
||||
typedef const char* pchar;
|
||||
pchar e1[4][5] =
|
||||
{
|
||||
{ "aBBcccDDDDDeeeeeeee", },
|
||||
{ "a", "BB", "ccc", "DDDDD", "eeeeeeee", },
|
||||
{ "a", "ccc", "eeeeeeee", },
|
||||
{ "BB", "DDDDD", },
|
||||
};
|
||||
test_captures("(([[:lower:]]+)|([[:upper:]]+))+", "aBBcccDDDDDeeeeeeee", e1);
|
||||
pchar e2[4][2] =
|
||||
{
|
||||
{ "abd" },
|
||||
{ "b", "" },
|
||||
{ "" },
|
||||
};
|
||||
test_captures("a(b+|((c)*))+d", "abd", e2);
|
||||
pchar e3[3][1] =
|
||||
{
|
||||
{ "abcbar" },
|
||||
{ "abc" },
|
||||
};
|
||||
test_captures("(.*)bar|(.*)bah", "abcbar", e3);
|
||||
pchar e4[3][1] =
|
||||
{
|
||||
{ "abcbah" },
|
||||
{ 0, },
|
||||
{ "abc" },
|
||||
};
|
||||
test_captures("(.*)bar|(.*)bah", "abcbah", e4);
|
||||
pchar e5[2][16] =
|
||||
{
|
||||
{ "now is the time for all good men to come to the aid of the party" },
|
||||
{ "now", "is", "the", "time", "for", "all", "good", "men", "to", "come", "to", "the", "aid", "of", "the", "party" },
|
||||
};
|
||||
test_captures("^(?:(\\w+)|(?>\\W+))*$", "now is the time for all good men to come to the aid of the party", e5);
|
||||
pchar e6[2][16] =
|
||||
{
|
||||
{ "now is the time for all good men to come to the aid of the party" },
|
||||
{ "now", "is", "the", "time", "for", "all", "good", "men", "to", "come", "to", "the", "aid", "of", "the", "party" },
|
||||
};
|
||||
test_captures("^(?>(\\w+)\\W*)*$", "now is the time for all good men to come to the aid of the party", e6);
|
||||
pchar e7[4][14] =
|
||||
{
|
||||
{ "now is the time for all good men to come to the aid of the party" },
|
||||
{ "now" },
|
||||
{ "is", "the", "time", "for", "all", "good", "men", "to", "come", "to", "the", "aid", "of", "the" },
|
||||
{ "party" },
|
||||
};
|
||||
test_captures("^(\\w+)\\W+(?>(\\w+)\\W+)*(\\w+)$", "now is the time for all good men to come to the aid of the party", e7);
|
||||
pchar e8[5][9] =
|
||||
{
|
||||
{ "now is the time for all good men to come to the aid of the party" } ,
|
||||
{ "now" },
|
||||
{ "is", "for", "men", "to", "of" },
|
||||
{ "the", "time", "all", "good", "to", "come", "the", "aid", "the" },
|
||||
{ "party" },
|
||||
};
|
||||
test_captures("^(\\w+)\\W+(?>(\\w+)\\W+(?:(\\w+)\\W+){0,2})*(\\w+)$", "now is the time for all good men to come to the aid of the party", e8);
|
||||
return 0;
|
||||
}
|
||||
|
Reference in New Issue
Block a user