mirror of
https://github.com/boostorg/leaf.git
synced 2026-01-30 07:52:13 +00:00
white space formatting
This commit is contained in:
@@ -10,110 +10,123 @@
|
||||
namespace leaf = boost::leaf;
|
||||
|
||||
template <int A>
|
||||
struct
|
||||
info
|
||||
{
|
||||
struct info
|
||||
{
|
||||
int value;
|
||||
};
|
||||
leaf::error
|
||||
f1()
|
||||
{
|
||||
};
|
||||
|
||||
leaf::error f1()
|
||||
{
|
||||
return leaf::error( info<1>{1} );
|
||||
}
|
||||
leaf::error
|
||||
f2()
|
||||
{
|
||||
}
|
||||
|
||||
leaf::error f2()
|
||||
{
|
||||
return f1().propagate( info<2>{2} );
|
||||
}
|
||||
leaf::error
|
||||
f3()
|
||||
{
|
||||
}
|
||||
|
||||
leaf::error f3()
|
||||
{
|
||||
return f2().propagate( info<3>{3} );
|
||||
}
|
||||
leaf::error
|
||||
f4()
|
||||
{
|
||||
}
|
||||
|
||||
leaf::error f4()
|
||||
{
|
||||
return f3().propagate();
|
||||
}
|
||||
int
|
||||
main()
|
||||
{
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
leaf::expect<info<1>,info<2>,info<4>> exp0;
|
||||
leaf::error e0 = f4();
|
||||
{
|
||||
{
|
||||
int const * p = leaf::peek<info<1>>(exp0,e0);
|
||||
BOOST_TEST(p && *p==1);
|
||||
}
|
||||
{
|
||||
}
|
||||
|
||||
{
|
||||
int const * p = leaf::peek<info<2>>(exp0,e0);
|
||||
BOOST_TEST(p && *p==2);
|
||||
}
|
||||
}
|
||||
|
||||
BOOST_TEST(!leaf::peek<info<4>>(exp0,e0));
|
||||
leaf::expect<info<1>,info<2>,info<4>> exp;
|
||||
leaf::error e1 = f4();
|
||||
{
|
||||
|
||||
{
|
||||
int const * p = leaf::peek<info<1>>(exp0,e0);
|
||||
BOOST_TEST(p && *p==1);
|
||||
}
|
||||
{
|
||||
}
|
||||
|
||||
{
|
||||
int const * p = leaf::peek<info<2>>(exp0,e0);
|
||||
BOOST_TEST(p && *p==2);
|
||||
}
|
||||
}
|
||||
|
||||
BOOST_TEST(!leaf::peek<info<4>>(exp0,e0));
|
||||
BOOST_TEST(!leaf::peek<info<1>>(exp,e0));
|
||||
BOOST_TEST(!leaf::peek<info<2>>(exp,e0));
|
||||
BOOST_TEST(!leaf::peek<info<4>>(exp,e0));
|
||||
{
|
||||
|
||||
{
|
||||
int const * p = leaf::peek<info<1>>(exp,e1);
|
||||
BOOST_TEST(p && *p==1);
|
||||
}
|
||||
{
|
||||
}
|
||||
|
||||
{
|
||||
int const * p = leaf::peek<info<2>>(exp,e1);
|
||||
BOOST_TEST(p && *p==2);
|
||||
}
|
||||
}
|
||||
|
||||
BOOST_TEST(!leaf::peek<info<4>>(exp,e1));
|
||||
BOOST_TEST( !handle_error(exp,e1,leaf::match<info<1>,info<2>,info<4>>()) );
|
||||
leaf::error e2 = f4();
|
||||
{
|
||||
|
||||
{
|
||||
int const * p = leaf::peek<info<1>>(exp,e2);
|
||||
BOOST_TEST(p && *p==1);
|
||||
}
|
||||
{
|
||||
}
|
||||
|
||||
{
|
||||
int const * p = leaf::peek<info<2>>(exp,e2);
|
||||
BOOST_TEST(p && *p==2);
|
||||
}
|
||||
}
|
||||
|
||||
BOOST_TEST(!leaf::peek<info<4>>(exp,e2));
|
||||
{
|
||||
|
||||
{
|
||||
int c1=0, c2=0, c3=0;
|
||||
BOOST_TEST( handle_error( exp, e2,
|
||||
leaf::match<info<1>,info<2>,info<4>>( [&c1]( int, int, int )
|
||||
{
|
||||
{
|
||||
++c1;
|
||||
} ),
|
||||
} ),
|
||||
leaf::match<info<1>,info<2>,info<4>>( [&c2]( int, int, int )
|
||||
{
|
||||
{
|
||||
++c2;
|
||||
} ),
|
||||
} ),
|
||||
leaf::match<info<2>,info<1>>( [&c3]( int i2,int i1 )
|
||||
{
|
||||
{
|
||||
BOOST_TEST(i1==1);
|
||||
BOOST_TEST(i2==2);
|
||||
++c3;
|
||||
} ) ) );
|
||||
} ) ) );
|
||||
BOOST_TEST(c1==0);
|
||||
BOOST_TEST(c2==0);
|
||||
BOOST_TEST(c3==1);
|
||||
}
|
||||
{
|
||||
}
|
||||
|
||||
{
|
||||
int c=0;
|
||||
BOOST_TEST( handle_error( exp0, e0,
|
||||
leaf::match<info<2>,info<1>>( [&c]( int i2,int i1 )
|
||||
{
|
||||
{
|
||||
BOOST_TEST(i1==1);
|
||||
BOOST_TEST(i2==2);
|
||||
++c;
|
||||
} ) ) );
|
||||
} ) ) );
|
||||
BOOST_TEST(c==1);
|
||||
}
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user