MCPcopy Create free account
hub / github.com/cppcheck-opensource/cppcheck / writestr

Function writestr

test/fixture.cpp:147–171  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

145}
146
147static std::string writestr(const std::string &str, bool gccStyle = false)
148{
149 std::ostringstream ostr;
150 if (gccStyle)
151 ostr << '\"';
152 for (auto i = str.cbegin(); i != str.cend(); ++i) {
153 if (*i == '\n') {
154 ostr << "\\n";
155 if ((i+1) != str.end() && !gccStyle)
156 ostr << std::endl;
157 } else if (*i == '\t')
158 ostr << "\\t";
159 else if (*i == '\"')
160 ostr << "\\\"";
161 else if (std::isprint(static_cast<unsigned char>(*i)))
162 ostr << *i;
163 else
164 ostr << "\\x" << std::hex << short{*i};
165 }
166 if (!str.empty() && !gccStyle)
167 ostr << std::endl;
168 else if (gccStyle)
169 ostr << '\"';
170 return ostr.str();
171}
172
173void TestFixture::assert_(const char * const filename, const unsigned int linenr, const bool condition, const std::string& msg) const
174{

Callers 2

assertFailureMethod · 0.85
todoAssertEqualsMethod · 0.85

Calls 3

endMethod · 0.45
emptyMethod · 0.45
strMethod · 0.45

Tested by

no test coverage detected