Debian Codegraph @

internal/libyaml/constructor_test.go

raw symbols SCIP
1 // Copyright 2025 The go-yaml Project Contributors
2 // SPDX-License-Identifier: Apache-2.0
3
4 // Tests for the constructor stage.
5 // Verifies YAML node to Go value conversion and error handling.
6
7 package libyaml
8
9 import (
10 "reflect"
11 "testing"
12
13 "go.yaml.in/yaml/v4/internal/testutil/assert"
14 )
15
16 func TestConstructor(t *testing.T) {
17 RunTestCases(t, "constructor.yaml", map[string]TestHandler{
18 "scalar-resolution": func(t *testing.T, tc TestCase) {
19 t.Helper()
20
21 // Load the YAML
22 result, err := LoadAny([]byte(tc.Yaml))
23 assert.NoErrorf(t, err, "LoadAny() error: %v", err)
24
25 // Compare the result with expected value
26 if !reflect.DeepEqual(result, tc.Want) {
27 t.Errorf("LoadAny() = %v (type: %T), want %v (type: %T)",
28 result, result, tc.Want, tc.Want)
29 }
30 },
31 })
32 }