/* * * Copyright (c) 2006 * Torsten Landschoff * * Use, modification and distribution are subject to the * Boost Software License, Version 1.0. (See accompanying file * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) * */ #include "test.hpp" #define BOOST_REGEX_TEST(x)\ if(!(x)){ BOOST_REGEX_TEST_ERROR("Error in: " BOOST_STRINGIZE(x), char); } void test_smatch() { boost::regex re("(A?)(B?)"); const char text[] = "AB"; boost::cmatch cm; BOOST_REGEX_TEST(boost::regex_match(text, cm, re)); BOOST_REGEX_TEST(cm[0].matched && cm[0] == text); BOOST_REGEX_TEST(cm[1].matched && cm[1] == "A"); BOOST_REGEX_TEST(cm[2].matched && cm[2] == "B"); boost::smatch sm; BOOST_REGEX_TEST(boost::regex_match(std::string(text), sm, re)); BOOST_REGEX_TEST(sm[0].matched && sm[0] == text); BOOST_REGEX_TEST(sm[1].matched && sm[1] == "A"); BOOST_REGEX_TEST(sm[2].matched && sm[2] == "B"); }