|
|
@@ -26,18 +26,18 @@ bool operator==(die const & lhs, unsigned_die const & rhs) {
|
|
|
|
|
|
using namespace ::testing;
|
|
|
|
|
|
-TEST(Parser, ThrowsOnEmptyString) {
|
|
|
+TEST(ParserTest, ThrowsOnEmptyString) {
|
|
|
EXPECT_THROW(dice::from_string(""), dice::unexpected_token);
|
|
|
}
|
|
|
|
|
|
-TEST(Parser, ThrowsOnOpeningArithmetic) {
|
|
|
+TEST(ParserTest, ThrowsOnOpeningArithmetic) {
|
|
|
EXPECT_THROW(dice::from_string("+5"), dice::unexpected_token);
|
|
|
EXPECT_THROW(dice::from_string("-5"), dice::unexpected_token);
|
|
|
EXPECT_THROW(dice::from_string("+1d4"), dice::unexpected_token);
|
|
|
EXPECT_THROW(dice::from_string("-1d4"), dice::unexpected_token);
|
|
|
}
|
|
|
|
|
|
-TEST(Parser, Implicit1dN) {
|
|
|
+TEST(ParserTest, Implicit1dN) {
|
|
|
dice::dice capture;
|
|
|
EXPECT_NO_THROW(capture = dice::from_string("d4"));
|
|
|
EXPECT_THAT(capture.num, Eq(1));
|
|
|
@@ -45,7 +45,7 @@ TEST(Parser, Implicit1dN) {
|
|
|
EXPECT_THAT(capture.of[0], Eq(unsigned_die(1, 4)));
|
|
|
}
|
|
|
|
|
|
-TEST(Parser, Explicit1dN) {
|
|
|
+TEST(ParserTest, Explicit1dN) {
|
|
|
dice::dice capture;
|
|
|
EXPECT_NO_THROW(capture = dice::from_string("1d4"));
|
|
|
EXPECT_THAT(capture.num, Eq(1));
|
|
|
@@ -53,11 +53,11 @@ TEST(Parser, Explicit1dN) {
|
|
|
EXPECT_THAT(capture.of[0], Eq(unsigned_die(1, 4)));
|
|
|
}
|
|
|
|
|
|
-TEST(Parser, CannotImplicitNumberOfSides) {
|
|
|
+TEST(ParserTest, CannotImplicitNumberOfSides) {
|
|
|
EXPECT_THROW(dice::from_string("1d"), dice::unexpected_token);
|
|
|
}
|
|
|
|
|
|
-TEST(Parser, AllowsMultipleDice) {
|
|
|
+TEST(ParserTest, AllowsMultipleDice) {
|
|
|
dice::dice capture;
|
|
|
EXPECT_NO_THROW(capture = dice::from_string("1d4+1d6"));
|
|
|
EXPECT_THAT(capture.of, SizeIs(2));
|
|
|
@@ -65,7 +65,7 @@ TEST(Parser, AllowsMultipleDice) {
|
|
|
Eq(unsigned_die(1, 6))));
|
|
|
}
|
|
|
|
|
|
-TEST(Parser, CanIncludeConstant) {
|
|
|
+TEST(ParserTest, CanIncludeConstant) {
|
|
|
dice::dice capture;
|
|
|
EXPECT_NO_THROW(capture = dice::from_string("1d4+1"));
|
|
|
EXPECT_THAT(capture.of, SizeIs(1));
|
|
|
@@ -73,7 +73,7 @@ TEST(Parser, CanIncludeConstant) {
|
|
|
EXPECT_THAT(capture.modifier[0].value, 1);
|
|
|
}
|
|
|
|
|
|
-TEST(Parser, ConstantSignIsInSgnMember) {
|
|
|
+TEST(ParserTest, ConstantSignIsInSgnMember) {
|
|
|
dice::dice capture;
|
|
|
EXPECT_NO_THROW(capture = dice::from_string("1d4-1"));
|
|
|
EXPECT_THAT(capture.of, SizeIs(1));
|
|
|
@@ -81,22 +81,22 @@ TEST(Parser, ConstantSignIsInSgnMember) {
|
|
|
EXPECT_THAT(capture.modifier[0].value, 1);
|
|
|
}
|
|
|
|
|
|
-TEST(Parser, ThrowsIfUnterminatedArithmatic) {
|
|
|
+TEST(ParserTest, ThrowsIfUnterminatedArithmatic) {
|
|
|
EXPECT_THROW(dice::from_string("1d4+"), dice::unexpected_token);
|
|
|
}
|
|
|
|
|
|
-TEST(Parser, CanProduceMultiRollExpression) {
|
|
|
+TEST(ParserTest, CanProduceMultiRollExpression) {
|
|
|
dice::dice capture;
|
|
|
EXPECT_NO_THROW(capture = dice::from_string("2{d4}"));
|
|
|
EXPECT_THAT(capture.num, Eq(2));
|
|
|
EXPECT_THAT(capture.of, SizeIs(1));
|
|
|
}
|
|
|
|
|
|
-TEST(Parser, MultiRollWillThrowIfNoEndBrace) {
|
|
|
+TEST(ParserTest, MultiRollWillThrowIfNoEndBrace) {
|
|
|
EXPECT_THROW(dice::from_string("2{d4"), dice::unexpected_token);
|
|
|
}
|
|
|
|
|
|
-TEST(Parser, IgnoresWhitespace) {
|
|
|
+TEST(ParserTest, IgnoresWhitespace) {
|
|
|
dice::dice capture;
|
|
|
EXPECT_NO_THROW(capture = dice::from_string("2 { d 4 + 5 }"));
|
|
|
EXPECT_THAT(capture.num, Eq(2));
|
|
|
@@ -104,28 +104,28 @@ TEST(Parser, IgnoresWhitespace) {
|
|
|
EXPECT_THAT(capture.modifier, SizeIs(1));
|
|
|
}
|
|
|
|
|
|
-TEST(Parser, CanParseDC) {
|
|
|
+TEST(ParserTest, CanParseDC) {
|
|
|
EXPECT_NO_THROW(dice::from_string("1d20<10"));
|
|
|
EXPECT_NO_THROW(dice::from_string("1d20<=10"));
|
|
|
EXPECT_NO_THROW(dice::from_string("1d20>10"));
|
|
|
EXPECT_NO_THROW(dice::from_string("1d20>=10"));
|
|
|
}
|
|
|
|
|
|
-TEST(Parser, CanParseDCForMultiroll) {
|
|
|
+TEST(ParserTest, CanParseDCForMultiroll) {
|
|
|
EXPECT_NO_THROW(dice::from_string("2{1d20<10}"));
|
|
|
EXPECT_NO_THROW(dice::from_string("2{1d20<=10}"));
|
|
|
EXPECT_NO_THROW(dice::from_string("2{1d20>10}"));
|
|
|
EXPECT_NO_THROW(dice::from_string("2{1d20>=10}"));
|
|
|
}
|
|
|
|
|
|
-TEST(Parser, MultirollDCMustAppearInsideBrackets) {
|
|
|
+TEST(ParserTest, MultirollDCMustAppearInsideBrackets) {
|
|
|
EXPECT_NO_THROW(dice::from_string("2{1d20}<10"));
|
|
|
EXPECT_NO_THROW(dice::from_string("2{1d20}<=10"));
|
|
|
EXPECT_NO_THROW(dice::from_string("2{1d20}>10"));
|
|
|
EXPECT_NO_THROW(dice::from_string("2{1d20}>=10"));
|
|
|
}
|
|
|
|
|
|
-TEST(Parser, DCIsCaptured) {
|
|
|
+TEST(ParserTest, DCIsCaptured) {
|
|
|
using test = dice::difficulty_class::test;
|
|
|
EXPECT_THAT(dice::from_string("1d20<10").dc.against, 10);
|
|
|
EXPECT_THAT(dice::from_string("1d20<10").dc.comp, test::Less);
|
|
|
@@ -134,19 +134,19 @@ TEST(Parser, DCIsCaptured) {
|
|
|
EXPECT_THAT(dice::from_string("1d20>=10").dc.comp, test::GreaterOrEqual);
|
|
|
}
|
|
|
|
|
|
-TEST(DiceIO, StringFormIsExplicit) {
|
|
|
+TEST(DiceIOTest, StringFormIsExplicit) {
|
|
|
std::stringstream ss;
|
|
|
ss << dice::from_string("2{2d6-d4+5}");
|
|
|
EXPECT_THAT(ss.str(), Eq("2{2d6-1d4+5}"));
|
|
|
}
|
|
|
|
|
|
-TEST(DiceIO, AllModifiersComeAtTheEnd) {
|
|
|
+TEST(DiceIOTest, AllModifiersComeAtTheEnd) {
|
|
|
std::stringstream ss;
|
|
|
ss << dice::from_string("2d6-4-1d6+5");
|
|
|
EXPECT_THAT(ss.str(), Eq("2d6-1d6-4+5"));
|
|
|
}
|
|
|
|
|
|
-TEST(DiceIO, StringFormDoesNotPreserveWhitespace) {
|
|
|
+TEST(DiceIOTest, StringFormDoesNotPreserveWhitespace) {
|
|
|
std::stringstream ss;
|
|
|
ss << dice::from_string("2 { d 4 + 5 }");
|
|
|
EXPECT_THAT(ss.str(), Eq("2{1d4+5}"));
|