| 200 | } |
| 201 | |
| 202 | void testRemove(MMKV *mmkv) { |
| 203 | auto ret = mmkv->set(true, "bool_1"); |
| 204 | ret &= mmkv->set(numeric_limits<int32_t>::max(), "int_1"); |
| 205 | ret &= mmkv->set(numeric_limits<int64_t>::max(), "long_1"); |
| 206 | ret &= mmkv->set(numeric_limits<float>::min(), "float_1"); |
| 207 | ret &= mmkv->set(numeric_limits<double>::min(), "double_1"); |
| 208 | ret &= mmkv->set("hello", "string_1"); |
| 209 | vector<string> v = vector<string>{"key", "value"}; |
| 210 | ret &= mmkv->set(v, "vector_1"); |
| 211 | assert(ret); |
| 212 | |
| 213 | { |
| 214 | long count = mmkv->count(); |
| 215 | |
| 216 | mmkv->removeValueForKey("bool_1"); |
| 217 | mmkv->removeValuesForKeys({"int_1", "long_1"}); |
| 218 | |
| 219 | auto newCount = mmkv->count(); |
| 220 | assert(count == newCount + 3); |
| 221 | } |
| 222 | |
| 223 | auto bValue = mmkv->getBool("bool_1"); |
| 224 | assert(!bValue); |
| 225 | |
| 226 | auto iValue = mmkv->getInt32("int_1"); |
| 227 | assert(iValue == 0); |
| 228 | |
| 229 | auto lValue = mmkv->getInt64("long_1"); |
| 230 | assert(lValue == 0); |
| 231 | |
| 232 | auto fValue = mmkv->getFloat("float_1"); |
| 233 | assert(EqualWithAccuracy(fValue, numeric_limits<float>::min(), 0.001f)); |
| 234 | |
| 235 | double dValue = mmkv->getDouble("double_1"); |
| 236 | assert(EqualWithAccuracy(dValue, numeric_limits<double>::min(), 0.001)); |
| 237 | |
| 238 | string sValue; |
| 239 | ret = mmkv->getString("string_1", sValue); |
| 240 | assert(ret && sValue == "hello"); |
| 241 | |
| 242 | vector<string> vValue; |
| 243 | ret = mmkv->getVector("vector_1", vValue); |
| 244 | assert(ret && vValue == v); |
| 245 | |
| 246 | printf("test remove: passed\n"); |
| 247 | } |
| 248 | |
| 249 | int main() { |
| 250 | locale::global(locale("")); |
no test coverage detected