MCPcopy Create free account
hub / github.com/Tencent/MMKV / testBytes

Function testBytes

POSIX/demo/UnitTest.cpp:175–188  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

173}
174
175void testBytes(MMKV *mmkv) {
176 string str = "Hello 2018 world cup 世界杯";
177 MMBuffer buffer((void *) str.data(), str.length(), MMBufferNoCopy);
178 auto ret = mmkv->set(buffer, "bytes");
179 assert(ret);
180
181 auto value = mmkv->getBytes("bytes");
182 assert(value.length() == buffer.length() && memcmp(value.getPtr(), buffer.getPtr(), value.length()) == 0);
183
184 value = mmkv->getBytes(KeyNotExist);
185 assert(value.length() == 0);
186
187 printf("test bytes: passed\n");
188}
189
190void testVector(MMKV *mmkv) {
191 vector<string> v = {"1", "0", "2", "4"};

Callers 1

mainFunction · 0.85

Calls 2

setMethod · 0.45
getBytesMethod · 0.45

Tested by

no test coverage detected