| 188 | } |
| 189 | |
| 190 | UTEST_F(DebugLog, MessageControl_EnableAll) |
| 191 | { |
| 192 | // config debug output |
| 193 | // ----------------------- |
| 194 | McSize numBytes = 0; |
| 195 | McFlags contextFlags = 0; |
| 196 | ASSERT_EQ(MC_NO_ERROR, mcGetInfo(utest_fixture->context_, MC_CONTEXT_FLAGS, 0, nullptr, &numBytes)); |
| 197 | |
| 198 | ASSERT_EQ(sizeof(McFlags), numBytes); |
| 199 | |
| 200 | ASSERT_EQ(MC_NO_ERROR, mcGetInfo(utest_fixture->context_, MC_CONTEXT_FLAGS, numBytes, &contextFlags, nullptr)); |
| 201 | |
| 202 | if (contextFlags & MC_DEBUG) { |
| 203 | // enable all |
| 204 | mcDebugMessageControl(utest_fixture->context_, McDebugSource::MC_DEBUG_SOURCE_ALL, McDebugType::MC_DEBUG_TYPE_ALL, McDebugSeverity::MC_DEBUG_SEVERITY_ALL, true); |
| 205 | } |
| 206 | |
| 207 | ASSERT_EQ(MC_NO_ERROR, |
| 208 | mcDispatch(utest_fixture->context_, |
| 209 | MC_DISPATCH_VERTEX_ARRAY_DOUBLE, |
| 210 | utest_fixture->cubeVertices.data(), utest_fixture->cubeFaces.data(), utest_fixture->cubeFaceSizes.data(), utest_fixture->numCubeVertices, utest_fixture->numCubeFaces, |
| 211 | utest_fixture->cutMeshVertices.data(), utest_fixture->cutMeshFaces.data(), |
| 212 | nullptr, // cutMeshFaceSizes, // no need to give 'faceSizes' parameter since cut-mesh is a triangle mesh |
| 213 | utest_fixture->numCutMeshVertices, utest_fixture->numCutMeshFaces)); |
| 214 | |
| 215 | McUint32 numMsgs = 10; // retrieve up to 10 |
| 216 | |
| 217 | McSize maxMsgLen = 0; |
| 218 | ASSERT_EQ(MC_NO_ERROR, mcGetInfo(utest_fixture->context_, MC_CONTEXT_MAX_DEBUG_MESSAGE_LENGTH, sizeof(McSize), &maxMsgLen, NULL)); |
| 219 | |
| 220 | std::vector<McChar> msgData(numMsgs * maxMsgLen); |
| 221 | std::vector<McDebugSource> sources(numMsgs); |
| 222 | std::vector<McDebugType> types(numMsgs); |
| 223 | std::vector<McDebugSeverity> severities(numMsgs); |
| 224 | std::vector<McSize> lengths(numMsgs); |
| 225 | McUint32 numFound; |
| 226 | |
| 227 | ASSERT_EQ(MC_NO_ERROR, mcGetDebugMessageLog(utest_fixture->context_, numMsgs, msgData.size(), &sources[0], &types[0], &severities[0], &lengths[0], &msgData[0], &numFound)); |
| 228 | |
| 229 | ASSERT_GT(numFound, (McUint32)0); |
| 230 | |
| 231 | sources.resize(numFound); |
| 232 | types.resize(numFound); |
| 233 | severities.resize(numFound); |
| 234 | lengths.resize(numFound); |
| 235 | std::vector<std::string> messages; |
| 236 | messages.reserve(numFound); |
| 237 | |
| 238 | std::vector<McChar>::iterator currPos = msgData.begin(); |
| 239 | |
| 240 | for (size_t msg = 0; msg < lengths.size(); ++msg) { |
| 241 | ASSERT_GT(lengths[msg], (McSize)0); |
| 242 | messages.push_back(std::string(currPos, currPos + lengths[msg])); |
| 243 | currPos = currPos + lengths[msg]; |
| 244 | |
| 245 | printf("message from log string: %s\n", messages.back().c_str()); |
| 246 | } |
| 247 |
nothing calls this directly
no test coverage detected