MCPcopy Create free account
hub / github.com/KDE/kdevelop / testVariablesWatchesQuotes

Method testVariablesWatchesQuotes

plugins/gdb/unittests/test_gdb.cpp:254–303  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

252}
253
254void GdbTest::testVariablesWatchesQuotes()
255{
256 auto *session = new TestDebugSession;
257 session->variableController()->setAutoUpdate(KDevelop::IVariableController::UpdateWatches);
258
259 TestLaunchConfiguration cfg;
260
261 // the unquoted string (the actual content): t\"t
262 // quoted string (what we would write as a c string): "t\\\"t"
263 // written in source file: R"("t\\\"t")"
264 const QString testString(QStringLiteral("t\\\"t")); // the actual content
265 const QString quotedTestString(QStringLiteral(R"("t\\\"t")"));
266
267 breakpoints()->addCodeBreakpoint(debugeeUrl(), 38);
268 START_DEBUGGING_E(session, cfg);
269 WAIT_FOR_STATE_AND_IDLE(session, DebugSession::PausedState);
270
271 variableCollection()->watches()->add(quotedTestString); //just a constant string
272 WAIT_FOR_STATE_AND_IDLE(session, DebugSession::PausedState);
273
274 QModelIndex i = variableCollection()->index(0, 0);
275 QCOMPARE(variableCollection()->rowCount(i), 1);
276 COMPARE_DATA(variableCollection()->index(0, 0, i), quotedTestString);
277 COMPARE_DATA(variableCollection()->index(0, 1, i), "[" + QString::number(testString.length() + 1) + "]");
278
279 QModelIndex testStr = variableCollection()->index(0, 0, i);
280 COMPARE_DATA(variableCollection()->index(0, 0, testStr), "...");
281
282 EXPAND_VARIABLE_COLLECTION(testStr);
283 int len = testString.length();
284 for (int ind = 0; ind < len; ind++)
285 {
286 COMPARE_DATA(variableCollection()->index(ind, 0, testStr), QString::number(ind));
287 QChar c = testString.at(ind);
288 QString value = QString::number(c.toLatin1()) + " '";
289 if (c == '\\')
290 value += QLatin1String("\\\\");
291 else if (c == '\'')
292 value += QLatin1String("\\'");
293 else
294 value += c;
295 value += QLatin1String("'");
296 COMPARE_DATA(variableCollection()->index(ind, 1, testStr), value);
297 }
298 COMPARE_DATA(variableCollection()->index(len, 0, testStr), QString::number(len));
299 COMPARE_DATA(variableCollection()->index(len, 1, testStr), "0 '\\000'");
300
301 session->run();
302 WAIT_FOR_STATE(session, DebugSession::EndedState);
303}
304
305void GdbTest::testPickupCatchThrowOnlyOnce()
306{

Callers

nothing calls this directly

Calls 10

variableCollectionFunction · 0.85
setAutoUpdateMethod · 0.80
variableControllerMethod · 0.45
addCodeBreakpointMethod · 0.45
addMethod · 0.45
indexMethod · 0.45
rowCountMethod · 0.45
lengthMethod · 0.45
atMethod · 0.45
runMethod · 0.45

Tested by

no test coverage detected