| 1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- //
- // exception_test.cxx
- // dice-td
- //
- // Created by Sam Jaffe on 12/18/18.
- // Copyright © 2018 Sam Jaffe. All rights reserved.
- //
- #include "xcode_gtest_helper.h"
- #include "dice-roll/die.h"
- #include "dice-roll/exception.h"
- using namespace ::testing;
- TEST(DiceExceptionTest, PointerIsActuallyAtTheRightLocation) {
- std::string bad{"6d+1"};
- try {
- dice::from_string(bad);
- FAIL();
- } catch (dice::unexpected_token const & e) {
- EXPECT_THAT(e.pointer().length(), Eq(2));
- }
- }
- TEST(DiceExceptionTest, ErrorAtEndHasSpecialToken) {
- std::string bad{"6d"};
- try {
- dice::from_string(bad);
- FAIL();
- } catch (dice::unexpected_token const & e) {
- EXPECT_THAT(e.pointer(), Eq("<END>"));
- }
- }
- TEST(DiceExceptionTest, ErrorAtEndCanUseFallback) {
- std::string bad{"6d"};
- try {
- dice::from_string(bad);
- FAIL();
- } catch (dice::unexpected_token const & e) {
- EXPECT_THAT(e.pointer(bad.length()), Eq("~^"));
- }
- }
|