vibe.internal.rangeutil 3/5(60%) line coverage

      
10
20
30
40
50
60
70
80
92
100
115
123
130
140
150
160
170
180
190
200
210
220
230
240
250
260
270
280
290
300
310
320
module vibe.internal.rangeutil; struct RangeCounter { @safe: import std.utf; long* length; this(long* _captureLength) { length = _captureLength; } void put(char ch) { (*length)++; } void put(string str) { *length += str.length; } void put(dchar ch) { *length += codeLength!char(ch); } void put(dstring str) { foreach (ch; str) put(ch); } } @safe unittest { static long writeLength(ARGS...)(ARGS args) { long len = 0; auto rng = RangeCounter(() @trusted { return &len; } ()); foreach (a; args) rng.put(a); return len; } assert(writeLength("hello", ' ', "world") == "hello world".length); assert(writeLength("h\u00E4llo", ' ', "world") == "h\u00E4llo world".length); assert(writeLength("hello", '\u00E4', "world") == "hello\u00E4world".length); assert(writeLength("h\u00E4llo", ' ', "world") == "h\u00E4llo world".length); assert(writeLength("h\u1000llo", '\u1000', "world") == "h\u1000llo\u1000world".length); auto test = "häl"; assert(test.length == 4); assert(writeLength(test[0], test[1], test[2], test[3]) == test.length); }