#include "include/core/SkString.h"
#include "include/core/SkTypes.h"
#include "include/private/base/SkAlign.h"
#include "src/base/SkRandom.h"
#include "src/core/SkChecksum.h"
#include "tests/Test.h"
#include <cstddef>
#include <cstdint>
#include <cstring>
#include <string>
#include <string_view>
Go to the source code of this file.
◆ DEF_TEST() [1/5]
DEF_TEST |
( |
Checksum |
, |
|
|
r |
|
|
) |
| |
Definition at line 21 of file ChecksumTest.cpp.
21 {
22
25 uint32_t
data[kBytes/4], tweaked[kBytes/4];
26 for (size_t i = 0; i < std::size(tweaked); ++i) {
28 }
29
31
33
34
35 for (size_t j = 0; j < std::size(tweaked); ++j) {
36 const uint32_t saved = tweaked[j];
37 tweaked[j] = rand.
nextU();
41 tweaked[j] = saved;
42 }
43}
static constexpr T SkAlign4(T x)
static uint32_t hash(const SkShaderBase::GradientInfo &v)
#define REPORTER_ASSERT(r, cond,...)
uint32_t Hash32(const void *data, size_t bytes, uint32_t seed)
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot data
◆ DEF_TEST() [2/5]
DEF_TEST |
( |
ChecksumCollisions |
, |
|
|
r |
|
|
) |
| |
Definition at line 51 of file ChecksumTest.cpp.
51 {
52
53
54
55
56
57 {
58 float a[9] = { 0, 1, 2,
59 3, 4, 5,
60 6, 7, 8, };
61 float b[9] = { 1, 2, 0,
62 4, 5, 3,
63 7, 8, 6, };
64
66 }
67 {
68 double a[9] = { 0, 1, 2,
69 3, 4, 5,
70 6, 7, 8, };
71 double b[9] = { 1, 2, 0,
72 4, 5, 3,
73 7, 8, 6, };
74
76 }
77}
◆ DEF_TEST() [3/5]
DEF_TEST |
( |
ChecksumConsistent |
, |
|
|
r |
|
|
) |
| |
Definition at line 79 of file ChecksumTest.cpp.
79 {
80
81
82 uint8_t bytes[256];
83 for (int i = 0; i < 256; i++) {
84 bytes[i] = i;
85 }
87 REPORTER_ASSERT(r, hash_bytes( 0) == 0xe2bde459,
"%08x", hash_bytes( 0));
88 REPORTER_ASSERT(r, hash_bytes( 1) == 0xe5f8bd85,
"%08x", hash_bytes( 1));
89 REPORTER_ASSERT(r, hash_bytes( 2) == 0x77acd42a,
"%08x", hash_bytes( 2));
90 REPORTER_ASSERT(r, hash_bytes( 7) == 0x78d0861f,
"%08x", hash_bytes( 7));
91 REPORTER_ASSERT(r, hash_bytes( 32) == 0x4e73df6d,
"%08x", hash_bytes( 32));
92 REPORTER_ASSERT(r, hash_bytes( 63) == 0x5e66a3f4,
"%08x", hash_bytes( 63));
93 REPORTER_ASSERT(r, hash_bytes( 64) == 0x962d6746,
"%08x", hash_bytes( 64));
94 REPORTER_ASSERT(r, hash_bytes( 99) == 0x79e09416,
"%08x", hash_bytes( 99));
95 REPORTER_ASSERT(r, hash_bytes(255) == 0x85f837f0,
"%08x", hash_bytes(255));
96}
◆ DEF_TEST() [4/5]
DEF_TEST |
( |
ChecksumStrings |
, |
|
|
r |
|
|
) |
| |
Definition at line 98 of file ChecksumTest.cpp.
98 {
99 constexpr char kMessage[] = "Checksums are supported for SkString, string, and string_view.";
101
105}
◆ DEF_TEST() [5/5]
DEF_TEST |
( |
GoodHash |
, |
|
|
r |
|
|
) |
| |