libcryfs/test/cpp-utils/io/ConsoleTest_AskPassword.cpp
2018-09-03 16:51:59 -07:00

23 lines
648 B
C++

#include "ConsoleTest.h"
using std::stringstream;
using std::string;
using std::istream;
using std::ostream;
class ConsoleTest_AskPassword: public ConsoleTest {};
TEST_F(ConsoleTest_AskPassword, InputSomePassword) {
auto chosen = askPassword("Please enter my password:");
EXPECT_OUTPUT_LINE("Please enter my password", ':');
sendInputLine("this is the password");
EXPECT_EQ("this is the password", chosen.get());
}
TEST_F(ConsoleTest_AskPassword, InputEmptyPassword) {
auto chosen = askPassword("Please enter my password:");
EXPECT_OUTPUT_LINE("Please enter my password", ':');
sendInputLine("");
EXPECT_EQ("", chosen.get());
}