diff options
author | Anton Samokhvalov <pg83@yandex.ru> | 2022-02-10 16:45:17 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:45:17 +0300 |
commit | d3a398281c6fd1d3672036cb2d63f842d2cb28c5 (patch) | |
tree | dd4bd3ca0f36b817e96812825ffaf10d645803f2 /library/cpp/digest/md5/md5_ut.cpp | |
parent | 72cb13b4aff9bc9cf22e49251bc8fd143f82538f (diff) | |
download | ydb-d3a398281c6fd1d3672036cb2d63f842d2cb28c5.tar.gz |
Restoring authorship annotation for Anton Samokhvalov <pg83@yandex.ru>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/digest/md5/md5_ut.cpp')
-rw-r--r-- | library/cpp/digest/md5/md5_ut.cpp | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/library/cpp/digest/md5/md5_ut.cpp b/library/cpp/digest/md5/md5_ut.cpp index 8216fa463a..1c3e4ad0a9 100644 --- a/library/cpp/digest/md5/md5_ut.cpp +++ b/library/cpp/digest/md5/md5_ut.cpp @@ -1,44 +1,44 @@ -#include "md5.h" - +#include "md5.h" + #include <library/cpp/testing/unittest/registar.h> -#include <util/system/fs.h> -#include <util/stream/file.h> - +#include <util/system/fs.h> +#include <util/stream/file.h> + Y_UNIT_TEST_SUITE(TMD5Test) { Y_UNIT_TEST(TestMD5) { // echo -n 'qwertyuiopqwertyuiopasdfghjklasdfghjkl' | md5sum constexpr const char* b = "qwertyuiopqwertyuiopasdfghjklasdfghjkl"; - + MD5 r; r.Update((const unsigned char*)b, 15); r.Update((const unsigned char*)b + 15, strlen(b) - 15); - + char rs[33]; TString s(r.End(rs)); s.to_lower(); - + UNIT_ASSERT_NO_DIFF(s, TStringBuf("3ac00dd696b966fd74deee3c35a59d8f")); - + TString result = r.Calc(TStringBuf(b)); result.to_lower(); UNIT_ASSERT_NO_DIFF(result, TStringBuf("3ac00dd696b966fd74deee3c35a59d8f")); } - + Y_UNIT_TEST(TestFile) { TString s = NUnitTest::RandomString(1000000, 1); const TString tmpFile = "tmp"; - + { TFixedBufferFileOutput fo(tmpFile); fo.Write(s.data(), s.size()); } - + char fileBuf[100]; char memBuf[100]; TString fileHash = MD5::File(tmpFile.data(), fileBuf); TString memoryHash = MD5::Data((const unsigned char*)s.data(), s.size(), memBuf); - + UNIT_ASSERT_NO_DIFF(fileHash, memoryHash); fileHash = MD5::File(tmpFile); |