| 12345678910111213141516171819202122232425262728293031323334 |
- //
- // prompt_test.cxx
- // cli-test
- //
- // Created by Sam Jaffe on 10/10/20.
- // Copyright © 2020 Sam Jaffe. All rights reserved.
- //
- #include "cli/prompt.h"
- #include "xcode_gtest_helper.h"
- TEST(PromptTest, WillOutputEverythingInMessageWithNoSpaces) {
- std::stringstream out;
- auto msg = cli::make_message("Example", 1, true);
- msg->print(out);
- EXPECT_THAT(out.str(), "Example1true");
- }
- TEST(PromptTest, WillRepollIfBadDataProvided) {
- std::stringstream in{"cake\n1"};
- cli::prompt prompt;
-
- int i = prompt.read<int>(in);
- EXPECT_THAT(i, 1);
- }
- TEST(PromptTest, WillDiscardEntireLineOnFailedParse) {
- std::stringstream in{"cake 2\n1"};
- cli::prompt prompt;
-
- int i = prompt.read<int>(in);
- EXPECT_THAT(i, 1);
- }
|