Debian Codegraph @

internal/libyaml/testdata/writer.yaml

raw symbols SCIP
1 # Copyright 2025 The go-yaml Project Contributors
2 # SPDX-License-Identifier: Apache-2.0
3
4 # Writer tests for Emitter output handling
5 #
6 # Purpose: Tests Emitter methods that handle writing and flushing output,
7 # including buffer management and write handlers.
8 #
9 # Format: Test cases use type-as-key format:
10 # - test-type:
11 # name: Test case name
12 # ...
13 #
14 # Test Types:
15 # writer-flush - Tests flush method with various scenarios
16 # writer-error - Tests flush with error conditions
17 # writer-panic - Tests methods that should panic
18 #
19 # Common Keys:
20 # name - Test case name (string, title case)
21 # type - Output handler type (string | writer | error-writer)
22 # data - Data to write to buffer (string or hex byte array)
23 # data2 - Second data chunk for multi-flush tests (optional)
24 # func - Function to call for panic tests (flush, etc.)
25 # want - Expected result:
26 # * For writer-flush: expected output string
27 # * For writer-error: error message substring
28 # * For writer-panic: panic message substring
29 # test - Field checks to perform after flush (list of operator: [field, value])
30 # Field check operators:
31 # * eq: [field, value] - Equals
32 # * len: [field, N] - Length equals N
33 #
34 # flush tests
35 - writer-flush:
36 name: Flush empty buffer
37 type: string
38 want: ''
39 test:
40 - eq: [buffer_pos, 0]
41
42 - writer-flush:
43 name: Flush with data
44 type: string
45 data: test data
46 want: test data
47 test:
48 - eq: [buffer_pos, 0]
49
50 - writer-flush:
51 name: Flush multiple times
52 type: string
53 data: first
54 data2: second
55 want: firstsecond
56
57 - writer-flush:
58 name: Flush with writer
59 type: writer
60 data: test data
61 want: test data
62
63 # error tests
64 - writer-error:
65 name: Flush with write error
66 type: error-writer
67 data: test
68 want: write error
69
70 # panic tests
71 - writer-panic:
72 name: Flush without write handler
73 func: flush
74 data: test
75 want: write handler not set