md5_medium_ut.cpp 658 B

12345678910111213141516171819202122232425
  1. #include "md5.h"
  2. #include <library/cpp/testing/unittest/registar.h>
  3. Y_UNIT_TEST_SUITE(TMD5MediumTest) {
  4. Y_UNIT_TEST(TestOverflow) {
  5. if (sizeof(size_t) > sizeof(unsigned int)) {
  6. const size_t maxUi32 = (size_t)Max<unsigned int>();
  7. TArrayHolder<char> buf(new char[maxUi32]);
  8. memset(buf.Get(), 0, maxUi32);
  9. MD5 r;
  10. for (int i = 0; i < 5; ++i) {
  11. r.Update(buf.Get(), maxUi32);
  12. }
  13. char rs[33];
  14. TString s(r.End(rs));
  15. s.to_lower();
  16. UNIT_ASSERT_VALUES_EQUAL(s, "34a5a7ed4f0221310084e21a1e599659");
  17. }
  18. }
  19. }