MCPcopy Create free account
hub / github.com/Kitware/VTK / TestReadLineLimit

Function TestReadLineLimit

IO/Core/Testing/Cxx/TestResourceParser.cxx:179–213  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

177}
178
179bool TestReadLineLimit()
180{
181 std::string input{ "55555\r\n333\n" };
182
183 static const std::array<const char*, 4> expectedValues{ "555", "55", "333", "" };
184 static const std::array<vtkParseResult, 5> expectedResults{
185 vtkParseResult::Limit,
186 vtkParseResult::EndOfLine,
187 vtkParseResult::Limit,
188 vtkParseResult::EndOfLine,
189 vtkParseResult::EndOfStream,
190 };
191
192 vtkNew<vtkMemoryResourceStream> stream;
193 stream->SetBuffer(input.data(), input.size());
194
195 vtkNew<vtkResourceParser> parser;
196 parser->SetStream(stream);
197
198 std::string line;
199 std::size_t index{};
200 while (parser->ReadLine(line, 3) == expectedResults[index])
201 {
202 if (index >= expectedValues.size())
203 {
204 return true;
205 }
206
207 Check(line == expectedValues[index],
208 "Expected \"" << expectedValues[index] << "\" but got \"" << line << "\"");
209 ++index;
210 }
211
212 return true;
213}
214
215bool TestReadLineTo()
216{

Callers 1

TestResourceParserFunction · 0.85

Calls 6

CheckFunction · 0.85
SetBufferMethod · 0.45
dataMethod · 0.45
sizeMethod · 0.45
SetStreamMethod · 0.45
ReadLineMethod · 0.45

Tested by

no test coverage detected