From b6aeff332748c5c8be7883cd05c27e9ac9512462 Mon Sep 17 00:00:00 2001 From: Vicent Marti Date: Tue, 11 Feb 2025 17:19:59 +0100 Subject: [PATCH] fix integration tests Signed-off-by: Vicent Marti --- go/tools/asthelpergen/integration/paths.go | 38 ++++++++++------------ 1 file changed, 17 insertions(+), 21 deletions(-) diff --git a/go/tools/asthelpergen/integration/paths.go b/go/tools/asthelpergen/integration/paths.go index 7a1fe0ed488..c0ac1b588ce 100644 --- a/go/tools/asthelpergen/integration/paths.go +++ b/go/tools/asthelpergen/integration/paths.go @@ -16,32 +16,28 @@ limitations under the License. package integration -import "encoding/binary" - // This file is a copy of the file go/vt/sqlparser/paths.go // We need it here to be able to test the path accumulation of the rewriter type ASTPath string -func AddStep(path ASTPath, step ASTStep) ASTPath { - b := make([]byte, 2) - binary.BigEndian.PutUint16(b, uint16(step)) - return path + ASTPath(b) -} - -func AddStepWithSliceIndex(path ASTPath, step ASTStep, idx int) ASTPath { - if idx < 255 { - // 2 bytes for step code + 1 byte for index - b := make([]byte, 3) - binary.BigEndian.PutUint16(b[:2], uint16(step)) - b[2] = byte(idx) - return path + ASTPath(b) +// nextPathOffset is an implementation of binary.Uvarint that works directly on +// the ASTPath without having to cast and allocate a byte slice +func (path ASTPath) nextPathOffset() (uint64, int) { + var x uint64 + var s uint + for i := 0; i < len(path); i++ { + b := path[i] + if b < 0x80 { + return x | uint64(b)<