Debian Codegraph @

debian/patches/0001-Fix-int64-value-handling-in-tests-for-cross-architecture.patch

raw
1 From: Arthur Diniz <[email protected]>
2 Date: Fri, 10 Oct 2025 19:33:01 +0100
3 Subject: [PATCH] Fix int64 value handling in tests for cross-architecture
4 compatibility (#120)
5
6 Update test cases with overflow errors on 32-bit (i386) architectures.
7
8 Signed-off-by: Arthur Diniz <[email protected]>
9
10 Origin: upstream, https://github.com/kubernetes-sigs/yaml/commit/537896d426f9ffce54c93ffb8196b4425d5275be
11 Bug: https://github.com/kubernetes-sigs/yaml/pull/120
12 Applied-Upstream: 537896d426f9ffce54c93ffb8196b4425d5275be, not yet in a tagged release (post-v1.6.0)
13 Last-Update: 2026-09-10
14 ---
15 yaml_test.go | 33 ++++++++++++++++++++++++++++++----
16 1 file changed, 29 insertions(+), 4 deletions(-)
17
18 diff --git a/yaml_test.go b/yaml_test.go
19 --- a/yaml_test.go
20 +++ b/yaml_test.go
21 @@ -37,6 +37,26 @@
22 return &str
23 }
24
25 +// newIntPtr returns a pointer to a new int or int64 based on architecture.
26 +// On 64-bit platforms, it returns *int to test unsized int behavior.
27 +// On 32-bit platforms, it returns *int64 to test the large value that doesn't fit in 32-bit int.
28 +func newIntPtr() interface{} {
29 + if strconv.IntSize == 64 {
30 + return new(int)
31 + }
32 + return new(int64)
33 +}
34 +
35 +// expectedIntValue returns the expected decoded value for architecture-specific int tests.
36 +// On 64-bit platforms, it returns the value as int.
37 +// On 32-bit platforms, it returns the value as int64 since the large value doesn't fit in 32-bit int.
38 +func expectedIntValue(value int64) interface{} {
39 + if strconv.IntSize == 64 {
40 + return int(value)
41 + }
42 + return value
43 +}
44 +
45 type errorType int
46
47 const (
48 @@ -183,7 +203,7 @@
49 func TestMarshal(t *testing.T) {
50 f32String := strconv.FormatFloat(math.MaxFloat32, 'g', -1, 32)
51 s := MarshalTest{"a", math.MaxInt64, math.MaxFloat32}
52 - e := []byte(fmt.Sprintf("A: a\nB: %d\nC: %s\n", math.MaxInt64, f32String))
53 + e := []byte(fmt.Sprintf("A: a\nB: %d\nC: %s\n", int64(math.MaxInt64), f32String))
54
55 y, err := Marshal(s)
56 if err != nil {
57 @@ -409,10 +429,15 @@
58 },
59
60 // decoding integers
61 - "decode 2^53 + 1 into int": {
62 + "decode 2^53 + 1 into int64": {
63 + encoded: []byte("9007199254740993"),
64 + decodeInto: new(int64),
65 + decoded: int64(9007199254740993),
66 + },
67 + "decode 2^53 + 1 into int (architecture-specific)": {
68 encoded: []byte("9007199254740993"),
69 - decodeInto: new(int),
70 - decoded: 9007199254740993,
71 + decodeInto: newIntPtr(),
72 + decoded: expectedIntValue(9007199254740993),
73 },
74 "decode 2^53 + 1 into interface": {
75 encoded: []byte("9007199254740993"),