aboutsummaryrefslogtreecommitdiff
path: root/vendor/libghostty-vt/src/terminal/kitty/dnd_test.zig
blob: c78ce00f6d773ce2a2b585e96f55478191f5756f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
//! End-to-end tests for the OSC 72 protocol state machine, validating
//! wire behavior against kitty's implementation (using kitty_tests/dnd.py as
//! an oracle for the expected bytes).
//!
//! It isn't normal for us to have dedicated test files but in this case
//! the dnd protocol is complicated enough that I wanted full e2e covering
//! the full machine.

const std = @import("std");
const testing = std.testing;

const osc = @import("../osc.zig");
const dnd = @import("dnd.zig");

/// A test harness holding the lazily allocated protocol state and an
/// output collector.
const Harness = struct {
    state: ?*dnd.State = null,
    output: std.Io.Writer.Allocating,

    fn init() Harness {
        return .{ .output = .init(testing.allocator) };
    }

    fn deinit(self: *Harness) void {
        if (self.state) |state| state.destroy(testing.allocator);
        self.output.deinit();
    }

    /// The registered state; asserts a client has registered.
    fn registered(self: *Harness) *dnd.State {
        return self.state.?;
    }

    /// Feed one client command, as it would arrive from the OSC parser,
    /// returning the event the stream handler would pass to its effect.
    fn command(self: *Harness, metadata: []const u8, payload: ?[]const u8) !?dnd.Event {
        return try dnd.handleCommand(&self.state, testing.allocator, &self.output.writer, .{
            .metadata = metadata,
            .payload = payload,
            .terminator = .st,
        });
    }

    /// Consume and return the collected output.
    fn consume(self: *Harness) []const u8 {
        const written = self.output.written();
        return written;
    }

    fn clear(self: *Harness) void {
        self.output.clearRetainingCapacity();
    }

    fn expectOutput(self: *Harness, expected: []const u8) !void {
        try testing.expectEqualStrings(expected, self.output.written());
        self.clear();
    }
};

test "dnd: query response" {
    var h: Harness = .init();
    defer h.deinit();

    // Works without any registration, matching kitty, and allocates
    // nothing.
    _ = try h.command("t=q", null);
    try h.expectOutput("\x1b]72;t=q\x1b\\");
    try testing.expect(h.state == null);
}

test "dnd: query response echoes client id" {
    var h: Harness = .init();
    defer h.deinit();

    _ = try h.command("t=q:i=31", null);
    try h.expectOutput("\x1b]72;t=q:i=31\x1b\\");
}

test "dnd: register and unregister" {
    var h: Harness = .init();
    defer h.deinit();

    try testing.expect(h.state == null);

    // Registration allocates the state and reports it, with the
    // declared MIME list readable from the state.
    try testing.expect((try h.command("t=a", "text/plain text/uri-list")).? == .registration);
    try h.expectOutput("");
    {
        var it = h.registered().registeredMimes();
        try testing.expectEqualStrings("text/plain", it.next().?);
        try testing.expectEqualStrings("text/uri-list", it.next().?);
        try testing.expect(it.next() == null);
    }

    // Machine ID declaration is accepted and ignored.
    try testing.expect((try h.command("t=a:x=1", "1:deadbeef")) == null);
    try h.expectOutput("");
    try testing.expect(h.state != null);

    // Re-registration replaces the list.
    try testing.expect((try h.command("t=a", "image/png")).? == .registration);
    {
        var it = h.registered().registeredMimes();
        try testing.expectEqualStrings("image/png", it.next().?);
        try testing.expect(it.next() == null);
    }

    // Registering without a list is the common case.
    try testing.expect((try h.command("t=a", null)).? == .registration);
    {
        var it = h.registered().registeredMimes();
        try testing.expect(it.next() == null);
    }

    // Unregistration frees it and reports the change.
    try testing.expect((try h.command("t=A", null)).? == .registration);
    try h.expectOutput("");
    try testing.expect(h.state == null);

    // Unregistering again changes nothing.
    try testing.expect((try h.command("t=A", null)) == null);
    try h.expectOutput("");
    try testing.expect(h.state == null);
}

test "dnd: no state before registration" {
    var h: Harness = .init();
    defer h.deinit();

    // State-dependent commands from an unregistered client allocate
    // nothing; a data request gets the error kitty sends from its
    // zeroed state.
    _ = try h.command("t=m:o=1", "text/plain");
    _ = try h.command("t=r", null);
    try h.expectOutput("");
    _ = try h.command("t=r:x=1", null);
    try h.expectOutput(
        "\x1b]72;t=R:x=1:m=0;ENOENT:no drop data available\x1b\\",
    );
    try testing.expect(h.state == null);
}

test "dnd: move event carries position, operations, and mime list" {
    var h: Harness = .init();
    defer h.deinit();

    _ = try h.command("t=a", "text/plain");

    try h.registered().dragMove(testing.allocator, &h.output.writer, .{
        .cell_x = 5,
        .cell_y = 3,
        .pixel_x = 100,
        .pixel_y = 60,
        .operations = .{ .copy = true },
    }, &.{ "text/plain", "text/uri-list" });

    // Note the trailing space after every MIME entry, matching kitty.
    try h.expectOutput(
        "\x1b]72;t=m:x=5:y=3:X=100:Y=60:o=1:m=0;text/plain text/uri-list \x1b\\",
    );
}

test "dnd: move event echoes registration client id" {
    var h: Harness = .init();
    defer h.deinit();

    _ = try h.command("t=a:i=7", "");
    try h.registered().dragMove(testing.allocator, &h.output.writer, .{
        .cell_x = 1,
        .cell_y = 2,
        .pixel_x = 8,
        .pixel_y = 16,
        .operations = .{ .copy = true, .move = true },
    }, &.{"text/plain"});
    try h.expectOutput("\x1b]72;t=m:x=1:y=2:X=8:Y=16:o=3:i=7:m=0;text/plain \x1b\\");
}

test "dnd: re-registration updates client id in place" {
    var h: Harness = .init();
    defer h.deinit();

    _ = try h.command("t=a:i=7", "");
    const state = h.registered();
    _ = try h.command("t=a:i=9", "");
    // Same allocation, new client ID.
    try testing.expect(h.state.? == state);
    try testing.expectEqual(@as(u32, 9), state.drop.client_id);
}

test "dnd: mime list sent on every move" {
    var h: Harness = .init();
    defer h.deinit();

    _ = try h.command("t=a", "");
    const ev: dnd.MoveEvent = .{
        .cell_x = 0,
        .cell_y = 0,
        .pixel_x = 0,
        .pixel_y = 0,
        .operations = .{ .copy = true },
    };
    try h.registered().dragMove(testing.allocator, &h.output.writer, ev, &.{"text/plain"});
    h.clear();

    // Kitty resends the list even when unchanged; clients depend on it.
    try h.registered().dragMove(testing.allocator, &h.output.writer, ev, &.{"text/plain"});
    try h.expectOutput("\x1b]72;t=m:x=0:y=0:X=0:Y=0:o=1:m=0;text/plain \x1b\\");
}

test "dnd: leave event" {
    var h: Harness = .init();
    defer h.deinit();

    _ = try h.command("t=a", "");
    try h.registered().dragMove(testing.allocator, &h.output.writer, .{
        .cell_x = 0,
        .cell_y = 0,
        .pixel_x = 0,
        .pixel_y = 0,
        .operations = .{ .copy = true },
    }, &.{"text/plain"});
    h.clear();

    try h.registered().dragLeave(testing.allocator, &h.output.writer);
    try h.expectOutput("\x1b]72;t=m:x=-1:y=-1\x1b\\");
}

test "dnd: client acceptance recorded" {
    var h: Harness = .init();
    defer h.deinit();

    _ = try h.command("t=a", "");
    try testing.expect(h.registered().clientAccepted() == null);

    try testing.expect((try h.command("t=m:o=1", "text/plain")).? == .acceptance);
    try h.expectOutput("");
    try testing.expectEqual(dnd.Operation.copy, h.registered().clientAccepted().?);

    // Rejection.
    try testing.expect((try h.command("t=m:o=0", "")).? == .acceptance);
    try testing.expectEqual(dnd.Operation.none, h.registered().clientAccepted().?);
}

test "dnd: chunked client acceptance" {
    var h: Harness = .init();
    defer h.deinit();

    _ = try h.command("t=a", "");

    // Chunked accept: continuation metadata is ignored, the acceptance
    // is pending until the final chunk.
    try testing.expect((try h.command("t=m:o=2:m=1", "text/pl")) == null);
    try testing.expect(h.registered().clientAccepted() == null);
    try testing.expect((try h.command("t=m:m=1", "ain text")) == null);
    try testing.expect((try h.command("t=m:m=0", "/html")).? == .acceptance);
    try testing.expectEqual(dnd.Operation.move, h.registered().clientAccepted().?);

    // The accumulated list was converted to NUL-separated entries.
    try testing.expectEqualSlices(
        u8,
        "text/plain\x00text/html\x00",
        h.registered().drop.accepted_mimes.items,
    );
}

test "dnd: drop and data serving round trip" {
    var h: Harness = .init();
    defer h.deinit();

    _ = try h.command("t=a", "text/plain text/uri-list");

    const ev: dnd.MoveEvent = .{
        .cell_x = 4,
        .cell_y = 2,
        .pixel_x = 40,
        .pixel_y = 20,
        .operations = .{ .copy = true },
    };
    try h.registered().dragDrop(testing.allocator, &h.output.writer, ev, &.{
        .{ .mime = "text/uri-list", .data = "file:///tmp/a.txt\r\n" },
        .{ .mime = "text/plain", .data = "hello" },
    });
    try h.expectOutput(
        "\x1b]72;t=M:x=4:y=2:X=40:Y=20:o=1:m=0;text/uri-list text/plain \x1b\\",
    );

    // Request the second MIME's data: base64 chunk plus the empty
    // end-of-data message.
    _ = try h.command("t=r:x=2", null);
    try h.expectOutput(
        "\x1b]72;t=r:x=2:m=0;aGVsbG8=\x1b\\" ++ "\x1b]72;t=r:x=2\x1b\\",
    );

    // Out-of-bounds request.
    _ = try h.command("t=r:x=3", null);
    try h.expectOutput(
        "\x1b]72;t=R:x=3:m=0;ENOENT:drop data request index out of bounds\x1b\\",
    );

    // Conclude: the performed operation is reported, held data is
    // freed, and further requests fail.
    try testing.expectEqual(dnd.Event.concluded_copy, (try h.command("t=r:o=1", null)).?);
    try h.expectOutput("");
    try testing.expect((try h.command("t=r:o=1", null)) == null);
    _ = try h.command("t=r:x=1", null);
    try h.expectOutput(
        "\x1b]72;t=R:x=1:m=0;ENOENT:no drop data available\x1b\\",
    );
}

test "dnd: empty item served as a single end-of-data message" {
    var h: Harness = .init();
    defer h.deinit();

    _ = try h.command("t=a", "");
    try h.registered().dragDrop(testing.allocator, &h.output.writer, .{
        .cell_x = 0,
        .cell_y = 0,
        .pixel_x = 0,
        .pixel_y = 0,
        .operations = .{ .copy = true },
    }, &.{.{ .mime = "text/plain", .data = "" }});
    h.clear();

    // Kitty's oracle (test_empty_data) asserts exactly one message:
    // the empty response is itself the end-of-data signal, and a
    // duplicate would be a second completion to the client.
    _ = try h.command("t=r:x=1", null);
    try h.expectOutput("\x1b]72;t=r:x=1\x1b\\");
}

test "dnd: leave without hover sends nothing" {
    var h: Harness = .init();
    defer h.deinit();

    // Client registered but no move was ever forwarded (e.g. it
    // registered mid-drag): kitty only notifies hovered windows.
    _ = try h.command("t=a", "");
    try h.registered().dragLeave(testing.allocator, &h.output.writer);
    try h.expectOutput("");
}

test "dnd: data request with no drop" {
    var h: Harness = .init();
    defer h.deinit();

    _ = try h.command("t=a", "");
    _ = try h.command("t=r:x=1", null);
    try h.expectOutput(
        "\x1b]72;t=R:x=1:m=0;ENOENT:no drop data available\x1b\\",
    );
}

test "dnd: leave after drop is ignored" {
    var h: Harness = .init();
    defer h.deinit();

    _ = try h.command("t=a", "");
    try h.registered().dragDrop(testing.allocator, &h.output.writer, .{
        .cell_x = 0,
        .cell_y = 0,
        .pixel_x = 0,
        .pixel_y = 0,
        .operations = .{ .copy = true },
    }, &.{.{ .mime = "text/plain", .data = "x" }});
    h.clear();

    // Some toolkits emit a leave for the drop itself; the held data
    // must survive so the client can still fetch it.
    try h.registered().dragLeave(testing.allocator, &h.output.writer);
    try h.expectOutput("");

    _ = try h.command("t=r:x=1", null);
    try h.expectOutput(
        "\x1b]72;t=r:x=1:m=0;eA==\x1b\\" ++ "\x1b]72;t=r:x=1\x1b\\",
    );
}

test "dnd: new drag resets held drop data" {
    var h: Harness = .init();
    defer h.deinit();

    _ = try h.command("t=a", "");
    const ev: dnd.MoveEvent = .{
        .cell_x = 0,
        .cell_y = 0,
        .pixel_x = 0,
        .pixel_y = 0,
        .operations = .{ .copy = true },
    };
    try h.registered().dragDrop(testing.allocator, &h.output.writer, ev, &.{
        .{ .mime = "text/plain", .data = "old" },
    });
    h.clear();

    // A new drag entering resets the per-drag state including the held
    // items from the unconcluded previous drop.
    try h.registered().dragMove(testing.allocator, &h.output.writer, ev, &.{"text/plain"});
    h.clear();
    _ = try h.command("t=r:x=1", null);
    try h.expectOutput(
        "\x1b]72;t=R:x=1:m=0;ENOENT:no drop data available\x1b\\",
    );
}

test "dnd: remote transfer requests refused" {
    var h: Harness = .init();
    defer h.deinit();

    _ = try h.command("t=a", "");

    // URI file content request.
    _ = try h.command("t=r:x=1:y=2", null);
    try h.expectOutput(
        "\x1b]72;t=R:x=1:y=2:m=0;EINVAL:remote drop data is not supported\x1b\\",
    );

    // Directory handle request.
    _ = try h.command("t=r:Y=2:x=1", null);
    try h.expectOutput(
        "\x1b]72;t=R:x=1:Y=2:m=0;EINVAL:remote drop data is not supported\x1b\\",
    );
}

test "dnd: drag out refused" {
    var h: Harness = .init();
    defer h.deinit();

    // Enabling and disabling offers is accepted silently and allocates
    // nothing.
    _ = try h.command("t=o:x=1", null);
    _ = try h.command("t=o:x=2", null);
    try h.expectOutput("");
    try testing.expect(h.state == null);

    // Offering a drag is refused.
    _ = try h.command("t=o:x=1", null);
    _ = try h.command("t=o:o=3", "text/plain");
    try h.expectOutput(
        "\x1b]72;t=E:m=0;EPERM:drag out is not supported by this terminal\x1b\\",
    );

    // Starting a drag is refused, echoing the command's client id.
    _ = try h.command("t=P:x=-1:i=9", null);
    try h.expectOutput(
        "\x1b]72;t=E:i=9:m=0;EPERM:drag out is not supported by this terminal\x1b\\",
    );
    try testing.expect(h.state == null);
}

test "dnd: unregister frees held drop data" {
    var h: Harness = .init();
    defer h.deinit();

    _ = try h.command("t=a", "");
    try h.registered().dragDrop(testing.allocator, &h.output.writer, .{
        .cell_x = 0,
        .cell_y = 0,
        .pixel_x = 0,
        .pixel_y = 0,
        .operations = .{ .copy = true },
    }, &.{.{ .mime = "text/plain", .data = "x" }});
    h.clear();

    // The testing allocator would report the held data as leaked if
    // unregistration didn't free the whole state.
    _ = try h.command("t=A", null);
    try testing.expect(h.state == null);
}

test "dnd: chunked registration reuses first chunk metadata" {
    var h: Harness = .init();
    defer h.deinit();

    // Registration split over two chunks: the first chunk allocates
    // the state and seeds chunk reassembly, so the continuation (which
    // carries a different type) is still treated as the registration.
    try testing.expect((try h.command("t=a:i=4:m=1", "text/pla")) == null);
    try testing.expect(h.state != null);
    try testing.expect((try h.command("t=q:m=0", "in")).? == .registration);
    try h.expectOutput("");
    try testing.expectEqual(@as(u32, 4), h.registered().drop.client_id);
    {
        var it = h.registered().registeredMimes();
        try testing.expectEqualStrings("text/plain", it.next().?);
    }

    // A query after the chunked command completes works again.
    _ = try h.command("t=q", null);
    try h.expectOutput("\x1b]72;t=q\x1b\\");
}

test "dnd: malformed metadata ignored" {
    var h: Harness = .init();
    defer h.deinit();

    _ = try h.command("t=a:zz=1", "");
    try h.expectOutput("");
    try testing.expect(h.state == null);

    // Command with no type is ignored, matching kitty (the spec's
    // default of t=a is not honored by the reference implementation).
    _ = try h.command("x=1", "");
    try h.expectOutput("");
    try testing.expect(h.state == null);
}

test "dnd: bel terminator echoed in responses" {
    var h: Harness = .init();
    defer h.deinit();

    _ = try dnd.handleCommand(&h.state, testing.allocator, &h.output.writer, .{
        .metadata = "t=q",
        .payload = null,
        .terminator = .bel,
    });
    try h.expectOutput("\x1b]72;t=q\x07");
}

test "dnd: kitten 0.47 conversation replay" {
    // This replays a conversation recorded from the reference client
    // (`kitten dnd --drop-anywhere=copy --drop text/plain:out.txt`,
    // kitten 0.47.0) driven over a pty by a harness that sent exactly
    // the bytes this engine produces. The kitten accepted the events,
    // wrote the dropped payload to disk intact, and concluded; its
    // client bytes are frozen here as an interop regression test.
    var h: Harness = .init();
    defer h.deinit();

    // Startup: register with MIME list and machine ID, then the test
    // harness reset (unregister both directions, re-register).
    _ = try h.command("t=a:m=0", "text/uri-list text/plain");
    _ = try h.command(
        "t=a:x=1:m=0",
        "1:5cff8247c477900a8727e2281fe890252f8848f87c224dd8dd7fb6303e94ddbd",
    );
    _ = try h.command("t=A", null);
    try testing.expect(h.state == null);
    _ = try h.command("t=o:x=2", null);
    _ = try h.command("t=a:m=0", "text/uri-list text/plain");
    _ = try h.command(
        "t=a:x=1:m=0",
        "1:5cff8247c477900a8727e2281fe890252f8848f87c224dd8dd7fb6303e94ddbd",
    );
    try h.expectOutput("");
    try testing.expect(h.state != null);

    // Native drag moves over the terminal and drops.
    const ev: dnd.MoveEvent = .{
        .cell_x = 2,
        .cell_y = 1,
        .pixel_x = 20,
        .pixel_y = 18,
        .operations = .{ .copy = true },
    };
    try h.registered().dragMove(testing.allocator, &h.output.writer, ev, &.{"text/plain"});
    try h.expectOutput("\x1b]72;t=m:x=2:y=1:X=20:Y=18:o=1:m=0;text/plain \x1b\\");

    // The kitten accepts as a copy of text/plain.
    _ = try h.command("t=m:o=1:m=0", "text/plain");
    try h.expectOutput("");
    try testing.expectEqual(dnd.Operation.copy, h.registered().clientAccepted().?);

    try h.registered().dragDrop(testing.allocator, &h.output.writer, ev, &.{
        .{ .mime = "text/plain", .data = "hello from ghostty\n" },
    });
    try h.expectOutput("\x1b]72;t=M:x=2:y=1:X=20:Y=18:o=1:m=0;text/plain \x1b\\");

    // The kitten requests the data and concludes with a copy.
    _ = try h.command("t=r:x=1", null);
    try h.expectOutput(
        "\x1b]72;t=r:x=1:m=0;aGVsbG8gZnJvbSBnaG9zdHR5Cg==\x1b\\" ++
            "\x1b]72;t=r:x=1\x1b\\",
    );
    _ = try h.command("t=r:o=1", null);
    try h.expectOutput("");
    try testing.expect(h.registered().drop.items == null);
}

test "dnd: large data served in chunks" {
    var h: Harness = .init();
    defer h.deinit();

    _ = try h.command("t=a", "");

    // 3073 bytes: one full chunk plus one byte.
    const data = [_]u8{'Z'} ** 3073;
    try h.registered().dragDrop(testing.allocator, &h.output.writer, .{
        .cell_x = 0,
        .cell_y = 0,
        .pixel_x = 0,
        .pixel_y = 0,
        .operations = .{ .copy = true },
    }, &.{.{ .mime = "application/octet-stream", .data = &data }});
    h.clear();

    _ = try h.command("t=r:x=1", null);
    const out = h.consume();

    // First chunk is m=1 with 4096 base64 chars, second is m=0, and
    // the final message is the bare end-of-data marker.
    try testing.expect(std.mem.startsWith(u8, out, "\x1b]72;t=r:x=1:m=1;"));
    try testing.expect(std.mem.indexOf(u8, out, "\x1b]72;t=r:x=1:m=0;") != null);
    try testing.expect(std.mem.endsWith(u8, out, "\x1b]72;t=r:x=1\x1b\\"));
    h.clear();
}

test "dnd: over-cap registration list never completes" {
    var h: Harness = .init();
    defer h.deinit();

    // Matching kitty, a chunk that would exceed the cap is dropped and
    // the registration is not reported, though the client stays
    // registered (the state exists).
    const big = try testing.allocator.alloc(u8, dnd.max_mime_list_bytes + 1);
    defer testing.allocator.free(big);
    @memset(big, 'a');
    try testing.expect((try h.command("t=a", big)) == null);
    try testing.expect(h.state != null);
    {
        var it = h.registered().registeredMimes();
        try testing.expect(it.next() == null);
    }
}