Print sections of example code. Used for checking what edited text looks like when writing tests.
| 145 | /// Print sections of example code. |
| 146 | /// Used for checking what edited text looks like when writing tests. |
| 147 | void TestBreakpointModel::printLines(int from, int count, const IDocument* doc) |
| 148 | { |
| 149 | // gather a set of breakpoint line numbers in doc. |
| 150 | std::vector<int> breakpointLines; |
| 151 | const auto breakpoints = breakpointModel()->breakpoints(); |
| 152 | for (const auto* b : breakpoints) { |
| 153 | if (b->url() == doc->url()) { |
| 154 | breakpointLines.push_back(b->line()); |
| 155 | } |
| 156 | } |
| 157 | std::sort(breakpointLines.begin(), breakpointLines.end()); |
| 158 | |
| 159 | // gather a set of breakpoint marks in doc. |
| 160 | const auto markLines = documentMarks(doc); |
| 161 | |
| 162 | // Breakpoint prefixes: |
| 163 | // "[bm]" ok: a line has both mark and breakpoint instance |
| 164 | // "[b-]" a line has breakpoint instance but no mark in UI |
| 165 | // "[-m]" a line has mark in UI but no breakpoint instance |
| 166 | // TODO: print upper-case letters for marks or breakpoints that are in an enabled state. |
| 167 | for (int i = from; i < from + count && i < doc->textDocument()->lines(); ++i) { |
| 168 | const bool hasBreakpoint = std::binary_search(breakpointLines.cbegin(), breakpointLines.cend(), i); |
| 169 | QString prefix = (hasBreakpoint ? "b" : "-"); |
| 170 | prefix += (markLines.contains(i) ? "m" : "-"); |
| 171 | |
| 172 | qDebug("%d\t[%s]: %s", i, qUtf8Printable(prefix), qUtf8Printable(doc->textDocument()->line(i))); |
| 173 | } |
| 174 | } |
| 175 | |
| 176 | /// Verify that the breakpoint is set correctly at the expected line number, |
| 177 | /// that the document line tracking is enabled for it, and that its mark type matches the expected value. |
nothing calls this directly
no test coverage detected