chore(3p/nix/hash): add decoding tests
Change-Id: Ifbeaf1822fa920f929482510ee79a5b24d7976ae Reviewed-on: https://cl.tvl.fyi/c/depot/+/1485 Tested-by: BuildkiteCI Reviewed-by: tazjin <mail@tazj.in>
This commit is contained in:
parent
d4c9a8afda
commit
ec349328e0
1 changed files with 19 additions and 0 deletions
19
third_party/nix/src/tests/hash_test.cc
vendored
19
third_party/nix/src/tests/hash_test.cc
vendored
|
@ -21,4 +21,23 @@ TEST(HASH_TEST, SHA256) {
|
|||
"sha256:LCa0a2j/xo/5m0U8HTBBNBNCLXBkg7+g+YpeiGJm564=");
|
||||
}
|
||||
|
||||
TEST(HashTest, SHA256Decode) {
|
||||
auto hash = hashString(HashType::htSHA256, "foo");
|
||||
|
||||
std::unique_ptr<Hash> base16 = std::make_unique<Hash>(
|
||||
"sha256:"
|
||||
"2c26b46b68ffc68ff99b453c1d30413413422d706483bfa0f98a5e886266e7ae",
|
||||
HashType::htSHA256);
|
||||
std::unique_ptr<Hash> base32 = std::make_unique<Hash>(
|
||||
"sha256:1bp7cri8hplaz6hbz0v4f0nl44rl84q1sg25kgwqzipzd1mv89ic",
|
||||
HashType::htSHA256);
|
||||
std::unique_ptr<Hash> base64 = std::make_unique<Hash>(
|
||||
"sha256:LCa0a2j/xo/5m0U8HTBBNBNCLXBkg7+g+YpeiGJm564=",
|
||||
HashType::htSHA256);
|
||||
|
||||
ASSERT_EQ(hash, *base16);
|
||||
ASSERT_EQ(hash, *base32);
|
||||
ASSERT_EQ(hash, *base64);
|
||||
}
|
||||
|
||||
} // namespace nix
|
||||
|
|
Loading…
Reference in a new issue