diff options
author | Tianjie Xu <xunchang@google.com> | 2018-08-14 18:57:01 +0200 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2018-08-14 18:57:01 +0200 |
commit | 66afc7f16ff87ecbe3b8deb280c2c1512c78f490 (patch) | |
tree | e4710cf9c00559878eaadfc12b49fce66b2e2158 /tests/unit/commands_test.cpp | |
parent | Merge "Reland "Build and use minadbd as a shared library."" am: 337bd80b78 am: 7785eec4f2 (diff) | |
parent | Merge "Add the hash_tree_info class in Command" am: c0195801dc (diff) | |
download | android_bootable_recovery-66afc7f16ff87ecbe3b8deb280c2c1512c78f490.tar android_bootable_recovery-66afc7f16ff87ecbe3b8deb280c2c1512c78f490.tar.gz android_bootable_recovery-66afc7f16ff87ecbe3b8deb280c2c1512c78f490.tar.bz2 android_bootable_recovery-66afc7f16ff87ecbe3b8deb280c2c1512c78f490.tar.lz android_bootable_recovery-66afc7f16ff87ecbe3b8deb280c2c1512c78f490.tar.xz android_bootable_recovery-66afc7f16ff87ecbe3b8deb280c2c1512c78f490.tar.zst android_bootable_recovery-66afc7f16ff87ecbe3b8deb280c2c1512c78f490.zip |
Diffstat (limited to 'tests/unit/commands_test.cpp')
-rw-r--r-- | tests/unit/commands_test.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/unit/commands_test.cpp b/tests/unit/commands_test.cpp index 9679a9e73..19841d676 100644 --- a/tests/unit/commands_test.cpp +++ b/tests/unit/commands_test.cpp @@ -333,6 +333,25 @@ TEST(CommandsTest, Parse_ZERO) { ASSERT_EQ(PatchInfo(), command.patch()); } +TEST(CommandsTest, Parse_COMPUTE_HASH_TREE) { + const std::string input{ "compute_hash_tree 2,0,1 2,3,4 sha1 unknown-salt unknown-root-hash" }; + std::string err; + Command command = Command::Parse(input, 9, &err); + ASSERT_TRUE(command); + + ASSERT_EQ(Command::Type::COMPUTE_HASH_TREE, command.type()); + ASSERT_EQ(9, command.index()); + ASSERT_EQ(input, command.cmdline()); + + HashTreeInfo expected_info(RangeSet({ { 0, 1 } }), RangeSet({ { 3, 4 } }), "sha1", "unknown-salt", + "unknown-root-hash"); + ASSERT_EQ(expected_info, command.hash_tree_info()); + ASSERT_EQ(TargetInfo(), command.target()); + ASSERT_EQ(SourceInfo(), command.source()); + ASSERT_EQ(StashInfo(), command.stash()); + ASSERT_EQ(PatchInfo(), command.patch()); +} + TEST(CommandsTest, Parse_InvalidNumberOfArgs) { Command::abort_allowed_ = true; @@ -341,6 +360,7 @@ TEST(CommandsTest, Parse_InvalidNumberOfArgs) { std::vector<std::string> inputs{ "abort foo", "bsdiff", + "compute_hash_tree, 2,0,1 2,0,1 unknown-algorithm unknown-salt", "erase", "erase 4,3,5,10,12 hash1", "free", |