summaryrefslogtreecommitdiffstats
path: root/tests/unit/commands_test.cpp
diff options
context:
space:
mode:
authorTao Bao <tbao@google.com>2018-05-22 01:05:56 +0200
committerTao Bao <tbao@google.com>2018-07-07 06:12:19 +0200
commit91a649ab62c9cf60ae9d02dd38c23fc23f98a1f3 (patch)
tree0300e0c2d1f901f89d35f93f791174d6693b1296 /tests/unit/commands_test.cpp
parentMerge "tests: Split unit tests out of component/applypatch_test.cpp." (diff)
downloadandroid_bootable_recovery-91a649ab62c9cf60ae9d02dd38c23fc23f98a1f3.tar
android_bootable_recovery-91a649ab62c9cf60ae9d02dd38c23fc23f98a1f3.tar.gz
android_bootable_recovery-91a649ab62c9cf60ae9d02dd38c23fc23f98a1f3.tar.bz2
android_bootable_recovery-91a649ab62c9cf60ae9d02dd38c23fc23f98a1f3.tar.lz
android_bootable_recovery-91a649ab62c9cf60ae9d02dd38c23fc23f98a1f3.tar.xz
android_bootable_recovery-91a649ab62c9cf60ae9d02dd38c23fc23f98a1f3.tar.zst
android_bootable_recovery-91a649ab62c9cf60ae9d02dd38c23fc23f98a1f3.zip
Diffstat (limited to 'tests/unit/commands_test.cpp')
-rw-r--r--tests/unit/commands_test.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/unit/commands_test.cpp b/tests/unit/commands_test.cpp
index cb2be9176..3daa58f33 100644
--- a/tests/unit/commands_test.cpp
+++ b/tests/unit/commands_test.cpp
@@ -159,6 +159,27 @@ TEST(CommandsTest, Parse_EmptyInput) {
ASSERT_EQ("invalid type", err);
}
+TEST(CommandsTest, Parse_ABORT_Allowed) {
+ Command::abort_allowed_ = true;
+
+ const std::string input{ "abort" };
+ std::string err;
+ Command command = Command::Parse(input, 0, &err);
+ ASSERT_TRUE(command);
+
+ ASSERT_EQ(TargetInfo(), command.target());
+ ASSERT_EQ(SourceInfo(), command.source());
+ ASSERT_EQ(StashInfo(), command.stash());
+ ASSERT_EQ(PatchInfo(), command.patch());
+}
+
+TEST(CommandsTest, Parse_ABORT_NotAllowed) {
+ const std::string input{ "abort" };
+ std::string err;
+ Command command = Command::Parse(input, 0, &err);
+ ASSERT_FALSE(command);
+}
+
TEST(CommandsTest, Parse_BSDIFF) {
const std::string input{
"bsdiff 0 148 "
@@ -312,9 +333,12 @@ TEST(CommandsTest, Parse_ZERO) {
}
TEST(CommandsTest, Parse_InvalidNumberOfArgs) {
+ Command::abort_allowed_ = true;
+
// Note that the case of having excess args in BSDIFF, IMGDIFF and MOVE is covered by
// ParseTargetInfoAndSourceInfo_InvalidInput.
std::vector<std::string> inputs{
+ "abort foo",
"bsdiff",
"erase",
"erase 4,3,5,10,12 hash1",