MCPcopy Create free account
hub / github.com/OpenOrienteering/mapper / Utf16PascalStringTest

Method Utf16PascalStringTest

test/ocd_t.cpp:227–249  ·  view source on GitHub ↗

* Tests the UTF-16 pascal string implementation, Ocd::Utf16PascalString . */

Source from the content-addressed store, hash-verified

225 * Tests the UTF-16 pascal string implementation, Ocd::Utf16PascalString<N>.
226 */
227 void Utf16PascalStringTest()
228 {
229 struct {
230 Ocd::Utf16PascalString<4> string;
231 char trailing[4];
232 } t;
233
234 auto* const expected_trailing = "xyz";
235 qstrncpy(t.trailing, expected_trailing, 4);
236
237 QFETCH(QString, input);
238 QFETCH(QString, expected);
239
240 Q_ASSERT(static_cast<std::size_t>(expected.length()) < std::extent<decltype(t.string.data)>::value);
241
242 t.string = input;
243 QCOMPARE(QString::fromRawData(t.string.data, expected.length()), expected);
244
245 using std::begin; using std::end;
246 QVERIFY(std::all_of(begin(t.string.data)+expected.length(), end(t.string.data), [](auto c){ return c == 0; }));
247
248 QCOMPARE(t.trailing, expected_trailing);
249 }
250
251}; // class OcdTest
252

Callers

nothing calls this directly

Calls 1

lengthMethod · 0.45

Tested by

no test coverage detected