summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorTao Bao <tbao@google.com>2018-06-26 05:46:12 +0200
committerandroid-build-merger <android-build-merger@google.com>2018-06-26 05:46:12 +0200
commit33cfd108ca418fd06861d740a2ffd7de3e9e4795 (patch)
tree0d513599175d5b036caab87796daca90b2205139 /tests
parentMerge "updater: Add Command parsing codes." am: afc2962e60 (diff)
parentMerge "updater: Check the number of args in Command::Parse." (diff)
downloadandroid_bootable_recovery-33cfd108ca418fd06861d740a2ffd7de3e9e4795.tar
android_bootable_recovery-33cfd108ca418fd06861d740a2ffd7de3e9e4795.tar.gz
android_bootable_recovery-33cfd108ca418fd06861d740a2ffd7de3e9e4795.tar.bz2
android_bootable_recovery-33cfd108ca418fd06861d740a2ffd7de3e9e4795.tar.lz
android_bootable_recovery-33cfd108ca418fd06861d740a2ffd7de3e9e4795.tar.xz
android_bootable_recovery-33cfd108ca418fd06861d740a2ffd7de3e9e4795.tar.zst
android_bootable_recovery-33cfd108ca418fd06861d740a2ffd7de3e9e4795.zip
Diffstat (limited to 'tests')
-rw-r--r--tests/unit/commands_test.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/unit/commands_test.cpp b/tests/unit/commands_test.cpp
index bbc83b9a8..cb2be9176 100644
--- a/tests/unit/commands_test.cpp
+++ b/tests/unit/commands_test.cpp
@@ -310,3 +310,28 @@ TEST(CommandsTest, Parse_ZERO) {
ASSERT_EQ(StashInfo(), command.stash());
ASSERT_EQ(PatchInfo(), command.patch());
}
+
+TEST(CommandsTest, Parse_InvalidNumberOfArgs) {
+ // Note that the case of having excess args in BSDIFF, IMGDIFF and MOVE is covered by
+ // ParseTargetInfoAndSourceInfo_InvalidInput.
+ std::vector<std::string> inputs{
+ "bsdiff",
+ "erase",
+ "erase 4,3,5,10,12 hash1",
+ "free",
+ "free id1 id2",
+ "imgdiff",
+ "move",
+ "new",
+ "new 4,3,5,10,12 hash1",
+ "stash",
+ "stash id1",
+ "stash id1 4,3,5,10,12 id2",
+ "zero",
+ "zero 4,3,5,10,12 hash2",
+ };
+ for (const auto& input : inputs) {
+ std::string err;
+ ASSERT_FALSE(Command::Parse(input, 0, &err));
+ }
+}