1 #include "unicode_config.h"
14 class collect_wordbreakflags : public mail::wordbreak_callback_base {
18 std::vector<bool> flags;
20 template<typename iter_type> void operator()(iter_type b, iter_type e)
22 mail::wordbreak_callback_base::operator()(b, e);
25 using mail::wordbreak_callback_base::operator<<;
28 int operator()(bool flag)
30 flags.push_back(flag);
35 static void testsuite()
40 std::ifstream fp("WordBreakTest.txt");
49 if (std::getline(fp, buf).eof() && buf.empty())
54 buf.erase(std::find(buf.begin(), buf.end(), '#'), buf.end());
59 std::list<std::string> words;
61 for (std::string::iterator b=buf.begin(), e=buf.end(); b != e;)
69 std::string::iterator p=b;
78 words.push_back(std::string(p, b));
81 std::vector<unicode_char> ubuf;
82 std::vector<bool> status;
86 if (!words.empty() && words.front().size() > 1)
89 std::string s=words.front();
93 if ((unsigned char)s[0] ==
94 (unsigned char)0xc3 &&
95 (unsigned char)s[1] == (unsigned char)0xb7)
101 status.push_back(flag);
103 std::istringstream i(words.front());
118 std::cerr << "Parse error, line " << linenum
119 << ": " << buf << std::endl;
127 collect_wordbreakflags flags;
129 flags(ubuf.begin(), ubuf.end());
132 if (status != flags.flags)
134 std::cerr << "Regression, line " << linenum
135 << ": " << buf << std::endl;
141 int main(int argc, char **argv)