Changeset View
Changeset View
Standalone View
Standalone View
debuggers/gdb/unittests/test_gdb.cpp
Show First 20 Lines • Show All 1197 Lines • ▼ Show 20 Line(s) | |||||
1198 | 1198 | | |||
1199 | void GdbTest::testVariablesWatchesQuotes() | 1199 | void GdbTest::testVariablesWatchesQuotes() | ||
1200 | { | 1200 | { | ||
1201 | TestDebugSession *session = new TestDebugSession; | 1201 | TestDebugSession *session = new TestDebugSession; | ||
1202 | session->variableController()->setAutoUpdate(KDevelop::IVariableController::UpdateWatches); | 1202 | session->variableController()->setAutoUpdate(KDevelop::IVariableController::UpdateWatches); | ||
1203 | 1203 | | |||
1204 | TestLaunchConfiguration cfg; | 1204 | TestLaunchConfiguration cfg; | ||
1205 | 1205 | | |||
1206 | const QString testString("test"); | 1206 | // the unquoted string (the actual content): t\"t | ||
1207 | const QString quotedTestString("\"" + testString + "\""); | 1207 | // quoted string (what we would write as a c string): "t\\\"t" | ||
1208 | // written in source file: R"("t\\\"t")" | ||||
1209 | const QString testString("t\\\"t"); // the actual content | ||||
1210 | const QString quotedTestString(R"("t\\\"t")"); | ||||
1208 | 1211 | | |||
1209 | breakpoints()->addCodeBreakpoint(QUrl::fromLocalFile(debugeeFileName), 38); | 1212 | breakpoints()->addCodeBreakpoint(QUrl::fromLocalFile(debugeeFileName), 38); | ||
1210 | QVERIFY(session->startDebugging(&cfg, m_iface)); | 1213 | QVERIFY(session->startDebugging(&cfg, m_iface)); | ||
1211 | WAIT_FOR_STATE(session, DebugSession::PausedState); | 1214 | WAIT_FOR_STATE_AND_IDLE(session, DebugSession::PausedState); | ||
1212 | 1215 | | |||
1213 | variableCollection()->watches()->add(quotedTestString); //just a constant string | 1216 | variableCollection()->watches()->add(quotedTestString); //just a constant string | ||
1214 | QTest::qWait(300); | 1217 | QTest::qWait(300); | ||
1215 | 1218 | | |||
1216 | QModelIndex i = variableCollection()->index(0, 0); | 1219 | QModelIndex i = variableCollection()->index(0, 0); | ||
1217 | QCOMPARE(variableCollection()->rowCount(i), 1); | 1220 | QCOMPARE(variableCollection()->rowCount(i), 1); | ||
1218 | COMPARE_DATA(variableCollection()->index(0, 0, i), quotedTestString); | 1221 | COMPARE_DATA(variableCollection()->index(0, 0, i), quotedTestString); | ||
1219 | COMPARE_DATA(variableCollection()->index(0, 1, i), "[" + QString::number(testString.length() + 1) + "]"); | 1222 | COMPARE_DATA(variableCollection()->index(0, 1, i), "[" + QString::number(testString.length() + 1) + "]"); | ||
1220 | 1223 | | |||
1221 | QModelIndex testStr = variableCollection()->index(0, 0, i); | 1224 | QModelIndex testStr = variableCollection()->index(0, 0, i); | ||
1222 | COMPARE_DATA(variableCollection()->index(0, 0, testStr), "..."); | 1225 | COMPARE_DATA(variableCollection()->index(0, 0, testStr), "..."); | ||
1223 | variableCollection()->expanded(testStr); | 1226 | variableCollection()->expanded(testStr); | ||
1224 | QTest::qWait(100); | 1227 | QTest::qWait(100); | ||
1225 | int len = testString.length(); | 1228 | int len = testString.length(); | ||
1226 | for (int ind = 0; ind < len; ind++) | 1229 | for (int ind = 0; ind < len; ind++) | ||
1227 | { | 1230 | { | ||
1228 | COMPARE_DATA(variableCollection()->index(ind, 0, testStr), QString::number(ind)); | 1231 | COMPARE_DATA(variableCollection()->index(ind, 0, testStr), QString::number(ind)); | ||
1229 | QChar c = testString.at(ind); | 1232 | QChar c = testString.at(ind); | ||
1230 | QString value = QString::number(c.toLatin1()) + " '" + c + "'"; | 1233 | QString value = QString::number(c.toLatin1()) + " '"; | ||
1234 | if (c == '\\') | ||||
1235 | value += "\\\\"; | ||||
1236 | else if (c == '\'') | ||||
1237 | value += "\\'"; | ||||
1238 | else | ||||
1239 | value += c; | ||||
1240 | value += "'"; | ||||
1231 | COMPARE_DATA(variableCollection()->index(ind, 1, testStr), value); | 1241 | COMPARE_DATA(variableCollection()->index(ind, 1, testStr), value); | ||
1232 | } | 1242 | } | ||
1233 | COMPARE_DATA(variableCollection()->index(len, 0, testStr), QString::number(len)); | 1243 | COMPARE_DATA(variableCollection()->index(len, 0, testStr), QString::number(len)); | ||
1234 | COMPARE_DATA(variableCollection()->index(len, 1, testStr), "0 '\\000'"); | 1244 | COMPARE_DATA(variableCollection()->index(len, 1, testStr), "0 '\\000'"); | ||
1235 | 1245 | | |||
1236 | session->run(); | 1246 | session->run(); | ||
1237 | WAIT_FOR_STATE(session, DebugSession::EndedState); | 1247 | WAIT_FOR_STATE(session, DebugSession::EndedState); | ||
1238 | } | 1248 | } | ||
▲ Show 20 Lines • Show All 855 Lines • Show Last 20 Lines |