SkBase64Test.cpp 941 B

12345678910111213141516171819202122232425262728293031
  1. /*
  2. * Copyright 2014 Google Inc.
  3. *
  4. * Use of this source code is governed by a BSD-style license that can be
  5. * found in the LICENSE file.
  6. */
  7. #include "include/private/SkTo.h"
  8. #include "include/utils/SkBase64.h"
  9. #include "tests/Test.h"
  10. DEF_TEST(SkBase64, reporter) {
  11. char all[256];
  12. for (int index = 0; index < 255; ++index) {
  13. all[index] = (signed char) (index + 1);
  14. }
  15. all[255] = 0;
  16. for (int offset = 0; offset < 6; ++offset) {
  17. size_t length = 256 - offset;
  18. size_t encodeLength = SkBase64::Encode(all + offset, length, nullptr);
  19. SkAutoTMalloc<char> src(encodeLength + 1);
  20. SkBase64::Encode(all + offset, length, src.get());
  21. src[SkToInt(encodeLength)] = '\0';
  22. SkBase64 tryMe;
  23. tryMe.decode(src.get(), encodeLength);
  24. REPORTER_ASSERT(reporter, (strcmp((const char*) (all + offset), tryMe.getData()) == 0));
  25. delete[] tryMe.getData();
  26. }
  27. }