Skip to content

Commit 899fc7d

Browse files
fix: assert []u8 contents and fix vfmt formatting
Address review feedback: check byte-array payload not just length, to catch pointer corruption that preserves array size. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 5e24d29 commit 899fc7d

1 file changed

Lines changed: 17 additions & 7 deletions

File tree

vlib/v/tests/fns/variadic_interface_chain_forwarding_test.v

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ fn process_params(params []Value) string {
1818
result << 'i32:${param}'
1919
}
2020
[]u8 {
21-
result << '[]u8:${param.len}'
21+
result << '[]u8:${param}'
2222
}
2323
else {
2424
result << 'unknown'
@@ -45,7 +45,9 @@ fn (mut stmt Statement) execute(params ...Value) !string {
4545
fn (stmt Statement) close() ! {}
4646

4747
fn (mut t Transaction) prepare(query string) !Statement {
48-
return Statement{ handle: 1 }
48+
return Statement{
49+
handle: 1
50+
}
4951
}
5052

5153
fn (mut t Transaction) execute(query string, params ...Value) !string {
@@ -89,7 +91,9 @@ fn test_variadic_interface_forwarding_with_match() ! {
8991
conditions, mut params := get_conditions(p)
9092
params = arrays.concat(params, p.offset, p.fetch)
9193

92-
mut tx := Transaction{ handle: 1 }
94+
mut tx := Transaction{
95+
handle: 1
96+
}
9397
result := tx.execute('SELECT * FROM users WHERE ${conditions}', ...params)!
9498
assert result == 'string:info@peony.com, i32:0, i32:10', 'got: ${result}'
9599
}
@@ -103,7 +107,9 @@ fn test_variadic_interface_forwarding_single_param() ! {
103107

104108
conditions, params := get_conditions(p)
105109

106-
mut tx := Transaction{ handle: 1 }
110+
mut tx := Transaction{
111+
handle: 1
112+
}
107113
result := tx.execute('SELECT COUNT(*) FROM users WHERE ${conditions}', ...params)!
108114
assert result == 'string:info@peony.com', 'got: ${result}'
109115
}
@@ -114,9 +120,11 @@ fn test_variadic_interface_forwarding_with_byte_arrays() ! {
114120

115121
mut params := [Value(user_id_bin), email]
116122

117-
mut tx := Transaction{ handle: 1 }
123+
mut tx := Transaction{
124+
handle: 1
125+
}
118126
result := tx.execute('INSERT INTO users', ...params)!
119-
assert result == '[]u8:4, string:info@peony.com', 'got: ${result}'
127+
assert result == '[]u8:&[1, 2, 3, 4], string:info@peony.com', 'got: ${result}'
120128
}
121129

122130
fn test_variadic_interface_forwarding_repeated() ! {
@@ -131,7 +139,9 @@ fn test_variadic_interface_forwarding_repeated() ! {
131139
conditions, mut params := get_conditions(p)
132140
params = arrays.concat(params, p.offset, p.fetch)
133141

134-
mut tx := Transaction{ handle: 1 }
142+
mut tx := Transaction{
143+
handle: 1
144+
}
135145
result := tx.execute('SELECT * FROM users WHERE ${conditions}', ...params)!
136146
assert result == 'string:info@peony.com, string:admin, i32:5, i32:20', 'got: ${result}'
137147
}

0 commit comments

Comments
 (0)