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

Function functionalTest

OpenHarmony/entry/src/main/cpp/napi_init.cpp:112–188  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

110}
111
112void functionalTest(MMKV *mmkv, bool decodeOnly) {
113 if (!decodeOnly) {
114 mmkv->set(true, "bool");
115 }
116 MMKVLog("bool = %d\n", mmkv->getBool("bool"));
117
118 if (!decodeOnly) {
119 mmkv->set(1024, "int32");
120 }
121 MMKVLog("int32 = %d\n", mmkv->getInt32("int32"));
122
123 if (!decodeOnly) {
124 mmkv->set(std::numeric_limits<uint32_t>::max(), "uint32");
125 }
126 MMKVLog("uint32 = %u\n", mmkv->getUInt32("uint32"));
127
128 if (!decodeOnly) {
129 mmkv->set(std::numeric_limits<int64_t>::min(), "int64");
130 }
131 MMKVLog("int64 = %lld\n", mmkv->getInt64("int64"));
132
133 if (!decodeOnly) {
134 mmkv->set(std::numeric_limits<uint64_t>::max(), "uint64");
135 }
136 MMKVLog("uint64 = %llu\n", mmkv->getUInt64("uint64"));
137
138 if (!decodeOnly) {
139 mmkv->set(3.14f, "float");
140 }
141 MMKVLog("float = %f\n", mmkv->getFloat("float"));
142
143 if (!decodeOnly) {
144 mmkv->set(std::numeric_limits<double>::max(), "double");
145 }
146 MMKVLog("double = %f\n", mmkv->getDouble("double"));
147
148 if (!decodeOnly) {
149 mmkv->set("Hello, MMKV-示例 for POSIX", "raw_string");
150 std::string str = "Hello, MMKV-示例 for POSIX string";
151 mmkv->set(str, "string");
152 mmkv->set(std::string_view(str).substr(7, 21), "string_view");
153 }
154 std::string result;
155 mmkv->getString("raw_string", result);
156 MMKVLog("raw_string = %s\n", result.c_str());
157 mmkv->getString("string", result);
158 MMKVLog("string = %s\n", result.c_str());
159 mmkv->getString("string_view", result);
160 MMKVLog("string_view = %s\n", result.c_str());
161
162 // containerTest(mmkv, decodeOnly);
163
164 MMKVLog("allKeys: %s\n", ::to_string(mmkv->allKeys()).c_str());
165 MMKVLog("count = %zu, totalSize = %zu\n", mmkv->count(), mmkv->totalSize());
166 MMKVLog("containsKey[string]: %d\n", mmkv->containsKey("string"));
167
168 mmkv->removeValueForKey("bool");
169 MMKVLog("bool: %d\n", mmkv->getBool("bool"));

Callers 1

TestNativeMMKVFunction · 0.70

Calls 15

mmapIDMethod · 0.80
to_stringFunction · 0.70
isFileValidFunction · 0.50
setMethod · 0.45
getBoolMethod · 0.45
getInt32Method · 0.45
getUInt32Method · 0.45
getInt64Method · 0.45
getUInt64Method · 0.45
getFloatMethod · 0.45
getDoubleMethod · 0.45
getStringMethod · 0.45

Tested by 1

TestNativeMMKVFunction · 0.56