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

Function testFloat

POSIX/demo/UnitTest.cpp:121–135  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

119}
120
121void testFloat(MMKV *mmkv) {
122 auto ret = mmkv->set(numeric_limits<float>::max(), "float");
123 assert(ret);
124
125 auto value = mmkv->getFloat("float");
126 assert(EqualWithAccuracy(value, numeric_limits<float>::max(), 0.001f));
127
128 value = mmkv->getFloat(KeyNotExist);
129 assert(EqualWithAccuracy(value, 0.0f, 0.001f));
130
131 value = mmkv->getFloat(KeyNotExist, -1.0f);
132 assert(EqualWithAccuracy(value, -1.0f, 0.001f));
133
134 printf("test float: passed\n");
135}
136
137void testDouble(MMKV *mmkv) {
138 auto ret = mmkv->set(numeric_limits<double>::max(), "double");

Callers 1

mainFunction · 0.85

Calls 3

EqualWithAccuracyFunction · 0.85
setMethod · 0.45
getFloatMethod · 0.45

Tested by

no test coverage detected