The string representation of the values received in EqFailure() are already escaped. Split them on escaped '\n' boundaries. Leave all other escaped characters the same.
| 2764 | // escaped. Split them on escaped '\n' boundaries. Leave all other escaped |
| 2765 | // characters the same. |
| 2766 | std::vector<std::string> SplitEscapedString(const std::string& str) { |
| 2767 | std::vector<std::string> lines; |
| 2768 | size_t start = 0, end = str.size(); |
| 2769 | if (end > 2 && str[0] == '"' && str[end - 1] == '"') { |
| 2770 | ++start; |
| 2771 | --end; |
| 2772 | } |
| 2773 | bool escaped = false; |
| 2774 | for (size_t i = start; i + 1 < end; ++i) { |
| 2775 | if (escaped) { |
| 2776 | escaped = false; |
| 2777 | if (str[i] == 'n') { |
| 2778 | lines.push_back(str.substr(start, i - start - 1)); |
| 2779 | start = i + 1; |
| 2780 | } |
| 2781 | } else { |
| 2782 | escaped = str[i] == '\\'; |
| 2783 | } |
| 2784 | } |
| 2785 | lines.push_back(str.substr(start, end - start)); |
| 2786 | return lines; |
| 2787 | } |
| 2788 | |
| 2789 | } // namespace |
| 2790 |