diff --git a/src/CryCipher.cpp b/src/config/CryCipher.cpp similarity index 100% rename from src/CryCipher.cpp rename to src/config/CryCipher.cpp diff --git a/src/CryCipher.h b/src/config/CryCipher.h similarity index 100% rename from src/CryCipher.h rename to src/config/CryCipher.h diff --git a/src/CryConfig.cpp b/src/config/CryConfig.cpp similarity index 100% rename from src/CryConfig.cpp rename to src/config/CryConfig.cpp diff --git a/src/CryConfig.h b/src/config/CryConfig.h similarity index 100% rename from src/CryConfig.h rename to src/config/CryConfig.h diff --git a/src/CryConfigLoader.cpp b/src/config/CryConfigLoader.cpp similarity index 98% rename from src/CryConfigLoader.cpp rename to src/config/CryConfigLoader.cpp index a3e24a1d..70d0d0cf 100644 --- a/src/CryConfigLoader.cpp +++ b/src/config/CryConfigLoader.cpp @@ -4,6 +4,8 @@ namespace bf = boost::filesystem; using cpputils::unique_ref; using cpputils::make_unique_ref; +using cpputils::Console; +using cpputils::IOStreamConsole; using boost::optional; using boost::none; using std::vector; diff --git a/src/CryConfigLoader.h b/src/config/CryConfigLoader.h similarity index 89% rename from src/CryConfigLoader.h rename to src/config/CryConfigLoader.h index 90ea5cba..7cd05151 100644 --- a/src/CryConfigLoader.h +++ b/src/config/CryConfigLoader.h @@ -7,14 +7,14 @@ #include "CryConfig.h" #include "CryCipher.h" #include -#include "utils/Console.h" +#include namespace cryfs { class CryConfigLoader { public: CryConfigLoader(); - explicit CryConfigLoader(cpputils::unique_ref console); + explicit CryConfigLoader(cpputils::unique_ref console); cpputils::unique_ref loadOrCreate(const boost::filesystem::path &filename); @@ -37,7 +37,7 @@ private: bool _showWarningForCipherAndReturnIfOk(const std::string &cipherName); - cpputils::unique_ref _console; + cpputils::unique_ref _console; }; } diff --git a/src/CryDevice.cpp b/src/filesystem/CryDevice.cpp similarity index 100% rename from src/CryDevice.cpp rename to src/filesystem/CryDevice.cpp diff --git a/src/CryDevice.h b/src/filesystem/CryDevice.h similarity index 97% rename from src/CryDevice.h rename to src/filesystem/CryDevice.h index 977c8934..8199a5bf 100644 --- a/src/CryDevice.h +++ b/src/filesystem/CryDevice.h @@ -4,7 +4,7 @@ #include #include -#include "CryConfigLoader.h" +#include "../config/CryConfigLoader.h" #include #include diff --git a/src/CryDir.cpp b/src/filesystem/CryDir.cpp similarity index 100% rename from src/CryDir.cpp rename to src/filesystem/CryDir.cpp diff --git a/src/CryDir.h b/src/filesystem/CryDir.h similarity index 100% rename from src/CryDir.h rename to src/filesystem/CryDir.h diff --git a/src/CryFile.cpp b/src/filesystem/CryFile.cpp similarity index 100% rename from src/CryFile.cpp rename to src/filesystem/CryFile.cpp diff --git a/src/CryFile.h b/src/filesystem/CryFile.h similarity index 100% rename from src/CryFile.h rename to src/filesystem/CryFile.h diff --git a/src/CryNode.cpp b/src/filesystem/CryNode.cpp similarity index 100% rename from src/CryNode.cpp rename to src/filesystem/CryNode.cpp diff --git a/src/CryNode.h b/src/filesystem/CryNode.h similarity index 100% rename from src/CryNode.h rename to src/filesystem/CryNode.h diff --git a/src/CryOpenFile.cpp b/src/filesystem/CryOpenFile.cpp similarity index 100% rename from src/CryOpenFile.cpp rename to src/filesystem/CryOpenFile.cpp diff --git a/src/CryOpenFile.h b/src/filesystem/CryOpenFile.h similarity index 100% rename from src/CryOpenFile.h rename to src/filesystem/CryOpenFile.h diff --git a/src/CrySymlink.cpp b/src/filesystem/CrySymlink.cpp similarity index 100% rename from src/CrySymlink.cpp rename to src/filesystem/CrySymlink.cpp diff --git a/src/CrySymlink.h b/src/filesystem/CrySymlink.h similarity index 100% rename from src/CrySymlink.h rename to src/filesystem/CrySymlink.h diff --git a/src/impl/DirBlob.cpp b/src/filesystem/impl/DirBlob.cpp similarity index 100% rename from src/impl/DirBlob.cpp rename to src/filesystem/impl/DirBlob.cpp diff --git a/src/impl/DirBlob.h b/src/filesystem/impl/DirBlob.h similarity index 100% rename from src/impl/DirBlob.h rename to src/filesystem/impl/DirBlob.h diff --git a/src/impl/FileBlob.cpp b/src/filesystem/impl/FileBlob.cpp similarity index 100% rename from src/impl/FileBlob.cpp rename to src/filesystem/impl/FileBlob.cpp diff --git a/src/impl/FileBlob.h b/src/filesystem/impl/FileBlob.h similarity index 100% rename from src/impl/FileBlob.h rename to src/filesystem/impl/FileBlob.h diff --git a/src/impl/MagicNumbers.h b/src/filesystem/impl/MagicNumbers.h similarity index 100% rename from src/impl/MagicNumbers.h rename to src/filesystem/impl/MagicNumbers.h diff --git a/src/impl/SymlinkBlob.cpp b/src/filesystem/impl/SymlinkBlob.cpp similarity index 100% rename from src/impl/SymlinkBlob.cpp rename to src/filesystem/impl/SymlinkBlob.cpp diff --git a/src/impl/SymlinkBlob.h b/src/filesystem/impl/SymlinkBlob.h similarity index 100% rename from src/impl/SymlinkBlob.h rename to src/filesystem/impl/SymlinkBlob.h diff --git a/src/main.cpp b/src/main.cpp index a520c5a7..6eee13eb 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -7,8 +7,8 @@ #include "messmer/fspp/fuse/Fuse.h" #include "messmer/fspp/impl/FilesystemImpl.h" -#include "CryDevice.h" -#include "CryConfigLoader.h" +#include "filesystem/CryDevice.h" +#include "config/CryConfigLoader.h" namespace bf = boost::filesystem; diff --git a/src/utils/Console.cpp b/src/utils/Console.cpp deleted file mode 100644 index 09d40fd4..00000000 --- a/src/utils/Console.cpp +++ /dev/null @@ -1,97 +0,0 @@ -#include "Console.h" - -#include -#include - -using std::string; -using std::vector; -using std::ostream; -using std::istream; -using std::flush; -using std::getline; -using boost::optional; -using boost::none; -using std::function; - -IOStreamConsole::IOStreamConsole(): IOStreamConsole(std::cout, std::cin) { -} - -IOStreamConsole::IOStreamConsole(ostream &output, istream &input): _output(output), _input(input) { -} - -optional parseInt(const string &str) { - try { - string trimmed = str; - boost::algorithm::trim(trimmed); - int parsed = std::stoi(str); - if (std::to_string(parsed) != trimmed) { - return none; - } - return parsed; - } catch (const std::invalid_argument &e) { - return none; - } catch (const std::out_of_range &e) { - return none; - } -} - -function(const std::string &input)> parseUIntWithMinMax(unsigned int min, unsigned int max) { - return [min, max] (const string &input) { - optional parsed = parseInt(input); - if (parsed == none) { - return optional(none); - } - unsigned int value = static_cast(*parsed); - if (value < min || value > max) { - return optional(none); - } - return optional(value); - }; -} - -template -Return IOStreamConsole::_askForChoice(const string &question, function (const string&)> parse) { - optional choice = none; - do { - _output << question << flush; - string choiceStr; - getline(_input, choiceStr); - choice = parse(choiceStr); - } while(choice == none); - return *choice; -} - -unsigned int IOStreamConsole::ask(const string &question, const vector &options) { - if(options.size() == 0) { - throw std::invalid_argument("options should have at least one entry"); - } - _output << "\n" << question << "\n"; - for (unsigned int i = 0; i < options.size(); ++i) { - _output << " [" << (i+1) << "] " << options[i] << "\n"; - } - int choice = _askForChoice("Your choice [1-" + std::to_string(options.size()) + "]: ", parseUIntWithMinMax(1, options.size())); - return choice-1; -} - -function(const string &input)> parseYesNo() { - return [] (const string &input) { - string trimmed = input; - boost::algorithm::trim(trimmed); - if(trimmed == "Y" || trimmed == "y" || trimmed == "Yes" || trimmed == "yes") { - return optional(true); - } else if (trimmed == "N" || trimmed == "n" || trimmed == "No" || trimmed == "no") { - return optional(false); - } else { - return optional(none); - } - }; -} - -bool IOStreamConsole::askYesNo(const string &question) { - _output << "\n" << question << "\n"; - return _askForChoice("Your choice [y/n]: ", parseYesNo()); -} - -void IOStreamConsole::print(const std::string &output) { - _output << output << std::flush; -} diff --git a/src/utils/Console.h b/src/utils/Console.h deleted file mode 100644 index 76fa6047..00000000 --- a/src/utils/Console.h +++ /dev/null @@ -1,33 +0,0 @@ -#pragma once -#ifndef CRYFS_CONSOLE_H -#define CRYFS_CONSOLE_H - -#include -#include -#include -#include - -class Console { -public: - virtual unsigned int ask(const std::string &question, const std::vector &options) = 0; - virtual bool askYesNo(const std::string &question) = 0; - virtual void print(const std::string &output) = 0; -}; - -class IOStreamConsole: public Console { -public: - IOStreamConsole(); - IOStreamConsole(std::ostream &output, std::istream &input); - unsigned int ask(const std::string &question, const std::vector &options) override; - bool askYesNo(const std::string &question) override; - void print(const std::string &output) override; -private: - template - Return _askForChoice(const std::string &question, std::function (const std::string&)> parse); - - std::ostream &_output; - std::istream &_input; -}; - - -#endif diff --git a/test/CryFsTest.cpp b/test/filesystem/CryFsTest.cpp similarity index 92% rename from test/CryFsTest.cpp rename to test/filesystem/CryFsTest.cpp index 3e787cd7..367ccc7a 100644 --- a/test/CryFsTest.cpp +++ b/test/filesystem/CryFsTest.cpp @@ -3,10 +3,10 @@ #include #include #include -#include "../src/CryDevice.h" -#include "../src/CryDir.h" -#include "../src/CryFile.h" -#include "../src/CryOpenFile.h" +#include "../../src/filesystem/CryDevice.h" +#include "../../src/filesystem/CryDir.h" +#include "../../src/filesystem/CryFile.h" +#include "../../src/filesystem/CryOpenFile.h" //TODO (whole project) Make constructors explicit when implicit construction not needed @@ -16,6 +16,7 @@ using cpputils::TempFile; using cpputils::dynamic_pointer_move; using cpputils::make_unique_ref; using cpputils::unique_ref; +using cpputils::Console; using blockstore::ondisk::OnDiskBlockStore; namespace bf = boost::filesystem; diff --git a/test/FileSystemTest.cpp b/test/filesystem/FileSystemTest.cpp similarity index 94% rename from test/FileSystemTest.cpp rename to test/filesystem/FileSystemTest.cpp index 9c7db546..4029e4f3 100644 --- a/test/FileSystemTest.cpp +++ b/test/filesystem/FileSystemTest.cpp @@ -2,7 +2,7 @@ #include #include -#include "../src/CryDevice.h" +#include "../../src/filesystem/CryDevice.h" using cpputils::unique_ref; using cpputils::make_unique_ref; diff --git a/test/utils/ConsoleTest.h b/test/utils/ConsoleTest.h deleted file mode 100644 index 00a29cfa..00000000 --- a/test/utils/ConsoleTest.h +++ /dev/null @@ -1,77 +0,0 @@ -#ifndef CRYFS_CONSOLETEST_H -#define CRYFS_CONSOLETEST_H - -#include - -#include "../../src/utils/Console.h" - -#include -#include -#include - -class ConsoleThread { -public: - ConsoleThread(std::ostream &ostr, std::istream &istr): _console(ostr, istr) {} - std::future ask(const std::string &question, const std::vector &options) { - return std::async(std::launch::async, [this, question, options]() { - return _console.ask(question, options); - }); - } - std::future askYesNo(const std::string &question) { - return std::async(std::launch::async, [this, question]() { - return _console.askYesNo(question); - }); - } - void print(const std::string &output) { - _console.print(output); - } -private: - IOStreamConsole _console; -}; - -class ConsoleTest: public ::testing::Test { -public: - ConsoleTest(): _inputStr(), _outputStr(), _input(&_inputStr), _output(&_outputStr), _console(_output, _input) {} - - void EXPECT_OUTPUT_LINES(std::initializer_list lines) { - for (const std::string &line : lines) { - EXPECT_OUTPUT_LINE(line); - } - } - - void EXPECT_OUTPUT_LINE(const std::string &expected, char delimiter = '\n', const std::string &expected_after_delimiter = "") { - std::string actual; - std::getline(_output, actual, delimiter); - EXPECT_EQ(expected, actual); - for (char expected_char : expected_after_delimiter) { - char actual_char; - _output.get(actual_char); - EXPECT_EQ(expected_char, actual_char); - } - } - - void sendInputLine(const std::string &line) { - _input << line << "\n" << std::flush; - } - - std::future ask(const std::string &question, const std::vector &options) { - return _console.ask(question, options); - } - - std::future askYesNo(const std::string &question) { - return _console.askYesNo(question); - } - - void print(const std::string &output) { - _console.print(output); - } - -private: - cpputils::pipestream _inputStr; - cpputils::pipestream _outputStr; - std::iostream _input; - std::iostream _output; - ConsoleThread _console; -}; - -#endif diff --git a/test/utils/ConsoleTest_Ask.cpp b/test/utils/ConsoleTest_Ask.cpp deleted file mode 100644 index 160c3375..00000000 --- a/test/utils/ConsoleTest_Ask.cpp +++ /dev/null @@ -1,200 +0,0 @@ -#include "ConsoleTest.h" - -using std::stringstream; -using std::string; -using std::vector; -using std::istream; -using std::ostream; -using std::future; -using std::initializer_list; - -class ConsoleTest_Ask: public ConsoleTest {}; - -TEST_F(ConsoleTest_Ask, CrashesWithoutOptions) { - EXPECT_THROW( - (ask("My Question?", {}).get()), - std::invalid_argument - ); -} - -TEST_F(ConsoleTest_Ask, OneOption) { - auto chosen = ask("My Question?", {"First Option"}); - EXPECT_OUTPUT_LINES({ - "", - "My Question?", - " [1] First Option" - }); - EXPECT_OUTPUT_LINE("Your choice [1-1]", ':', " "); - sendInputLine("1"); - EXPECT_EQ(0, chosen.get()); -} - -TEST_F(ConsoleTest_Ask, TwoOptions_ChooseFirst) { - auto chosen = ask("My Question?", {"First Option", "Second Option"}); - EXPECT_OUTPUT_LINES({ - "", - "My Question?", - " [1] First Option", - " [2] Second Option" - }); - EXPECT_OUTPUT_LINE("Your choice [1-2]", ':', " "); - sendInputLine("1"); - EXPECT_EQ(0, chosen.get()); -} - -TEST_F(ConsoleTest_Ask, TwoOptions_ChooseSecond) { - auto chosen = ask("My Question?", {"First Option", "Second Option"}); - EXPECT_OUTPUT_LINES({ - "", - "My Question?", - " [1] First Option", - " [2] Second Option" - }); - EXPECT_OUTPUT_LINE("Your choice [1-2]", ':', " "); - sendInputLine("2"); - EXPECT_EQ(1, chosen.get()); -} - -TEST_F(ConsoleTest_Ask, ThreeOptions_ChooseFirst) { - auto chosen = ask("My Other Question?", {"1st Option", "2nd Option", "3rd Option"}); - EXPECT_OUTPUT_LINES({ - "", - "My Other Question?", - " [1] 1st Option", - " [2] 2nd Option", - " [3] 3rd Option" - }); - EXPECT_OUTPUT_LINE("Your choice [1-3]", ':', " "); - sendInputLine("1"); - EXPECT_EQ(0, chosen.get()); -} - -TEST_F(ConsoleTest_Ask, ThreeOptions_ChooseSecond) { - auto chosen = ask("My Question?", {"1st Option", "2nd Option", "3rd Option"}); - EXPECT_OUTPUT_LINES({ - "", - "My Question?", - " [1] 1st Option", - " [2] 2nd Option", - " [3] 3rd Option" - }); - EXPECT_OUTPUT_LINE("Your choice [1-3]", ':', " "); - sendInputLine("2"); - EXPECT_EQ(1, chosen.get()); -} - -TEST_F(ConsoleTest_Ask, ThreeOptions_ChooseThird) { - auto chosen = ask("My Question?", {"1st Option", "2nd Option", "3rd Option"}); - EXPECT_OUTPUT_LINES({ - "", - "My Question?", - " [1] 1st Option", - " [2] 2nd Option", - " [3] 3rd Option" - }); - EXPECT_OUTPUT_LINE("Your choice [1-3]", ':', " "); - sendInputLine("3"); - EXPECT_EQ(2, chosen.get()); -} - -TEST_F(ConsoleTest_Ask, InputWithLeadingSpaces) { - auto chosen = ask("My Question?", {"First Option", "Second Option"}); - EXPECT_OUTPUT_LINES({ - "", - "My Question?", - " [1] First Option", - " [2] Second Option" - }); - EXPECT_OUTPUT_LINE("Your choice [1-2]", ':', " "); - sendInputLine(" 2"); - EXPECT_EQ(1, chosen.get()); -} - -TEST_F(ConsoleTest_Ask, InputWithFollowingSpaces) { - auto chosen = ask("My Question?", {"First Option", "Second Option"}); - EXPECT_OUTPUT_LINES({ - "", - "My Question?", - " [1] First Option", - " [2] Second Option" - }); - EXPECT_OUTPUT_LINE("Your choice [1-2]", ':', " "); - sendInputLine("2 "); - EXPECT_EQ(1, chosen.get()); -} - -TEST_F(ConsoleTest_Ask, InputWithLeadingAndFollowingSpaces) { - auto chosen = ask("My Question?", {"First Option", "Second Option"}); - EXPECT_OUTPUT_LINES({ - "", - "My Question?", - " [1] First Option", - " [2] Second Option" - }); - EXPECT_OUTPUT_LINE("Your choice [1-2]", ':', " "); - sendInputLine(" 2 "); - EXPECT_EQ(1, chosen.get()); -} - -TEST_F(ConsoleTest_Ask, InputEmptyLine) { - auto chosen = ask("My Question?", {"First Option", "Second Option"}); - EXPECT_OUTPUT_LINES({ - "", - "My Question?", - " [1] First Option", - " [2] Second Option" - }); - EXPECT_OUTPUT_LINE("Your choice [1-2]", ':', " "); - sendInputLine(""); - EXPECT_OUTPUT_LINE("Your choice [1-2]", ':', " "); - sendInputLine(" "); // empty line with space - EXPECT_OUTPUT_LINE("Your choice [1-2]", ':', " "); - sendInputLine("2"); - EXPECT_EQ(1, chosen.get()); -} - -TEST_F(ConsoleTest_Ask, InputWrongNumbers) { - auto chosen = ask("My Question?", {"1st Option", "2nd Option"}); - EXPECT_OUTPUT_LINES({ - "", - "My Question?", - " [1] 1st Option", - " [2] 2nd Option", - }); - EXPECT_OUTPUT_LINE("Your choice [1-2]", ':', " "); - sendInputLine("0"); - EXPECT_OUTPUT_LINE("Your choice [1-2]", ':', " "); - sendInputLine("-1"); - EXPECT_OUTPUT_LINE("Your choice [1-2]", ':', " "); - sendInputLine("3"); - EXPECT_OUTPUT_LINE("Your choice [1-2]", ':', " "); - sendInputLine("1.5"); - EXPECT_OUTPUT_LINE("Your choice [1-2]", ':', " "); - sendInputLine("1,5"); - EXPECT_OUTPUT_LINE("Your choice [1-2]", ':', " "); - sendInputLine("2"); - EXPECT_EQ(1, chosen.get()); -} - -TEST_F(ConsoleTest_Ask, InputNonNumbers) { - auto chosen = ask("My Question?", {"1st Option", "2nd Option"}); - EXPECT_OUTPUT_LINES({ - "", - "My Question?", - " [1] 1st Option", - " [2] 2nd Option", - }); - EXPECT_OUTPUT_LINE("Your choice [1-2]", ':', " "); - sendInputLine("abc"); - EXPECT_OUTPUT_LINE("Your choice [1-2]", ':', " "); - sendInputLine("3a"); // Wrong number and string attached - EXPECT_OUTPUT_LINE("Your choice [1-2]", ':', " "); - sendInputLine("1a"); // Right number but string attached - EXPECT_OUTPUT_LINE("Your choice [1-2]", ':', " "); - sendInputLine("a3"); // Wrong number and string attached - EXPECT_OUTPUT_LINE("Your choice [1-2]", ':', " "); - sendInputLine("a1"); // Right number but string attached - EXPECT_OUTPUT_LINE("Your choice [1-2]", ':', " "); - sendInputLine("2"); - EXPECT_EQ(1, chosen.get()); -} \ No newline at end of file diff --git a/test/utils/ConsoleTest_AskYesNo.cpp b/test/utils/ConsoleTest_AskYesNo.cpp deleted file mode 100644 index c8b88fb2..00000000 --- a/test/utils/ConsoleTest_AskYesNo.cpp +++ /dev/null @@ -1,108 +0,0 @@ -#include "ConsoleTest.h" - -using std::string; - -class ConsoleTest_AskYesNo: public ConsoleTest { -public: - void EXPECT_TRUE_ON_INPUT(const string &input) { - EXPECT_RESULT_ON_INPUT(true, input); - } - - void EXPECT_FALSE_ON_INPUT(const string &input) { - EXPECT_RESULT_ON_INPUT(false, input); - } - - void EXPECT_RESULT_ON_INPUT(const bool expected, const string &input) { - auto chosen = askYesNo("Are you sure blablub?"); - EXPECT_OUTPUT_LINES({"", "Are you sure blablub?"}); - EXPECT_OUTPUT_LINE("Your choice [y/n]", ':', " "); - sendInputLine(input); - EXPECT_EQ(expected, chosen.get()); - } -}; - -TEST_F(ConsoleTest_AskYesNo, Input_Yes) { - EXPECT_TRUE_ON_INPUT("Yes"); -} - -TEST_F(ConsoleTest_AskYesNo, Input_yes) { - EXPECT_TRUE_ON_INPUT("yes"); -} - -TEST_F(ConsoleTest_AskYesNo, Input_Y) { - EXPECT_TRUE_ON_INPUT("Y"); -} - -TEST_F(ConsoleTest_AskYesNo, Input_y) { - EXPECT_TRUE_ON_INPUT("y"); -} - -TEST_F(ConsoleTest_AskYesNo, Input_No) { - EXPECT_FALSE_ON_INPUT("No"); -} - -TEST_F(ConsoleTest_AskYesNo, Input_no) { - EXPECT_FALSE_ON_INPUT("no"); -} - -TEST_F(ConsoleTest_AskYesNo, Input_N) { - EXPECT_FALSE_ON_INPUT("N"); -} - -TEST_F(ConsoleTest_AskYesNo, Input_n) { - EXPECT_FALSE_ON_INPUT("n"); -} - -TEST_F(ConsoleTest_AskYesNo, InputWithLeadingSpaces) { - EXPECT_TRUE_ON_INPUT(" y"); -} - -TEST_F(ConsoleTest_AskYesNo, InputWithFollowingSpaces) { - EXPECT_TRUE_ON_INPUT("y "); -} - -TEST_F(ConsoleTest_AskYesNo, InputWithLeadingAndFollowingSpaces) { - EXPECT_TRUE_ON_INPUT(" y "); -} - -TEST_F(ConsoleTest_AskYesNo, InputEmptyLine) { - auto chosen = askYesNo("My Question?"); - EXPECT_OUTPUT_LINES({"", "My Question?"}); - EXPECT_OUTPUT_LINE("Your choice [y/n]", ':', " "); - sendInputLine(""); - EXPECT_OUTPUT_LINE("Your choice [y/n]", ':', " "); - sendInputLine(" "); // empty line with space - EXPECT_OUTPUT_LINE("Your choice [y/n]", ':', " "); - sendInputLine("y"); - EXPECT_EQ(true, chosen.get()); -} - -TEST_F(ConsoleTest_AskYesNo, WrongInput) { - auto chosen = askYesNo("My Question?"); - EXPECT_OUTPUT_LINES({"", "My Question?"}); - EXPECT_OUTPUT_LINE("Your choice [y/n]", ':', " "); - sendInputLine("0"); - EXPECT_OUTPUT_LINE("Your choice [y/n]", ':', " "); - sendInputLine("1"); - EXPECT_OUTPUT_LINE("Your choice [y/n]", ':', " "); - sendInputLine("bla"); - EXPECT_OUTPUT_LINE("Your choice [y/n]", ':', " "); - sendInputLine("Y_andsomethingelse"); - EXPECT_OUTPUT_LINE("Your choice [y/n]", ':', " "); - sendInputLine("y_andsomethingelse"); - EXPECT_OUTPUT_LINE("Your choice [y/n]", ':', " "); - sendInputLine("N_andsomethingelse"); - EXPECT_OUTPUT_LINE("Your choice [y/n]", ':', " "); - sendInputLine("n_andsomethingelse"); - EXPECT_OUTPUT_LINE("Your choice [y/n]", ':', " "); - sendInputLine("Yes_andsomethingelse"); - EXPECT_OUTPUT_LINE("Your choice [y/n]", ':', " "); - sendInputLine("yes_andsomethingelse"); - EXPECT_OUTPUT_LINE("Your choice [y/n]", ':', " "); - sendInputLine("No_andsomethingelse"); - EXPECT_OUTPUT_LINE("Your choice [y/n]", ':', " "); - sendInputLine("no_andsomethingelse"); - EXPECT_OUTPUT_LINE("Your choice [y/n]", ':', " "); - sendInputLine("y"); - EXPECT_EQ(true, chosen.get()); -} diff --git a/test/utils/ConsoleTest_Print.cpp b/test/utils/ConsoleTest_Print.cpp deleted file mode 100644 index e38585ee..00000000 --- a/test/utils/ConsoleTest_Print.cpp +++ /dev/null @@ -1,6 +0,0 @@ -#include "ConsoleTest.h" - -TEST_F(ConsoleTest, Print) { - print("Bla Blub"); - EXPECT_OUTPUT_LINE("Bla Blu", 'b'); // 'b' is the delimiter for reading -}