forked from Alepha/Alepha
Testing improvements.
This commit is contained in:
@ -50,12 +50,17 @@ namespace
|
||||
{ "Negative case", { -10, -20 }, -30 },
|
||||
};
|
||||
|
||||
struct DerivedError : std::runtime_error
|
||||
{
|
||||
using std::runtime_error::runtime_error;
|
||||
};
|
||||
|
||||
"Can we use Aggregates with universal cases, correctly?"_test <=
|
||||
TableTest
|
||||
<
|
||||
[]( const int x )
|
||||
{
|
||||
if( x < 0 ) throw std::runtime_error{ "Cannot be negative." };
|
||||
if( x < 0 ) throw DerivedError{ "Cannot be negative." };
|
||||
return Aggregate{ x, x, x };
|
||||
}
|
||||
>
|
||||
@ -66,16 +71,19 @@ namespace
|
||||
{ "Ignore exceptions case (`std::type_identity< void >`)", { 42 }, std::type_identity< void >{} },
|
||||
{ "Expect exception type runtime_error", { -42 }, std::type_identity< std::runtime_error >{} },
|
||||
{ "Expect exception type exception", { -42 }, std::type_identity< std::exception >{} },
|
||||
{ "Expect exception value specific", { -42 }, std::runtime_error{ "Cannot be negative." } },
|
||||
{ "Expect exception value specific", { -42 }, DerivedError{ "Cannot be negative." } },
|
||||
{ "Expect exception value specific (loose)", { -42 }, std::runtime_error{ "Cannot be negative." } },
|
||||
|
||||
/* These cases should fail, but we don't want to fail them in normal builds. */
|
||||
#if 0
|
||||
{ "Failing: Basic value case", { -42 }, { 42, 42, 42 } },
|
||||
{ "Failing: Ignore exceptions case (`std::nothrow`)", { -42 }, std::nothrow },
|
||||
{ "Failing: Ignore exceptions case (`std::type_identity< void >`)", { -42 }, std::type_identity< void >{} },
|
||||
{ "Failing: Expect exception type runtime_error", { 42 }, std::type_identity< std::runtime_error >{} },
|
||||
{ "Failing: Expect exception type exception", { 42 }, std::type_identity< std::exception >{} },
|
||||
{ "Failing: Expect exception value specific", { 42 }, std::runtime_error{ "Cannot be negative." } },
|
||||
{ "Basic value case", { -42 }, { 42, 42, 42 } },
|
||||
{ "Ignore exceptions case (`std::nothrow`)", { -42 }, std::nothrow },
|
||||
{ "Ignore exceptions case (`std::type_identity< void >`)", { -42 }, std::type_identity< void >{} },
|
||||
{ "Expect exception type runtime_error", { 42 }, std::type_identity< std::runtime_error >{} },
|
||||
{ "Expect exception type exception", { 42 }, std::type_identity< std::exception >{} },
|
||||
{ "Expect exception value specific", { 42 }, DerivedError{ "Cannot be negative." } },
|
||||
{ "Expect exception value specific (loose)", { 42 }, std::runtime_error{ "Cannot be negative." } },
|
||||
{ "Expect exception value specific (wrong)", { -42 }, std::logic_error{ "Cannot be negative." } },
|
||||
#endif
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user