MCPcopy Create free account
hub / github.com/boostorg/parser / main

Function main

test/split.cpp:29–275  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

27#endif
28
29int main()
30{
31
32// split_
33{
34 {
35 auto r = bp::split("", bp::lit("XYZ"), bp::ws);
36 int count = 0;
37 for (auto subrange : r) {
38 (void)subrange;
39 ++count;
40 }
41 BOOST_TEST(count == 0);
42 }
43 {
44 char const str[] = "aaXYZb";
45 auto r = bp::split(str, bp::lit("XYZ"), bp::ws);
46 int count = 0;
47 int const offsets[] = {0, 2, 5, 6};
48 for (auto subrange : r) {
49 BOOST_TEST(subrange.begin() - str == offsets[count * 2 + 0]);
50 BOOST_TEST(subrange.end() - str == offsets[count * 2 + 1]);
51 ++count;
52 }
53 BOOST_TEST(count == 2);
54 }
55 {
56 char const str[] = "aaXYZbaabaXYZ";
57 auto r = str | bp::split(bp::lit("XYZ"), bp::ws, bp::trace::off);
58 int count = 0;
59 int const offsets[] = {0, 2, 5, 10, 13, 13};
60 for (auto subrange : r) {
61 BOOST_TEST(subrange.begin() - str == offsets[count * 2 + 0]);
62 BOOST_TEST(subrange.end() - str == offsets[count * 2 + 1]);
63 ++count;
64 }
65 BOOST_TEST(count == 3);
66 }
67 {
68 char const str[] = "aaXYZbaabaXYZ";
69 auto r = str | bp::split(bp::lit("XYZ"), bp::trace::off);
70 int count = 0;
71 int const offsets[] = {0, 2, 5, 10, 13, 13};
72 for (auto subrange : r) {
73 BOOST_TEST(subrange.begin() - str == offsets[count * 2 + 0]);
74 BOOST_TEST(subrange.end() - str == offsets[count * 2 + 1]);
75 ++count;
76 }
77 BOOST_TEST(count == 3);
78 }
79 {
80 char const str[] = "aaXYZbaabaXYZ";
81 auto r = str | bp::split(bp::lit("XYZ"));
82 int count = 0;
83 int const offsets[] = {0, 2, 5, 10, 13, 13};
84 for (auto subrange : r) {
85 BOOST_TEST(subrange.begin() - str == offsets[count * 2 + 0]);
86 BOOST_TEST(subrange.end() - str == offsets[count * 2 + 1]);

Callers

nothing calls this directly

Calls 5

litFunction · 0.85
null_termFunction · 0.85
beginMethod · 0.45
endMethod · 0.45
baseMethod · 0.45

Tested by

no test coverage detected