repo stringlengths 6 47 | file_url stringlengths 77 269 | file_path stringlengths 5 186 | content stringlengths 0 32.8k | language stringclasses 1
value | license stringclasses 7
values | commit_sha stringlengths 40 40 | retrieved_at stringdate 2026-01-07 08:35:43 2026-01-07 08:55:24 | truncated bool 2
classes |
|---|---|---|---|---|---|---|---|---|
kubev2v/forklift | https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/github.com/cloudwego/base64x/base64x_subr_amd64.go | vendor/github.com/cloudwego/base64x/base64x_subr_amd64.go |
package base64x
import (
"github.com/cloudwego/base64x/internal/native"
)
// HACK: maintain these only to prevent breakchange, because sonic-go linkname these
var (
_subr__b64decode uintptr
_subr__b64encode uintptr
)
func init() {
_subr__b64decode = native.S_b64decode
_subr__b64encode = native.S_b64encode
}
| go | Apache-2.0 | b3b4703e958c25d54c4d48138d9e80ae32fadac3 | 2026-01-07T09:44:30.792320Z | false |
kubev2v/forklift | https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/github.com/cloudwego/base64x/faststr.go | vendor/github.com/cloudwego/base64x/faststr.go | /*
* Copyright 2024 CloudWeGo Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package base64x
import (
`reflect`
`unsafe`
)
func mem2str(v []byte) (s string) {
(*reflect.StringHeader)(unsafe.Pointer(&s)).Len = (*reflect.SliceHeader)(unsafe.Pointer(&v)).Len
(*reflect.StringHeader)(unsafe.Pointer(&s)).Data = (*reflect.SliceHeader)(unsafe.Pointer(&v)).Data
return
}
func str2mem(s string) (v []byte) {
(*reflect.SliceHeader)(unsafe.Pointer(&v)).Cap = (*reflect.StringHeader)(unsafe.Pointer(&s)).Len
(*reflect.SliceHeader)(unsafe.Pointer(&v)).Len = (*reflect.StringHeader)(unsafe.Pointer(&s)).Len
(*reflect.SliceHeader)(unsafe.Pointer(&v)).Data = (*reflect.StringHeader)(unsafe.Pointer(&s)).Data
return
}
func mem2addr(v []byte) unsafe.Pointer {
return *(*unsafe.Pointer)(unsafe.Pointer(&v))
}
// NoEscape hides a pointer from escape analysis. NoEscape is
// the identity function but escape analysis doesn't think the
// output depends on the input. NoEscape is inlined and currently
// compiles down to zero instructions.
// USE CAREFULLY!
//go:nosplit
//goland:noinspection GoVetUnsafePointer
func noEscape(p unsafe.Pointer) unsafe.Pointer {
x := uintptr(p)
return unsafe.Pointer(x ^ 0)
}
| go | Apache-2.0 | b3b4703e958c25d54c4d48138d9e80ae32fadac3 | 2026-01-07T09:44:30.792320Z | false |
kubev2v/forklift | https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/github.com/cloudwego/base64x/base64x.go | vendor/github.com/cloudwego/base64x/base64x.go | /*
* Copyright 2024 CloudWeGo Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package base64x
import (
`encoding/base64`
"github.com/cloudwego/base64x/internal/native"
)
// An Encoding is a radix 64 encoding/decoding scheme, defined by a
// 64-character alphabet. The most common encoding is the "base64"
// encoding defined in RFC 4648 and used in MIME (RFC 2045) and PEM
// (RFC 1421). RFC 4648 also defines an alternate encoding, which is
// the standard encoding with - and _ substituted for + and /.
type Encoding int
const (
_MODE_URL = 1 << 0
_MODE_RAW = 1 << 1
_MODE_AVX2 = 1 << 2
_MODE_JSON = 1 << 3
)
// StdEncoding is the standard base64 encoding, as defined in
// RFC 4648.
const StdEncoding Encoding = 0
// URLEncoding is the alternate base64 encoding defined in RFC 4648.
// It is typically used in URLs and file names.
const URLEncoding Encoding = _MODE_URL
// RawStdEncoding is the standard raw, unpadded base64 encoding,
// as defined in RFC 4648 section 3.2.
//
// This is the same as StdEncoding but omits padding characters.
const RawStdEncoding Encoding = _MODE_RAW
// RawURLEncoding is the unpadded alternate base64 encoding defined in RFC 4648.
// It is typically used in URLs and file names.
//
// This is the same as URLEncoding but omits padding characters.
const RawURLEncoding Encoding = _MODE_RAW | _MODE_URL
// JSONStdEncoding is the StdEncoding and encoded as JSON string as RFC 8259.
const JSONStdEncoding Encoding = _MODE_JSON;
var (
archFlags = 0
)
/** Encoder Functions **/
// Encode encodes src using the specified encoding, writing
// EncodedLen(len(src)) bytes to out.
//
// The encoding pads the output to a multiple of 4 bytes,
// so Encode is not appropriate for use on individual blocks
// of a large data stream.
//
// If out is not large enough to contain the encoded result,
// it will panic.
func (self Encoding) Encode(out []byte, src []byte) {
if len(src) != 0 {
if buf := out[:0:len(out)]; self.EncodedLen(len(src)) <= len(out) {
self.EncodeUnsafe(&buf, src)
} else {
panic("encoder output buffer is too small")
}
}
}
// EncodeUnsafe behaves like Encode, except it does NOT check if
// out is large enough to contain the encoded result.
//
// It will also update the length of out.
func (self Encoding) EncodeUnsafe(out *[]byte, src []byte) {
native.B64Encode(out, &src, int(self) | archFlags)
}
// EncodeToString returns the base64 encoding of src.
func (self Encoding) EncodeToString(src []byte) string {
nbs := len(src)
ret := make([]byte, 0, self.EncodedLen(nbs))
/* encode in native code */
self.EncodeUnsafe(&ret, src)
return mem2str(ret)
}
// EncodedLen returns the length in bytes of the base64 encoding
// of an input buffer of length n.
func (self Encoding) EncodedLen(n int) int {
if (self & _MODE_RAW) == 0 {
return (n + 2) / 3 * 4
} else {
return (n * 8 + 5) / 6
}
}
/** Decoder Functions **/
// Decode decodes src using the encoding enc. It writes at most
// DecodedLen(len(src)) bytes to out and returns the number of bytes
// written. If src contains invalid base64 data, it will return the
// number of bytes successfully written and base64.CorruptInputError.
//
// New line characters (\r and \n) are ignored.
//
// If out is not large enough to contain the encoded result,
// it will panic.
func (self Encoding) Decode(out []byte, src []byte) (int, error) {
if len(src) == 0 {
return 0, nil
} else if buf := out[:0:len(out)]; self.DecodedLen(len(src)) <= len(out) {
return self.DecodeUnsafe(&buf, src)
} else {
panic("decoder output buffer is too small")
}
}
// DecodeUnsafe behaves like Decode, except it does NOT check if
// out is large enough to contain the decoded result.
//
// It will also update the length of out.
func (self Encoding) DecodeUnsafe(out *[]byte, src []byte) (int, error) {
if n := native.B64Decode(out, mem2addr(src), len(src), int(self) | archFlags); n >= 0 {
return n, nil
} else {
return 0, base64.CorruptInputError(-n - 1)
}
}
// DecodeString returns the bytes represented by the base64 string s.
func (self Encoding) DecodeString(s string) ([]byte, error) {
src := str2mem(s)
ret := make([]byte, 0, self.DecodedLen(len(s)))
/* decode into the allocated buffer */
if _, err := self.DecodeUnsafe(&ret, src); err != nil {
return nil, err
} else {
return ret, nil
}
}
// DecodedLen returns the maximum length in bytes of the decoded data
// corresponding to n bytes of base64-encoded data.
func (self Encoding) DecodedLen(n int) int {
if (self & _MODE_RAW) == 0 {
return n / 4 * 3
} else {
return n * 6 / 8
}
}
| go | Apache-2.0 | b3b4703e958c25d54c4d48138d9e80ae32fadac3 | 2026-01-07T09:44:30.792320Z | false |
kubev2v/forklift | https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/github.com/cloudwego/base64x/internal/native/dispatch.go | vendor/github.com/cloudwego/base64x/internal/native/dispatch.go | package native
import (
"unsafe"
`github.com/klauspost/cpuid/v2`
"github.com/cloudwego/base64x/internal/rt"
"github.com/cloudwego/base64x/internal/native/avx2"
"github.com/cloudwego/base64x/internal/native/sse"
)
var (
hasAVX2 = cpuid.CPU.Has(cpuid.AVX2)
hasSSE = cpuid.CPU.Has(cpuid.SSE)
)
var (
S_b64decode uintptr
S_b64encode uintptr
)
var (
F_b64decode func(out unsafe.Pointer, src unsafe.Pointer, len int, mod int) (ret int)
F_b64encode func(out unsafe.Pointer, src unsafe.Pointer, mod int)
)
func useAVX2() {
avx2.Use()
S_b64decode = avx2.S_b64decode
S_b64encode = avx2.S_b64encode
F_b64decode = avx2.F_b64decode
F_b64encode = avx2.F_b64encode
}
func useSSE() {
sse.Use()
S_b64decode = sse.S_b64decode
S_b64encode = sse.S_b64encode
F_b64decode = sse.F_b64decode
F_b64encode = sse.F_b64encode
}
//go:nosplit
func B64Decode(out *[]byte, src unsafe.Pointer, len int, mod int) (ret int) {
return F_b64decode(rt.NoEscape(unsafe.Pointer(out)), rt.NoEscape(unsafe.Pointer(src)), len, mod)
}
//go:nosplit
func B64Encode(out *[]byte, src *[]byte, mod int) {
F_b64encode(rt.NoEscape(unsafe.Pointer(out)), rt.NoEscape(unsafe.Pointer(src)), mod)
}
func init() {
if hasAVX2 {
useAVX2()
} else if hasSSE {
useSSE()
} else {
panic("Unsupported CPU, lacks of AVX2 or SSE CPUID Flag. maybe it's too old to run Sonic.")
}
}
| go | Apache-2.0 | b3b4703e958c25d54c4d48138d9e80ae32fadac3 | 2026-01-07T09:44:30.792320Z | false |
kubev2v/forklift | https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/github.com/cloudwego/base64x/internal/native/sse/b64decode.go | vendor/github.com/cloudwego/base64x/internal/native/sse/b64decode.go | // Code generated by Bash, DO NOT EDIT.
/*
* Copyright 2025 ByteDance Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package sse
import (
`unsafe`
`github.com/cloudwego/base64x/internal/rt`
)
var F_b64decode func(out unsafe.Pointer, src unsafe.Pointer, len int, mod int) (ret int)
var S_b64decode uintptr
//go:nosplit
func B64decode(out *[]byte, src unsafe.Pointer, len int, mode int) (ret int) {
return F_b64decode(rt.NoEscape(unsafe.Pointer(out)), rt.NoEscape(unsafe.Pointer(src)), len, mode)
}
| go | Apache-2.0 | b3b4703e958c25d54c4d48138d9e80ae32fadac3 | 2026-01-07T09:44:30.792320Z | false |
kubev2v/forklift | https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/github.com/cloudwego/base64x/internal/native/sse/native_export.go | vendor/github.com/cloudwego/base64x/internal/native/sse/native_export.go |
// Code generated by Bash, DO NOT EDIT.
/*
* Copyright 2025 ByteDance Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package sse
import (
`github.com/bytedance/sonic/loader`
)
func Use() {
loader.WrapGoC(_text_b64encode, _cfunc_b64encode, []loader.GoC{{"_b64encode", &S_b64encode, &F_b64encode}}, "sse", "sse/b64encode.c")
loader.WrapGoC(_text_b64decode, _cfunc_b64decode, []loader.GoC{{"_b64decode", &S_b64decode, &F_b64decode}}, "sse", "sse/b64decode.c")
} | go | Apache-2.0 | b3b4703e958c25d54c4d48138d9e80ae32fadac3 | 2026-01-07T09:44:30.792320Z | false |
kubev2v/forklift | https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/github.com/cloudwego/base64x/internal/native/sse/b64encode.go | vendor/github.com/cloudwego/base64x/internal/native/sse/b64encode.go | // Code generated by Bash, DO NOT EDIT.
/*
* Copyright 2025 ByteDance Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package sse
import (
`unsafe`
`github.com/cloudwego/base64x/internal/rt`
)
var F_b64encode func(out unsafe.Pointer, src unsafe.Pointer, mod int)
var S_b64encode uintptr
//go:nosplit
func B64encode(out *[]byte, src *[]byte, mode int) {
F_b64encode(rt.NoEscape(unsafe.Pointer(out)), rt.NoEscape(unsafe.Pointer(src)), mode)
}
| go | Apache-2.0 | b3b4703e958c25d54c4d48138d9e80ae32fadac3 | 2026-01-07T09:44:30.792320Z | false |
kubev2v/forklift | https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/github.com/cloudwego/base64x/internal/native/sse/b64decode_text_amd64.go | vendor/github.com/cloudwego/base64x/internal/native/sse/b64decode_text_amd64.go | // +build amd64
// Code generated by asm2asm, DO NOT EDIT.
package sse
var _text_b64decode = []byte{
// .p2align 4, 0x90
// _b64decode
0x55, // pushq %rbp
0x48, 0x89, 0xe5, //0x00000001 movq %rsp, %rbp
0x41, 0x57, //0x00000004 pushq %r15
0x41, 0x56, //0x00000006 pushq %r14
0x41, 0x55, //0x00000008 pushq %r13
0x41, 0x54, //0x0000000a pushq %r12
0x53, //0x0000000c pushq %rbx
0x48, 0x83, 0xec, 0x60, //0x0000000d subq $96, %rsp
0x48, 0x85, 0xd2, //0x00000011 testq %rdx, %rdx
0x0f, 0x84, 0x54, 0x1a, 0x00, 0x00, //0x00000014 je LBB0_432
0x48, 0x8b, 0x07, //0x0000001a movq (%rdi), %rax
0x48, 0x8b, 0x5f, 0x10, //0x0000001d movq $16(%rdi), %rbx
0x48, 0x89, 0x5d, 0x88, //0x00000021 movq %rbx, $-120(%rbp)
0x48, 0x89, 0xbd, 0x78, 0xff, 0xff, 0xff, //0x00000025 movq %rdi, $-136(%rbp)
0x48, 0x8b, 0x7f, 0x08, //0x0000002c movq $8(%rdi), %rdi
0x48, 0x89, 0x45, 0xb0, //0x00000030 movq %rax, $-80(%rbp)
0x48, 0x01, 0xc7, //0x00000034 addq %rax, %rdi
0x4c, 0x8d, 0x0c, 0x16, //0x00000037 leaq (%rsi,%rdx), %r9
0x89, 0x4d, 0xc4, //0x0000003b movl %ecx, $-60(%rbp)
0xf6, 0xc1, 0x01, //0x0000003e testb $1, %cl
0x48, 0x8d, 0x05, 0xa8, 0x26, 0x00, 0x00, //0x00000041 leaq $9896(%rip), %rax /* _VecDecodeCharsetStd+0(%rip) */
0x48, 0x8d, 0x0d, 0xa1, 0x27, 0x00, 0x00, //0x00000048 leaq $10145(%rip), %rcx /* _VecDecodeCharsetURL+0(%rip) */
0x48, 0x0f, 0x44, 0xc8, //0x0000004f cmoveq %rax, %rcx
0x48, 0x89, 0x4d, 0xd0, //0x00000053 movq %rcx, $-48(%rbp)
0x48, 0x89, 0x55, 0xa0, //0x00000057 movq %rdx, $-96(%rbp)
0x48, 0x8d, 0x4c, 0x16, 0xf8, //0x0000005b leaq $-8(%rsi,%rdx), %rcx
0x48, 0x89, 0x7d, 0xa8, //0x00000060 movq %rdi, $-88(%rbp)
0x49, 0x89, 0xf6, //0x00000064 movq %rsi, %r14
0x48, 0x89, 0xf0, //0x00000067 movq %rsi, %rax
0x48, 0x89, 0x75, 0xb8, //0x0000006a movq %rsi, $-72(%rbp)
0x48, 0x89, 0x4d, 0x90, //0x0000006e movq %rcx, $-112(%rbp)
0x48, 0x39, 0xf1, //0x00000072 cmpq %rsi, %rcx
0x0f, 0x82, 0x09, 0x0d, 0x00, 0x00, //0x00000075 jb LBB0_214
0x48, 0x8b, 0x45, 0xb0, //0x0000007b movq $-80(%rbp), %rax
0x48, 0x8b, 0x4d, 0x88, //0x0000007f movq $-120(%rbp), %rcx
0x48, 0x01, 0xc1, //0x00000083 addq %rax, %rcx
0x48, 0x83, 0xc1, 0xf8, //0x00000086 addq $-8, %rcx
0x48, 0x8b, 0x45, 0xa8, //0x0000008a movq $-88(%rbp), %rax
0x48, 0x89, 0xc7, //0x0000008e movq %rax, %rdi
0x4c, 0x8b, 0x75, 0xb8, //0x00000091 movq $-72(%rbp), %r14
0x48, 0x89, 0x4d, 0x98, //0x00000095 movq %rcx, $-104(%rbp)
0x48, 0x39, 0xc8, //0x00000099 cmpq %rcx, %rax
0x0f, 0x87, 0xe2, 0x0c, 0x00, 0x00, //0x0000009c ja LBB0_214
0x4c, 0x8b, 0x75, 0xb8, //0x000000a2 movq $-72(%rbp), %r14
0x48, 0x8b, 0x45, 0xa0, //0x000000a6 movq $-96(%rbp), %rax
0x4c, 0x01, 0xf0, //0x000000aa addq %r14, %rax
0x48, 0x83, 0xc0, 0xff, //0x000000ad addq $-1, %rax
0x48, 0x89, 0x45, 0x80, //0x000000b1 movq %rax, $-128(%rbp)
0x48, 0x8b, 0x7d, 0xa8, //0x000000b5 movq $-88(%rbp), %rdi
0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, //0x000000b9 .p2align 4, 0x90
//0x000000c0 LBB0_4
0x48, 0x89, 0x7d, 0xc8, //0x000000c0 movq %rdi, $-56(%rbp)
0x41, 0x0f, 0xb6, 0x06, //0x000000c4 movzbl (%r14), %eax
0x48, 0x8b, 0x4d, 0xd0, //0x000000c8 movq $-48(%rbp), %rcx
0x44, 0x0f, 0xb6, 0x2c, 0x01, //0x000000cc movzbl (%rcx,%rax), %r13d
0x41, 0x0f, 0xb6, 0x46, 0x01, //0x000000d1 movzbl $1(%r14), %eax
0x0f, 0xb6, 0x14, 0x01, //0x000000d6 movzbl (%rcx,%rax), %edx
0x41, 0x0f, 0xb6, 0x46, 0x02, //0x000000da movzbl $2(%r14), %eax
0x44, 0x0f, 0xb6, 0x3c, 0x01, //0x000000df movzbl (%rcx,%rax), %r15d
0x41, 0x0f, 0xb6, 0x46, 0x03, //0x000000e4 movzbl $3(%r14), %eax
0x0f, 0xb6, 0x04, 0x01, //0x000000e9 movzbl (%rcx,%rax), %eax
0x41, 0x0f, 0xb6, 0x76, 0x04, //0x000000ed movzbl $4(%r14), %esi
0x44, 0x0f, 0xb6, 0x14, 0x31, //0x000000f2 movzbl (%rcx,%rsi), %r10d
0x41, 0x0f, 0xb6, 0x7e, 0x05, //0x000000f7 movzbl $5(%r14), %edi
0x44, 0x0f, 0xb6, 0x1c, 0x39, //0x000000fc movzbl (%rcx,%rdi), %r11d
0x41, 0x0f, 0xb6, 0x7e, 0x06, //0x00000101 movzbl $6(%r14), %edi
0x0f, 0xb6, 0x3c, 0x39, //0x00000106 movzbl (%rcx,%rdi), %edi
0x41, 0x0f, 0xb6, 0x5e, 0x07, //0x0000010a movzbl $7(%r14), %ebx
0x0f, 0xb6, 0x1c, 0x19, //0x0000010f movzbl (%rcx,%rbx), %ebx
0x41, 0x89, 0xd0, //0x00000113 movl %edx, %r8d
0x45, 0x09, 0xe8, //0x00000116 orl %r13d, %r8d
0x41, 0x89, 0xc4, //0x00000119 movl %eax, %r12d
0x45, 0x09, 0xfc, //0x0000011c orl %r15d, %r12d
0x45, 0x09, 0xc4, //0x0000011f orl %r8d, %r12d
0x44, 0x89, 0xd9, //0x00000122 movl %r11d, %ecx
0x44, 0x09, 0xd1, //0x00000125 orl %r10d, %ecx
0x89, 0xfe, //0x00000128 movl %edi, %esi
0x09, 0xce, //0x0000012a orl %ecx, %esi
0x44, 0x09, 0xe6, //0x0000012c orl %r12d, %esi
0x89, 0xd9, //0x0000012f movl %ebx, %ecx
0x09, 0xf1, //0x00000131 orl %esi, %ecx
0x80, 0xf9, 0xff, //0x00000133 cmpb $-1, %cl
0x0f, 0x84, 0x54, 0x00, 0x00, 0x00, //0x00000136 je LBB0_6
0x49, 0xc1, 0xe5, 0x3a, //0x0000013c shlq $58, %r13
0x48, 0xc1, 0xe2, 0x34, //0x00000140 shlq $52, %rdx
0x4c, 0x09, 0xea, //0x00000144 orq %r13, %rdx
0x49, 0xc1, 0xe7, 0x2e, //0x00000147 shlq $46, %r15
0x48, 0xc1, 0xe0, 0x28, //0x0000014b shlq $40, %rax
0x4c, 0x09, 0xf8, //0x0000014f orq %r15, %rax
0x48, 0x09, 0xd0, //0x00000152 orq %rdx, %rax
0x49, 0xc1, 0xe2, 0x22, //0x00000155 shlq $34, %r10
0x49, 0xc1, 0xe3, 0x1c, //0x00000159 shlq $28, %r11
0x4d, 0x09, 0xd3, //0x0000015d orq %r10, %r11
0x48, 0xc1, 0xe7, 0x16, //0x00000160 shlq $22, %rdi
0x4c, 0x09, 0xdf, //0x00000164 orq %r11, %rdi
0x48, 0x09, 0xc7, //0x00000167 orq %rax, %rdi
0x48, 0xc1, 0xe3, 0x10, //0x0000016a shlq $16, %rbx
0x48, 0x09, 0xfb, //0x0000016e orq %rdi, %rbx
0x48, 0x0f, 0xcb, //0x00000171 bswapq %rbx
0x48, 0x8b, 0x7d, 0xc8, //0x00000174 movq $-56(%rbp), %rdi
0x48, 0x89, 0x1f, //0x00000178 movq %rbx, (%rdi)
0x49, 0x83, 0xc6, 0x08, //0x0000017b addq $8, %r14
0x48, 0x83, 0xc7, 0x06, //0x0000017f addq $6, %rdi
0xe9, 0xe8, 0x06, 0x00, 0x00, //0x00000183 jmp LBB0_156
0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, //0x00000188 .p2align 4, 0x90
//0x00000190 LBB0_6
0x4d, 0x39, 0xce, //0x00000190 cmpq %r9, %r14
0x0f, 0x83, 0xcc, 0x00, 0x00, 0x00, //0x00000193 jae LBB0_18
0x4d, 0x89, 0xf5, //0x00000199 movq %r14, %r13
0xf6, 0x45, 0xc4, 0x08, //0x0000019c testb $8, $-60(%rbp)
0x0f, 0x84, 0x17, 0x00, 0x00, 0x00, //0x000001a0 je LBB0_9
0xe9, 0xd8, 0x00, 0x00, 0x00, //0x000001a6 jmp LBB0_21
0x90, 0x90, 0x90, 0x90, 0x90, //0x000001ab .p2align 4, 0x90
//0x000001b0 LBB0_8
0x49, 0x83, 0xc5, 0x01, //0x000001b0 addq $1, %r13
0x4d, 0x39, 0xcd, //0x000001b4 cmpq %r9, %r13
0x0f, 0x83, 0xed, 0x01, 0x00, 0x00, //0x000001b7 jae LBB0_37
//0x000001bd LBB0_9
0x41, 0x0f, 0xb6, 0x7d, 0x00, //0x000001bd movzbl (%r13), %edi
0x48, 0x83, 0xff, 0x0d, //0x000001c2 cmpq $13, %rdi
0x0f, 0x84, 0xe4, 0xff, 0xff, 0xff, //0x000001c6 je LBB0_8
0x40, 0x80, 0xff, 0x0a, //0x000001cc cmpb $10, %dil
0x0f, 0x84, 0xda, 0xff, 0xff, 0xff, //0x000001d0 je LBB0_8
0x48, 0x8b, 0x45, 0xd0, //0x000001d6 movq $-48(%rbp), %rax
0x0f, 0xb6, 0x1c, 0x38, //0x000001da movzbl (%rax,%rdi), %ebx
0x49, 0x83, 0xc5, 0x01, //0x000001de addq $1, %r13
0x81, 0xfb, 0xff, 0x00, 0x00, 0x00, //0x000001e2 cmpl $255, %ebx
0x0f, 0x84, 0xea, 0x02, 0x00, 0x00, //0x000001e8 je LBB0_61
0xbe, 0x01, 0x00, 0x00, 0x00, //0x000001ee movl $1, %esi
0x4d, 0x39, 0xcd, //0x000001f3 cmpq %r9, %r13
0x0f, 0x82, 0x21, 0x00, 0x00, 0x00, //0x000001f6 jb LBB0_14
0xe9, 0x66, 0x02, 0x00, 0x00, //0x000001fc jmp LBB0_51
0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, //0x00000201 .p2align 4, 0x90
//0x00000210 LBB0_13
0x49, 0x83, 0xc5, 0x01, //0x00000210 addq $1, %r13
0x4d, 0x39, 0xcd, //0x00000214 cmpq %r9, %r13
0x0f, 0x83, 0x9d, 0x04, 0x00, 0x00, //0x00000217 jae LBB0_94
//0x0000021d LBB0_14
0x41, 0x0f, 0xb6, 0x7d, 0x00, //0x0000021d movzbl (%r13), %edi
0x48, 0x83, 0xff, 0x0d, //0x00000222 cmpq $13, %rdi
0x0f, 0x84, 0xe4, 0xff, 0xff, 0xff, //0x00000226 je LBB0_13
0x40, 0x80, 0xff, 0x0a, //0x0000022c cmpb $10, %dil
0x0f, 0x84, 0xda, 0xff, 0xff, 0xff, //0x00000230 je LBB0_13
0x48, 0x8b, 0x45, 0xd0, //0x00000236 movq $-48(%rbp), %rax
0x0f, 0xb6, 0x04, 0x38, //0x0000023a movzbl (%rax,%rdi), %eax
0x49, 0x83, 0xc5, 0x01, //0x0000023e addq $1, %r13
0x3d, 0xff, 0x00, 0x00, 0x00, //0x00000242 cmpl $255, %eax
0x0f, 0x84, 0x1d, 0x08, 0x00, 0x00, //0x00000247 je LBB0_147
0xc1, 0xe3, 0x06, //0x0000024d shll $6, %ebx
0x09, 0xc3, //0x00000250 orl %eax, %ebx
0xbe, 0x02, 0x00, 0x00, 0x00, //0x00000252 movl $2, %esi
0x4d, 0x39, 0xcd, //0x00000257 cmpq %r9, %r13
0x0f, 0x82, 0x82, 0x01, 0x00, 0x00, //0x0000025a jb LBB0_41
0xe9, 0x02, 0x02, 0x00, 0x00, //0x00000260 jmp LBB0_51
//0x00000265 LBB0_18
0x48, 0x8b, 0x7d, 0xc8, //0x00000265 movq $-56(%rbp), %rdi
0xe9, 0x02, 0x06, 0x00, 0x00, //0x00000269 jmp LBB0_156
//0x0000026e LBB0_35
0x80, 0xf9, 0x6e, //0x0000026e cmpb $110, %cl
0x0f, 0x85, 0xbb, 0x01, 0x00, 0x00, //0x00000271 jne LBB0_46
//0x00000277 LBB0_19
0x49, 0x89, 0xc5, //0x00000277 movq %rax, %r13
//0x0000027a LBB0_20
0x4d, 0x39, 0xcd, //0x0000027a cmpq %r9, %r13
0x0f, 0x83, 0x27, 0x01, 0x00, 0x00, //0x0000027d jae LBB0_37
//0x00000283 LBB0_21
0x49, 0x8d, 0x4d, 0x01, //0x00000283 leaq $1(%r13), %rcx
0x41, 0x0f, 0xb6, 0x45, 0x00, //0x00000287 movzbl (%r13), %eax
0x3c, 0x5c, //0x0000028c cmpb $92, %al
0x0f, 0x85, 0xfc, 0x00, 0x00, 0x00, //0x0000028e jne LBB0_33
0x49, 0x8d, 0x45, 0x02, //0x00000294 leaq $2(%r13), %rax
0x40, 0xb7, 0xff, //0x00000298 movb $-1, %dil
0x4c, 0x39, 0xc8, //0x0000029b cmpq %r9, %rax
0x0f, 0x87, 0x86, 0x01, 0x00, 0x00, //0x0000029e ja LBB0_45
0x0f, 0xb6, 0x09, //0x000002a4 movzbl (%rcx), %ecx
0x80, 0xf9, 0x71, //0x000002a7 cmpb $113, %cl
0x0f, 0x8e, 0xbe, 0xff, 0xff, 0xff, //0x000002aa jle LBB0_35
0x80, 0xf9, 0x72, //0x000002b0 cmpb $114, %cl
0x0f, 0x84, 0xbe, 0xff, 0xff, 0xff, //0x000002b3 je LBB0_19
0x80, 0xf9, 0x75, //0x000002b9 cmpb $117, %cl
0x0f, 0x85, 0x7c, 0x01, 0x00, 0x00, //0x000002bc jne LBB0_48
0x4c, 0x89, 0xc9, //0x000002c2 movq %r9, %rcx
0x48, 0x29, 0xc1, //0x000002c5 subq %rax, %rcx
0x48, 0x83, 0xf9, 0x04, //0x000002c8 cmpq $4, %rcx
0x0f, 0x8c, 0x6c, 0x01, 0x00, 0x00, //0x000002cc jl LBB0_48
0x8b, 0x08, //0x000002d2 movl (%rax), %ecx
0x89, 0xca, //0x000002d4 movl %ecx, %edx
0xf7, 0xd2, //0x000002d6 notl %edx
0x8d, 0xb1, 0xd0, 0xcf, 0xcf, 0xcf, //0x000002d8 leal $-808464432(%rcx), %esi
0x81, 0xe2, 0x80, 0x80, 0x80, 0x80, //0x000002de andl $-2139062144, %edx
0x85, 0xf2, //0x000002e4 testl %esi, %edx
0x0f, 0x85, 0x52, 0x01, 0x00, 0x00, //0x000002e6 jne LBB0_48
0x8d, 0xb1, 0x19, 0x19, 0x19, 0x19, //0x000002ec leal $421075225(%rcx), %esi
0x09, 0xce, //0x000002f2 orl %ecx, %esi
0xf7, 0xc6, 0x80, 0x80, 0x80, 0x80, //0x000002f4 testl $-2139062144, %esi
0x0f, 0x85, 0x3e, 0x01, 0x00, 0x00, //0x000002fa jne LBB0_48
0x89, 0xce, //0x00000300 movl %ecx, %esi
0x81, 0xe6, 0x7f, 0x7f, 0x7f, 0x7f, //0x00000302 andl $2139062143, %esi
0xbb, 0xc0, 0xc0, 0xc0, 0xc0, //0x00000308 movl $-1061109568, %ebx
0x29, 0xf3, //0x0000030d subl %esi, %ebx
0x44, 0x8d, 0x86, 0x46, 0x46, 0x46, 0x46, //0x0000030f leal $1179010630(%rsi), %r8d
0x21, 0xd3, //0x00000316 andl %edx, %ebx
0x44, 0x85, 0xc3, //0x00000318 testl %r8d, %ebx
0x0f, 0x85, 0x1d, 0x01, 0x00, 0x00, //0x0000031b jne LBB0_48
0xbb, 0xe0, 0xe0, 0xe0, 0xe0, //0x00000321 movl $-522133280, %ebx
0x29, 0xf3, //0x00000326 subl %esi, %ebx
0x81, 0xc6, 0x39, 0x39, 0x39, 0x39, //0x00000328 addl $960051513, %esi
0x21, 0xda, //0x0000032e andl %ebx, %edx
0x85, 0xf2, //0x00000330 testl %esi, %edx
0x0f, 0x85, 0x06, 0x01, 0x00, 0x00, //0x00000332 jne LBB0_48
0x0f, 0xc9, //0x00000338 bswapl %ecx
0x89, 0xc8, //0x0000033a movl %ecx, %eax
0xc1, 0xe8, 0x04, //0x0000033c shrl $4, %eax
0xf7, 0xd0, //0x0000033f notl %eax
0x25, 0x01, 0x01, 0x01, 0x01, //0x00000341 andl $16843009, %eax
0x8d, 0x04, 0xc0, //0x00000346 leal (%rax,%rax,8), %eax
0x81, 0xe1, 0x0f, 0x0f, 0x0f, 0x0f, //0x00000349 andl $252645135, %ecx
0x01, 0xc1, //0x0000034f addl %eax, %ecx
0x89, 0xc8, //0x00000351 movl %ecx, %eax
0xc1, 0xe8, 0x04, //0x00000353 shrl $4, %eax
0x09, 0xc8, //0x00000356 orl %ecx, %eax
0x89, 0xc1, //0x00000358 movl %eax, %ecx
0xc1, 0xe9, 0x08, //0x0000035a shrl $8, %ecx
0x81, 0xe1, 0x00, 0xff, 0x00, 0x00, //0x0000035d andl $65280, %ecx
0x89, 0xc2, //0x00000363 movl %eax, %edx
0x81, 0xe2, 0x80, 0x00, 0x00, 0x00, //0x00000365 andl $128, %edx
0x49, 0x83, 0xc5, 0x06, //0x0000036b addq $6, %r13
0x09, 0xca, //0x0000036f orl %ecx, %edx
0x0f, 0x85, 0xca, 0x00, 0x00, 0x00, //0x00000371 jne LBB0_49
0x3c, 0x0d, //0x00000377 cmpb $13, %al
0x0f, 0x85, 0x1c, 0x00, 0x00, 0x00, //0x00000379 jne LBB0_34
0xe9, 0xf6, 0xfe, 0xff, 0xff, //0x0000037f jmp LBB0_20
0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, //0x00000384 .p2align 4, 0x90
//0x00000390 LBB0_33
0x49, 0x89, 0xcd, //0x00000390 movq %rcx, %r13
0x3c, 0x0d, //0x00000393 cmpb $13, %al
0x0f, 0x84, 0xdf, 0xfe, 0xff, 0xff, //0x00000395 je LBB0_20
//0x0000039b LBB0_34
0x89, 0xc7, //0x0000039b movl %eax, %edi
0x3c, 0x0a, //0x0000039d cmpb $10, %al
0x0f, 0x84, 0xd5, 0xfe, 0xff, 0xff, //0x0000039f je LBB0_20
0xe9, 0x97, 0x00, 0x00, 0x00, //0x000003a5 jmp LBB0_49
//0x000003aa LBB0_37
0x31, 0xf6, //0x000003aa xorl %esi, %esi
0x31, 0xdb, //0x000003ac xorl %ebx, %ebx
//0x000003ae LBB0_38
0x85, 0xf6, //0x000003ae testl %esi, %esi
0x48, 0x8b, 0x7d, 0xc8, //0x000003b0 movq $-56(%rbp), %rdi
0x0f, 0x85, 0xad, 0x00, 0x00, 0x00, //0x000003b4 jne LBB0_51
0x4d, 0x89, 0xee, //0x000003ba movq %r13, %r14
0xe9, 0xae, 0x04, 0x00, 0x00, //0x000003bd jmp LBB0_156
0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, //0x000003c2 .p2align 4, 0x90
//0x000003d0 LBB0_40
0x49, 0x83, 0xc5, 0x01, //0x000003d0 addq $1, %r13
0xbe, 0x02, 0x00, 0x00, 0x00, //0x000003d4 movl $2, %esi
0x4d, 0x39, 0xcd, //0x000003d9 cmpq %r9, %r13
0x0f, 0x83, 0xcc, 0xff, 0xff, 0xff, //0x000003dc jae LBB0_38
//0x000003e2 LBB0_41
0x41, 0x0f, 0xb6, 0x7d, 0x00, //0x000003e2 movzbl (%r13), %edi
0x48, 0x83, 0xff, 0x0d, //0x000003e7 cmpq $13, %rdi
0x0f, 0x84, 0xdf, 0xff, 0xff, 0xff, //0x000003eb je LBB0_40
0x40, 0x80, 0xff, 0x0a, //0x000003f1 cmpb $10, %dil
0x0f, 0x84, 0xd5, 0xff, 0xff, 0xff, //0x000003f5 je LBB0_40
0x48, 0x8b, 0x45, 0xd0, //0x000003fb movq $-48(%rbp), %rax
0x0f, 0xb6, 0x04, 0x38, //0x000003ff movzbl (%rax,%rdi), %eax
0x49, 0x83, 0xc5, 0x01, //0x00000403 addq $1, %r13
0x3d, 0xff, 0x00, 0x00, 0x00, //0x00000407 cmpl $255, %eax
0x0f, 0x84, 0x18, 0x09, 0x00, 0x00, //0x0000040c je LBB0_182
0xc1, 0xe3, 0x06, //0x00000412 shll $6, %ebx
0x09, 0xc3, //0x00000415 orl %eax, %ebx
0xbe, 0x03, 0x00, 0x00, 0x00, //0x00000417 movl $3, %esi
0x4d, 0x39, 0xcd, //0x0000041c cmpq %r9, %r13
0x0f, 0x82, 0x7e, 0x04, 0x00, 0x00, //0x0000041f jb LBB0_119
0xe9, 0x3d, 0x00, 0x00, 0x00, //0x00000425 jmp LBB0_51
//0x0000042a LBB0_45
0x49, 0x89, 0xcd, //0x0000042a movq %rcx, %r13
0xe9, 0x0f, 0x00, 0x00, 0x00, //0x0000042d jmp LBB0_49
//0x00000432 LBB0_46
0x80, 0xf9, 0x2f, //0x00000432 cmpb $47, %cl
0x0f, 0x85, 0x03, 0x00, 0x00, 0x00, //0x00000435 jne LBB0_48
0x40, 0xb7, 0x2f, //0x0000043b movb $47, %dil
//0x0000043e LBB0_48
0x49, 0x89, 0xc5, //0x0000043e movq %rax, %r13
//0x00000441 LBB0_49
0x40, 0x0f, 0xb6, 0xc7, //0x00000441 movzbl %dil, %eax
0x48, 0x8b, 0x4d, 0xd0, //0x00000445 movq $-48(%rbp), %rcx
0x0f, 0xb6, 0x1c, 0x01, //0x00000449 movzbl (%rcx,%rax), %ebx
0x81, 0xfb, 0xff, 0x00, 0x00, 0x00, //0x0000044d cmpl $255, %ebx
0x0f, 0x84, 0x7f, 0x00, 0x00, 0x00, //0x00000453 je LBB0_61
0xbe, 0x01, 0x00, 0x00, 0x00, //0x00000459 movl $1, %esi
0x4d, 0x39, 0xcd, //0x0000045e cmpq %r9, %r13
0x0f, 0x82, 0x2d, 0x01, 0x00, 0x00, //0x00000461 jb LBB0_77
//0x00000467 LBB0_51
0xf6, 0x45, 0xc4, 0x02, //0x00000467 testb $2, $-60(%rbp)
0x0f, 0x94, 0xc0, //0x0000046b sete %al
0x83, 0xfe, 0x01, //0x0000046e cmpl $1, %esi
0x0f, 0x94, 0xc1, //0x00000471 sete %cl
0x4d, 0x39, 0xcd, //0x00000474 cmpq %r9, %r13
0x0f, 0x82, 0x11, 0x00, 0x00, 0x00, //0x00000477 jb LBB0_54
0x83, 0xfe, 0x04, //0x0000047d cmpl $4, %esi
0x0f, 0x84, 0x08, 0x00, 0x00, 0x00, //0x00000480 je LBB0_54
0x08, 0xc8, //0x00000486 orb %cl, %al
0x0f, 0x85, 0xc0, 0x03, 0x00, 0x00, //0x00000488 jne LBB0_155
//0x0000048e LBB0_54
0xb0, 0x04, //0x0000048e movb $4, %al
0x40, 0x28, 0xf0, //0x00000490 subb %sil, %al
0x0f, 0xb6, 0xc0, //0x00000493 movzbl %al, %eax
0x01, 0xc0, //0x00000496 addl %eax, %eax
0x8d, 0x0c, 0x40, //0x00000498 leal (%rax,%rax,2), %ecx
0xd3, 0xe3, //0x0000049b shll %cl, %ebx
0x83, 0xfe, 0x02, //0x0000049d cmpl $2, %esi
0x48, 0x8b, 0x7d, 0xc8, //0x000004a0 movq $-56(%rbp), %rdi
0x0f, 0x84, 0x18, 0x00, 0x00, 0x00, //0x000004a4 je LBB0_59
0x83, 0xfe, 0x03, //0x000004aa cmpl $3, %esi
0x0f, 0x84, 0x0c, 0x00, 0x00, 0x00, //0x000004ad je LBB0_58
0x83, 0xfe, 0x04, //0x000004b3 cmpl $4, %esi
0x0f, 0x85, 0x0b, 0x00, 0x00, 0x00, //0x000004b6 jne LBB0_60
0x88, 0x5f, 0x02, //0x000004bc movb %bl, $2(%rdi)
//0x000004bf LBB0_58
0x88, 0x7f, 0x01, //0x000004bf movb %bh, $1(%rdi)
//0x000004c2 LBB0_59
0xc1, 0xeb, 0x10, //0x000004c2 shrl $16, %ebx
0x88, 0x1f, //0x000004c5 movb %bl, (%rdi)
//0x000004c7 LBB0_60
0x89, 0xf0, //0x000004c7 movl %esi, %eax
0x48, 0x01, 0xc7, //0x000004c9 addq %rax, %rdi
0x48, 0x83, 0xc7, 0xff, //0x000004cc addq $-1, %rdi
0x4d, 0x89, 0xee, //0x000004d0 movq %r13, %r14
0xe9, 0x98, 0x03, 0x00, 0x00, //0x000004d3 jmp LBB0_156
//0x000004d8 LBB0_61
0x31, 0xf6, //0x000004d8 xorl %esi, %esi
0x31, 0xdb, //0x000004da xorl %ebx, %ebx
//0x000004dc LBB0_62
0xf6, 0x45, 0xc4, 0x02, //0x000004dc testb $2, $-60(%rbp)
0x0f, 0x85, 0x68, 0x03, 0x00, 0x00, //0x000004e0 jne LBB0_155
0x40, 0x80, 0xff, 0x3d, //0x000004e6 cmpb $61, %dil
0x0f, 0x85, 0x5e, 0x03, 0x00, 0x00, //0x000004ea jne LBB0_155
0x83, 0xfe, 0x02, //0x000004f0 cmpl $2, %esi
0x0f, 0x82, 0x55, 0x03, 0x00, 0x00, //0x000004f3 jb LBB0_155
0x41, 0xbb, 0x05, 0x00, 0x00, 0x00, //0x000004f9 movl $5, %r11d
0x41, 0x29, 0xf3, //0x000004ff subl %esi, %r11d
0xf6, 0x45, 0xc4, 0x08, //0x00000502 testb $8, $-60(%rbp)
0x0f, 0x85, 0xb8, 0x01, 0x00, 0x00, //0x00000506 jne LBB0_95
0x4d, 0x39, 0xcd, //0x0000050c cmpq %r9, %r13
0x0f, 0x83, 0x79, 0xff, 0xff, 0xff, //0x0000050f jae LBB0_54
0x49, 0x8d, 0x4d, 0x01, //0x00000515 leaq $1(%r13), %rcx
0x48, 0x8b, 0x45, 0x80, //0x00000519 movq $-128(%rbp), %rax
0x4c, 0x29, 0xe8, //0x0000051d subq %r13, %rax
0x49, 0x83, 0xc5, 0x02, //0x00000520 addq $2, %r13
0x4c, 0x89, 0xea, //0x00000524 movq %r13, %rdx
0x49, 0x89, 0xcd, //0x00000527 movq %rcx, %r13
0xe9, 0x13, 0x00, 0x00, 0x00, //0x0000052a jmp LBB0_69
0x90, //0x0000052f .p2align 4, 0x90
//0x00000530 LBB0_68
0x49, 0x83, 0xc5, 0x01, //0x00000530 addq $1, %r13
0x48, 0x83, 0xc2, 0x01, //0x00000534 addq $1, %rdx
0x48, 0x83, 0xc0, 0xff, //0x00000538 addq $-1, %rax
0x0f, 0x83, 0x32, 0x05, 0x00, 0x00, //0x0000053c jae LBB0_148
//0x00000542 LBB0_69
0x41, 0x0f, 0xb6, 0x4d, 0xff, //0x00000542 movzbl $-1(%r13), %ecx
0x80, 0xf9, 0x0a, //0x00000547 cmpb $10, %cl
0x0f, 0x84, 0xe0, 0xff, 0xff, 0xff, //0x0000054a je LBB0_68
0x80, 0xf9, 0x0d, //0x00000550 cmpb $13, %cl
0x0f, 0x84, 0xd7, 0xff, 0xff, 0xff, //0x00000553 je LBB0_68
0x80, 0xf9, 0x3d, //0x00000559 cmpb $61, %cl
0x0f, 0x85, 0xec, 0x02, 0x00, 0x00, //0x0000055c jne LBB0_155
0x41, 0x83, 0xfb, 0x02, //0x00000562 cmpl $2, %r11d
0x0f, 0x84, 0xe2, 0x02, 0x00, 0x00, //0x00000566 je LBB0_155
0x4d, 0x39, 0xcd, //0x0000056c cmpq %r9, %r13
0x0f, 0x83, 0x19, 0xff, 0xff, 0xff, //0x0000056f jae LBB0_54
0x49, 0x01, 0xc5, //0x00000575 addq %rax, %r13
0x31, 0xc9, //0x00000578 xorl %ecx, %ecx
0xe9, 0xb4, 0x02, 0x00, 0x00, //0x0000057a jmp LBB0_115
//0x0000057f LBB0_91
0x80, 0xf9, 0x6e, //0x0000057f cmpb $110, %cl
0x0f, 0x85, 0x60, 0x03, 0x00, 0x00, //0x00000582 jne LBB0_124
//0x00000588 LBB0_75
0x49, 0x89, 0xc5, //0x00000588 movq %rax, %r13
//0x0000058b LBB0_76
0x4d, 0x39, 0xcd, //0x0000058b cmpq %r9, %r13
0x0f, 0x83, 0x26, 0x01, 0x00, 0x00, //0x0000058e jae LBB0_94
//0x00000594 LBB0_77
0x49, 0x8d, 0x4d, 0x01, //0x00000594 leaq $1(%r13), %rcx
0x41, 0x0f, 0xb6, 0x45, 0x00, //0x00000598 movzbl (%r13), %eax
0x3c, 0x5c, //0x0000059d cmpb $92, %al
0x0f, 0x85, 0xfb, 0x00, 0x00, 0x00, //0x0000059f jne LBB0_89
0x49, 0x8d, 0x45, 0x02, //0x000005a5 leaq $2(%r13), %rax
0x40, 0xb7, 0xff, //0x000005a9 movb $-1, %dil
0x4c, 0x39, 0xc8, //0x000005ac cmpq %r9, %rax
0x0f, 0x87, 0xd4, 0x02, 0x00, 0x00, //0x000005af ja LBB0_117
0x0f, 0xb6, 0x09, //0x000005b5 movzbl (%rcx), %ecx
0x80, 0xf9, 0x71, //0x000005b8 cmpb $113, %cl
0x0f, 0x8e, 0xbe, 0xff, 0xff, 0xff, //0x000005bb jle LBB0_91
0x80, 0xf9, 0x72, //0x000005c1 cmpb $114, %cl
0x0f, 0x84, 0xbe, 0xff, 0xff, 0xff, //0x000005c4 je LBB0_75
0x80, 0xf9, 0x75, //0x000005ca cmpb $117, %cl
0x0f, 0x85, 0x21, 0x03, 0x00, 0x00, //0x000005cd jne LBB0_126
0x4c, 0x89, 0xc9, //0x000005d3 movq %r9, %rcx
0x48, 0x29, 0xc1, //0x000005d6 subq %rax, %rcx
0x48, 0x83, 0xf9, 0x04, //0x000005d9 cmpq $4, %rcx
0x0f, 0x8c, 0x11, 0x03, 0x00, 0x00, //0x000005dd jl LBB0_126
0x8b, 0x08, //0x000005e3 movl (%rax), %ecx
0x89, 0xca, //0x000005e5 movl %ecx, %edx
0xf7, 0xd2, //0x000005e7 notl %edx
0x8d, 0xb1, 0xd0, 0xcf, 0xcf, 0xcf, //0x000005e9 leal $-808464432(%rcx), %esi
0x81, 0xe2, 0x80, 0x80, 0x80, 0x80, //0x000005ef andl $-2139062144, %edx
0x85, 0xf2, //0x000005f5 testl %esi, %edx
0x0f, 0x85, 0xf7, 0x02, 0x00, 0x00, //0x000005f7 jne LBB0_126
0x8d, 0xb1, 0x19, 0x19, 0x19, 0x19, //0x000005fd leal $421075225(%rcx), %esi
0x09, 0xce, //0x00000603 orl %ecx, %esi
0xf7, 0xc6, 0x80, 0x80, 0x80, 0x80, //0x00000605 testl $-2139062144, %esi
0x0f, 0x85, 0xe3, 0x02, 0x00, 0x00, //0x0000060b jne LBB0_126
0x41, 0x89, 0xda, //0x00000611 movl %ebx, %r10d
0x89, 0xce, //0x00000614 movl %ecx, %esi
0x81, 0xe6, 0x7f, 0x7f, 0x7f, 0x7f, //0x00000616 andl $2139062143, %esi
0xbb, 0xc0, 0xc0, 0xc0, 0xc0, //0x0000061c movl $-1061109568, %ebx
0x29, 0xf3, //0x00000621 subl %esi, %ebx
0x44, 0x8d, 0x86, 0x46, 0x46, 0x46, 0x46, //0x00000623 leal $1179010630(%rsi), %r8d
0x21, 0xd3, //0x0000062a andl %edx, %ebx
0x44, 0x85, 0xc3, //0x0000062c testl %r8d, %ebx
0x0f, 0x85, 0xa8, 0x02, 0x00, 0x00, //0x0000062f jne LBB0_123
0xbb, 0xe0, 0xe0, 0xe0, 0xe0, //0x00000635 movl $-522133280, %ebx
0x29, 0xf3, //0x0000063a subl %esi, %ebx
0x81, 0xc6, 0x39, 0x39, 0x39, 0x39, //0x0000063c addl $960051513, %esi
0x21, 0xda, //0x00000642 andl %ebx, %edx
0x85, 0xf2, //0x00000644 testl %esi, %edx
0x0f, 0x85, 0x91, 0x02, 0x00, 0x00, //0x00000646 jne LBB0_123
0x0f, 0xc9, //0x0000064c bswapl %ecx
0x89, 0xc8, //0x0000064e movl %ecx, %eax
0xc1, 0xe8, 0x04, //0x00000650 shrl $4, %eax
0xf7, 0xd0, //0x00000653 notl %eax
0x25, 0x01, 0x01, 0x01, 0x01, //0x00000655 andl $16843009, %eax
0x8d, 0x04, 0xc0, //0x0000065a leal (%rax,%rax,8), %eax
0x81, 0xe1, 0x0f, 0x0f, 0x0f, 0x0f, //0x0000065d andl $252645135, %ecx
0x01, 0xc1, //0x00000663 addl %eax, %ecx
0x89, 0xc8, //0x00000665 movl %ecx, %eax
0xc1, 0xe8, 0x04, //0x00000667 shrl $4, %eax
0x09, 0xc8, //0x0000066a orl %ecx, %eax
0x89, 0xc1, //0x0000066c movl %eax, %ecx
0xc1, 0xe9, 0x08, //0x0000066e shrl $8, %ecx
0x81, 0xe1, 0x00, 0xff, 0x00, 0x00, //0x00000671 andl $65280, %ecx
0x89, 0xc2, //0x00000677 movl %eax, %edx
0x81, 0xe2, 0x80, 0x00, 0x00, 0x00, //0x00000679 andl $128, %edx
0x49, 0x83, 0xc5, 0x06, //0x0000067f addq $6, %r13
0x09, 0xca, //0x00000683 orl %ecx, %edx
0x44, 0x89, 0xd3, //0x00000685 movl %r10d, %ebx
0x0f, 0x85, 0x69, 0x02, 0x00, 0x00, //0x00000688 jne LBB0_127
0x3c, 0x0d, //0x0000068e cmpb $13, %al
0x0f, 0x85, 0x15, 0x00, 0x00, 0x00, //0x00000690 jne LBB0_90
0xe9, 0xf0, 0xfe, 0xff, 0xff, //0x00000696 jmp LBB0_76
0x90, 0x90, 0x90, 0x90, 0x90, //0x0000069b .p2align 4, 0x90
//0x000006a0 LBB0_89
0x49, 0x89, 0xcd, //0x000006a0 movq %rcx, %r13
0x3c, 0x0d, //0x000006a3 cmpb $13, %al
0x0f, 0x84, 0xe0, 0xfe, 0xff, 0xff, //0x000006a5 je LBB0_76
//0x000006ab LBB0_90
0x89, 0xc7, //0x000006ab movl %eax, %edi
0x3c, 0x0a, //0x000006ad cmpb $10, %al
0x0f, 0x84, 0xd6, 0xfe, 0xff, 0xff, //0x000006af je LBB0_76
0xe9, 0x3d, 0x02, 0x00, 0x00, //0x000006b5 jmp LBB0_127
//0x000006ba LBB0_94
0xbe, 0x01, 0x00, 0x00, 0x00, //0x000006ba movl $1, %esi
0xe9, 0xea, 0xfc, 0xff, 0xff, //0x000006bf jmp LBB0_38
//0x000006c4 LBB0_95
0x4d, 0x39, 0xcd, //0x000006c4 cmpq %r9, %r13
0x0f, 0x83, 0xc1, 0xfd, 0xff, 0xff, //0x000006c7 jae LBB0_54
0x4c, 0x89, 0xef, //0x000006cd movq %r13, %rdi
0x41, 0x89, 0xda, //0x000006d0 movl %ebx, %r10d
0xe9, 0x1d, 0x00, 0x00, 0x00, //0x000006d3 jmp LBB0_99
//0x000006d8 LBB0_113
0x48, 0x89, 0xd7, //0x000006d8 movq %rdx, %rdi
0x4c, 0x39, 0xcf, //0x000006db cmpq %r9, %rdi
0x0f, 0x82, 0x11, 0x00, 0x00, 0x00, //0x000006de jb LBB0_99
0xe9, 0x93, 0x03, 0x00, 0x00, //0x000006e4 jmp LBB0_150
//0x000006e9 LBB0_97
0x4c, 0x89, 0xef, //0x000006e9 movq %r13, %rdi
0x4c, 0x39, 0xcf, //0x000006ec cmpq %r9, %rdi
0x0f, 0x83, 0x87, 0x03, 0x00, 0x00, //0x000006ef jae LBB0_150
//0x000006f5 LBB0_99
0x48, 0x8d, 0x57, 0x01, //0x000006f5 leaq $1(%rdi), %rdx
0x0f, 0xb6, 0x0f, //0x000006f9 movzbl (%rdi), %ecx
0x80, 0xf9, 0x5c, //0x000006fc cmpb $92, %cl
0x0f, 0x85, 0xe7, 0x00, 0x00, 0x00, //0x000006ff jne LBB0_110
0x4c, 0x8d, 0x6f, 0x02, //0x00000705 leaq $2(%rdi), %r13
0x4d, 0x39, 0xcd, //0x00000709 cmpq %r9, %r13
0x0f, 0x87, 0x39, 0x01, 0x00, 0x00, //0x0000070c ja LBB0_154
0x0f, 0xb6, 0x02, //0x00000712 movzbl (%rdx), %eax
0x3c, 0x6e, //0x00000715 cmpb $110, %al
0x0f, 0x84, 0xcc, 0xff, 0xff, 0xff, //0x00000717 je LBB0_97
0x3c, 0x72, //0x0000071d cmpb $114, %al
0x0f, 0x84, 0xc4, 0xff, 0xff, 0xff, //0x0000071f je LBB0_97
0x3c, 0x75, //0x00000725 cmpb $117, %al
0x0f, 0x85, 0x21, 0x01, 0x00, 0x00, //0x00000727 jne LBB0_155
0x4c, 0x89, 0xc8, //0x0000072d movq %r9, %rax
0x4c, 0x29, 0xe8, //0x00000730 subq %r13, %rax
0x48, 0x83, 0xf8, 0x04, //0x00000733 cmpq $4, %rax
0x0f, 0x8c, 0x11, 0x01, 0x00, 0x00, //0x00000737 jl LBB0_155
0x41, 0x8b, 0x45, 0x00, //0x0000073d movl (%r13), %eax
0x89, 0xc1, //0x00000741 movl %eax, %ecx
0xf7, 0xd1, //0x00000743 notl %ecx
0x8d, 0x90, 0xd0, 0xcf, 0xcf, 0xcf, //0x00000745 leal $-808464432(%rax), %edx
0x81, 0xe1, 0x80, 0x80, 0x80, 0x80, //0x0000074b andl $-2139062144, %ecx
0x85, 0xd1, //0x00000751 testl %edx, %ecx
0x0f, 0x85, 0xf5, 0x00, 0x00, 0x00, //0x00000753 jne LBB0_155
0x8d, 0x90, 0x19, 0x19, 0x19, 0x19, //0x00000759 leal $421075225(%rax), %edx
0x09, 0xc2, //0x0000075f orl %eax, %edx
0xf7, 0xc2, 0x80, 0x80, 0x80, 0x80, //0x00000761 testl $-2139062144, %edx
0x0f, 0x85, 0xe1, 0x00, 0x00, 0x00, //0x00000767 jne LBB0_155
0x89, 0xc2, //0x0000076d movl %eax, %edx
0x81, 0xe2, 0x7f, 0x7f, 0x7f, 0x7f, //0x0000076f andl $2139062143, %edx
0xbb, 0xc0, 0xc0, 0xc0, 0xc0, //0x00000775 movl $-1061109568, %ebx
0x29, 0xd3, //0x0000077a subl %edx, %ebx
0x44, 0x8d, 0x82, 0x46, 0x46, 0x46, 0x46, //0x0000077c leal $1179010630(%rdx), %r8d
0x21, 0xcb, //0x00000783 andl %ecx, %ebx
0x44, 0x85, 0xc3, //0x00000785 testl %r8d, %ebx
0x0f, 0x85, 0xc0, 0x00, 0x00, 0x00, //0x00000788 jne LBB0_155
0xbb, 0xe0, 0xe0, 0xe0, 0xe0, //0x0000078e movl $-522133280, %ebx
0x29, 0xd3, //0x00000793 subl %edx, %ebx
0x81, 0xc2, 0x39, 0x39, 0x39, 0x39, //0x00000795 addl $960051513, %edx
0x21, 0xd9, //0x0000079b andl %ebx, %ecx
0x85, 0xd1, //0x0000079d testl %edx, %ecx
0x0f, 0x85, 0xa9, 0x00, 0x00, 0x00, //0x0000079f jne LBB0_155
0x44, 0x89, 0xd3, //0x000007a5 movl %r10d, %ebx
0x0f, 0xc8, //0x000007a8 bswapl %eax
0x89, 0xc1, //0x000007aa movl %eax, %ecx
0xc1, 0xe9, 0x04, //0x000007ac shrl $4, %ecx
0xf7, 0xd1, //0x000007af notl %ecx
0x81, 0xe1, 0x01, 0x01, 0x01, 0x01, //0x000007b1 andl $16843009, %ecx
0x8d, 0x0c, 0xc9, //0x000007b7 leal (%rcx,%rcx,8), %ecx
0x25, 0x0f, 0x0f, 0x0f, 0x0f, //0x000007ba andl $252645135, %eax
0x01, 0xc8, //0x000007bf addl %ecx, %eax
0x89, 0xc1, //0x000007c1 movl %eax, %ecx
0xc1, 0xe9, 0x04, //0x000007c3 shrl $4, %ecx
0x09, 0xc1, //0x000007c6 orl %eax, %ecx
0x89, 0xc8, //0x000007c8 movl %ecx, %eax
0xc1, 0xe8, 0x08, //0x000007ca shrl $8, %eax
0x25, 0x00, 0xff, 0x00, 0x00, //0x000007cd andl $65280, %eax
0x89, 0xca, //0x000007d2 movl %ecx, %edx
0x81, 0xe2, 0x80, 0x00, 0x00, 0x00, //0x000007d4 andl $128, %edx
0x48, 0x83, 0xc7, 0x06, //0x000007da addq $6, %rdi
0x09, 0xc2, //0x000007de orl %eax, %edx
0x48, 0x89, 0xfa, //0x000007e0 movq %rdi, %rdx
0x49, 0x89, 0xfd, //0x000007e3 movq %rdi, %r13
0x0f, 0x85, 0x62, 0x00, 0x00, 0x00, //0x000007e6 jne LBB0_155
//0x000007ec LBB0_110
0x80, 0xf9, 0x0a, //0x000007ec cmpb $10, %cl
0x0f, 0x84, 0xe3, 0xfe, 0xff, 0xff, //0x000007ef je LBB0_113
0x80, 0xf9, 0x0d, //0x000007f5 cmpb $13, %cl
| go | Apache-2.0 | b3b4703e958c25d54c4d48138d9e80ae32fadac3 | 2026-01-07T09:44:30.792320Z | true |
kubev2v/forklift | https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/github.com/cloudwego/base64x/internal/native/sse/b64encode_text_amd64.go | vendor/github.com/cloudwego/base64x/internal/native/sse/b64encode_text_amd64.go | // +build amd64
// Code generated by asm2asm, DO NOT EDIT.
package sse
var _text_b64encode = []byte{
// .p2align 4, 0x90
// _b64encode
0x55, // pushq %rbp
0x48, 0x89, 0xe5, //0x00000001 movq %rsp, %rbp
0x41, 0x57, //0x00000004 pushq %r15
0x41, 0x56, //0x00000006 pushq %r14
0x53, //0x00000008 pushq %rbx
0x4c, 0x8b, 0x4e, 0x08, //0x00000009 movq $8(%rsi), %r9
0x4d, 0x85, 0xc9, //0x0000000d testq %r9, %r9
0x0f, 0x84, 0x94, 0x01, 0x00, 0x00, //0x00000010 je LBB0_15
0x4c, 0x8b, 0x3e, //0x00000016 movq (%rsi), %r15
0x4c, 0x8b, 0x07, //0x00000019 movq (%rdi), %r8
0x4c, 0x03, 0x47, 0x08, //0x0000001c addq $8(%rdi), %r8
0x4d, 0x01, 0xf9, //0x00000020 addq %r15, %r9
0xf6, 0xc2, 0x01, //0x00000023 testb $1, %dl
0x48, 0x8d, 0x0d, 0x93, 0x01, 0x00, 0x00, //0x00000026 leaq $403(%rip), %rcx /* _TabEncodeCharsetStd+0(%rip) */
0x4c, 0x8d, 0x1d, 0xcc, 0x01, 0x00, 0x00, //0x0000002d leaq $460(%rip), %r11 /* _TabEncodeCharsetURL+0(%rip) */
0x4c, 0x0f, 0x44, 0xd9, //0x00000034 cmoveq %rcx, %r11
0x4d, 0x8d, 0x51, 0xfc, //0x00000038 leaq $-4(%r9), %r10
0x4d, 0x89, 0xc6, //0x0000003c movq %r8, %r14
0x4d, 0x39, 0xfa, //0x0000003f cmpq %r15, %r10
0x0f, 0x82, 0x5e, 0x00, 0x00, 0x00, //0x00000042 jb LBB0_3
0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, //0x00000048 .p2align 4, 0x90
//0x00000050 LBB0_2
0x41, 0x8b, 0x37, //0x00000050 movl (%r15), %esi
0x0f, 0xce, //0x00000053 bswapl %esi
0x48, 0x89, 0xf3, //0x00000055 movq %rsi, %rbx
0x48, 0xc1, 0xeb, 0x1a, //0x00000058 shrq $26, %rbx
0x89, 0xf1, //0x0000005c movl %esi, %ecx
0xc1, 0xe9, 0x14, //0x0000005e shrl $20, %ecx
0x83, 0xe1, 0x3f, //0x00000061 andl $63, %ecx
0x89, 0xf0, //0x00000064 movl %esi, %eax
0xc1, 0xe8, 0x0e, //0x00000066 shrl $14, %eax
0x83, 0xe0, 0x3f, //0x00000069 andl $63, %eax
0xc1, 0xee, 0x08, //0x0000006c shrl $8, %esi
0x83, 0xe6, 0x3f, //0x0000006f andl $63, %esi
0x49, 0x83, 0xc7, 0x03, //0x00000072 addq $3, %r15
0x41, 0x0f, 0xb6, 0x1c, 0x1b, //0x00000076 movzbl (%r11,%rbx), %ebx
0x41, 0x88, 0x1e, //0x0000007b movb %bl, (%r14)
0x41, 0x0f, 0xb6, 0x0c, 0x0b, //0x0000007e movzbl (%r11,%rcx), %ecx
0x41, 0x88, 0x4e, 0x01, //0x00000083 movb %cl, $1(%r14)
0x41, 0x0f, 0xb6, 0x04, 0x03, //0x00000087 movzbl (%r11,%rax), %eax
0x41, 0x88, 0x46, 0x02, //0x0000008c movb %al, $2(%r14)
0x41, 0x0f, 0xb6, 0x04, 0x33, //0x00000090 movzbl (%r11,%rsi), %eax
0x41, 0x88, 0x46, 0x03, //0x00000095 movb %al, $3(%r14)
0x49, 0x83, 0xc6, 0x04, //0x00000099 addq $4, %r14
0x4d, 0x39, 0xd7, //0x0000009d cmpq %r10, %r15
0x0f, 0x86, 0xaa, 0xff, 0xff, 0xff, //0x000000a0 jbe LBB0_2
//0x000000a6 LBB0_3
0x4d, 0x29, 0xf9, //0x000000a6 subq %r15, %r9
0x45, 0x0f, 0xb6, 0x17, //0x000000a9 movzbl (%r15), %r10d
0x49, 0x83, 0xf9, 0x01, //0x000000ad cmpq $1, %r9
0x0f, 0x84, 0xa8, 0x00, 0x00, 0x00, //0x000000b1 je LBB0_10
0x4c, 0x89, 0xd6, //0x000000b7 movq %r10, %rsi
0x48, 0xc1, 0xe6, 0x10, //0x000000ba shlq $16, %rsi
0x49, 0x83, 0xf9, 0x02, //0x000000be cmpq $2, %r9
0x0f, 0x84, 0x54, 0x00, 0x00, 0x00, //0x000000c2 je LBB0_7
0x49, 0x83, 0xf9, 0x03, //0x000000c8 cmpq $3, %r9
0x0f, 0x85, 0xd1, 0x00, 0x00, 0x00, //0x000000cc jne LBB0_14
0x41, 0x0f, 0xb6, 0x57, 0x02, //0x000000d2 movzbl $2(%r15), %edx
0x09, 0xd6, //0x000000d7 orl %edx, %esi
0x41, 0x0f, 0xb6, 0x47, 0x01, //0x000000d9 movzbl $1(%r15), %eax
0xc1, 0xe0, 0x08, //0x000000de shll $8, %eax
0x09, 0xf0, //0x000000e1 orl %esi, %eax
0x49, 0xc1, 0xea, 0x02, //0x000000e3 shrq $2, %r10
0x43, 0x8a, 0x0c, 0x13, //0x000000e7 movb (%r11,%r10), %cl
0x41, 0x88, 0x0e, //0x000000eb movb %cl, (%r14)
0x89, 0xc1, //0x000000ee movl %eax, %ecx
0xc1, 0xe9, 0x0c, //0x000000f0 shrl $12, %ecx
0x83, 0xe1, 0x3f, //0x000000f3 andl $63, %ecx
0x41, 0x8a, 0x0c, 0x0b, //0x000000f6 movb (%r11,%rcx), %cl
0x41, 0x88, 0x4e, 0x01, //0x000000fa movb %cl, $1(%r14)
0xc1, 0xe8, 0x06, //0x000000fe shrl $6, %eax
0x83, 0xe0, 0x3f, //0x00000101 andl $63, %eax
0x41, 0x8a, 0x04, 0x03, //0x00000104 movb (%r11,%rax), %al
0x41, 0x88, 0x46, 0x02, //0x00000108 movb %al, $2(%r14)
0x83, 0xe2, 0x3f, //0x0000010c andl $63, %edx
0x41, 0x8a, 0x04, 0x13, //0x0000010f movb (%r11,%rdx), %al
0x41, 0x88, 0x46, 0x03, //0x00000113 movb %al, $3(%r14)
0xe9, 0x71, 0x00, 0x00, 0x00, //0x00000117 jmp LBB0_13
//0x0000011c LBB0_7
0x41, 0x0f, 0xb6, 0x47, 0x01, //0x0000011c movzbl $1(%r15), %eax
0x89, 0xc1, //0x00000121 movl %eax, %ecx
0xc1, 0xe1, 0x08, //0x00000123 shll $8, %ecx
0x09, 0xf1, //0x00000126 orl %esi, %ecx
0x49, 0xc1, 0xea, 0x02, //0x00000128 shrq $2, %r10
0x43, 0x8a, 0x1c, 0x13, //0x0000012c movb (%r11,%r10), %bl
0x41, 0x88, 0x1e, //0x00000130 movb %bl, (%r14)
0xc1, 0xe9, 0x0c, //0x00000133 shrl $12, %ecx
0x83, 0xe1, 0x3f, //0x00000136 andl $63, %ecx
0x41, 0x8a, 0x0c, 0x0b, //0x00000139 movb (%r11,%rcx), %cl
0x41, 0x88, 0x4e, 0x01, //0x0000013d movb %cl, $1(%r14)
0x83, 0xe0, 0x0f, //0x00000141 andl $15, %eax
0x41, 0x8a, 0x04, 0x83, //0x00000144 movb (%r11,%rax,4), %al
0x41, 0x88, 0x46, 0x02, //0x00000148 movb %al, $2(%r14)
0xf6, 0xc2, 0x02, //0x0000014c testb $2, %dl
0x0f, 0x85, 0x41, 0x00, 0x00, 0x00, //0x0000014f jne LBB0_8
0x41, 0xc6, 0x46, 0x03, 0x3d, //0x00000155 movb $61, $3(%r14)
0xe9, 0x2e, 0x00, 0x00, 0x00, //0x0000015a jmp LBB0_13
//0x0000015f LBB0_10
0x4c, 0x89, 0xd0, //0x0000015f movq %r10, %rax
0x48, 0xc1, 0xe8, 0x02, //0x00000162 shrq $2, %rax
0x41, 0x8a, 0x04, 0x03, //0x00000166 movb (%r11,%rax), %al
0x41, 0x88, 0x06, //0x0000016a movb %al, (%r14)
0x41, 0xc1, 0xe2, 0x04, //0x0000016d shll $4, %r10d
0x41, 0x83, 0xe2, 0x30, //0x00000171 andl $48, %r10d
0x43, 0x8a, 0x04, 0x13, //0x00000175 movb (%r11,%r10), %al
0x41, 0x88, 0x46, 0x01, //0x00000179 movb %al, $1(%r14)
0xf6, 0xc2, 0x02, //0x0000017d testb $2, %dl
0x0f, 0x85, 0x19, 0x00, 0x00, 0x00, //0x00000180 jne LBB0_11
0x66, 0x41, 0xc7, 0x46, 0x02, 0x3d, 0x3d, //0x00000186 movw $15677, $2(%r14)
//0x0000018d LBB0_13
0x49, 0x83, 0xc6, 0x04, //0x0000018d addq $4, %r14
0xe9, 0x0d, 0x00, 0x00, 0x00, //0x00000191 jmp LBB0_14
//0x00000196 LBB0_8
0x49, 0x83, 0xc6, 0x03, //0x00000196 addq $3, %r14
0xe9, 0x04, 0x00, 0x00, 0x00, //0x0000019a jmp LBB0_14
//0x0000019f LBB0_11
0x49, 0x83, 0xc6, 0x02, //0x0000019f addq $2, %r14
//0x000001a3 LBB0_14
0x4d, 0x29, 0xc6, //0x000001a3 subq %r8, %r14
0x4c, 0x01, 0x77, 0x08, //0x000001a6 addq %r14, $8(%rdi)
//0x000001aa LBB0_15
0x5b, //0x000001aa popq %rbx
0x41, 0x5e, //0x000001ab popq %r14
0x41, 0x5f, //0x000001ad popq %r15
0x5d, //0x000001af popq %rbp
0xc3, //0x000001b0 retq
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //0x000001b1 .p2align 4, 0x00
//0x000001c0 _TabEncodeCharsetStd
0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50, //0x000001c0 QUAD $0x4847464544434241; QUAD $0x504f4e4d4c4b4a49 // .ascii 16, 'ABCDEFGHIJKLMNOP'
0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, //0x000001d0 QUAD $0x5857565554535251; QUAD $0x6665646362615a59 // .ascii 16, 'QRSTUVWXYZabcdef'
0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, //0x000001e0 QUAD $0x6e6d6c6b6a696867; QUAD $0x767574737271706f // .ascii 16, 'ghijklmnopqrstuv'
0x77, 0x78, 0x79, 0x7a, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x2b, 0x2f, //0x000001f0 QUAD $0x333231307a797877; QUAD $0x2f2b393837363534 // .ascii 16, 'wxyz0123456789+/'
//0x00000200 .p2align 4, 0x00
//0x00000200 _TabEncodeCharsetURL
0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50, //0x00000200 QUAD $0x4847464544434241; QUAD $0x504f4e4d4c4b4a49 // .ascii 16, 'ABCDEFGHIJKLMNOP'
0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, //0x00000210 QUAD $0x5857565554535251; QUAD $0x6665646362615a59 // .ascii 16, 'QRSTUVWXYZabcdef'
0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, //0x00000220 QUAD $0x6e6d6c6b6a696867; QUAD $0x767574737271706f // .ascii 16, 'ghijklmnopqrstuv'
0x77, 0x78, 0x79, 0x7a, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x2d, 0x5f, //0x00000230 QUAD $0x333231307a797877; QUAD $0x5f2d393837363534 // .ascii 16, 'wxyz0123456789-_'
}
| go | Apache-2.0 | b3b4703e958c25d54c4d48138d9e80ae32fadac3 | 2026-01-07T09:44:30.792320Z | false |
kubev2v/forklift | https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/github.com/cloudwego/base64x/internal/native/sse/b64decode_subr.go | vendor/github.com/cloudwego/base64x/internal/native/sse/b64decode_subr.go | // +build !noasm !appengine
// Code generated by asm2asm, DO NOT EDIT.
package sse
import (
`github.com/bytedance/sonic/loader`
)
const (
_entry__b64decode = 0
)
const (
_stack__b64decode = 144
)
const (
_size__b64decode = 9968
)
var (
_pcsp__b64decode = [][2]uint32{
{0x1, 0},
{0x6, 8},
{0x8, 16},
{0xa, 24},
{0xc, 32},
{0xd, 40},
{0x11, 48},
{0x26e1, 144},
{0x26e2, 48},
{0x26e4, 40},
{0x26e6, 32},
{0x26e8, 24},
{0x26ea, 16},
{0x26eb, 8},
{0x26f0, 0},
}
)
var _cfunc_b64decode = []loader.CFunc{
{"_b64decode_entry", 0, _entry__b64decode, 0, nil},
{"_b64decode", _entry__b64decode, _size__b64decode, _stack__b64decode, _pcsp__b64decode},
}
| go | Apache-2.0 | b3b4703e958c25d54c4d48138d9e80ae32fadac3 | 2026-01-07T09:44:30.792320Z | false |
kubev2v/forklift | https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/github.com/cloudwego/base64x/internal/native/sse/b64encode_subr.go | vendor/github.com/cloudwego/base64x/internal/native/sse/b64encode_subr.go | // +build !noasm !appengine
// Code generated by asm2asm, DO NOT EDIT.
package sse
import (
`github.com/bytedance/sonic/loader`
)
const (
_entry__b64encode = 0
)
const (
_stack__b64encode = 32
)
const (
_size__b64encode = 448
)
var (
_pcsp__b64encode = [][2]uint32{
{0x1, 0},
{0x6, 8},
{0x8, 16},
{0x9, 24},
{0x1ab, 32},
{0x1ad, 24},
{0x1af, 16},
{0x1b0, 8},
{0x1c0, 0},
}
)
var _cfunc_b64encode = []loader.CFunc{
{"_b64encode_entry", 0, _entry__b64encode, 0, nil},
{"_b64encode", _entry__b64encode, _size__b64encode, _stack__b64encode, _pcsp__b64encode},
}
| go | Apache-2.0 | b3b4703e958c25d54c4d48138d9e80ae32fadac3 | 2026-01-07T09:44:30.792320Z | false |
kubev2v/forklift | https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/github.com/cloudwego/base64x/internal/native/avx2/b64decode.go | vendor/github.com/cloudwego/base64x/internal/native/avx2/b64decode.go | // Code generated by Bash, DO NOT EDIT.
/*
* Copyright 2025 ByteDance Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package avx2
import (
`unsafe`
`github.com/cloudwego/base64x/internal/rt`
)
var F_b64decode func(out unsafe.Pointer, src unsafe.Pointer, len int, mod int) (ret int)
var S_b64decode uintptr
//go:nosplit
func B64decode(out *[]byte, src unsafe.Pointer, len int, mode int) (ret int) {
return F_b64decode(rt.NoEscape(unsafe.Pointer(out)), rt.NoEscape(unsafe.Pointer(src)), len, mode)
}
| go | Apache-2.0 | b3b4703e958c25d54c4d48138d9e80ae32fadac3 | 2026-01-07T09:44:30.792320Z | false |
kubev2v/forklift | https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/github.com/cloudwego/base64x/internal/native/avx2/native_export.go | vendor/github.com/cloudwego/base64x/internal/native/avx2/native_export.go |
// Code generated by Bash, DO NOT EDIT.
/*
* Copyright 2025 ByteDance Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package avx2
import (
`github.com/bytedance/sonic/loader`
)
func Use() {
loader.WrapGoC(_text_b64encode, _cfunc_b64encode, []loader.GoC{{"_b64encode", &S_b64encode, &F_b64encode}}, "avx2", "avx2/b64encode.c")
loader.WrapGoC(_text_b64decode, _cfunc_b64decode, []loader.GoC{{"_b64decode", &S_b64decode, &F_b64decode}}, "avx2", "avx2/b64decode.c")
} | go | Apache-2.0 | b3b4703e958c25d54c4d48138d9e80ae32fadac3 | 2026-01-07T09:44:30.792320Z | false |
kubev2v/forklift | https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/github.com/cloudwego/base64x/internal/native/avx2/b64encode.go | vendor/github.com/cloudwego/base64x/internal/native/avx2/b64encode.go | // Code generated by Bash, DO NOT EDIT.
/*
* Copyright 2025 ByteDance Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package avx2
import (
`unsafe`
`github.com/cloudwego/base64x/internal/rt`
)
var F_b64encode func(out unsafe.Pointer, src unsafe.Pointer, mod int)
var S_b64encode uintptr
//go:nosplit
func B64encode(out *[]byte, src *[]byte, mode int) {
F_b64encode(rt.NoEscape(unsafe.Pointer(out)), rt.NoEscape(unsafe.Pointer(src)), mode)
}
| go | Apache-2.0 | b3b4703e958c25d54c4d48138d9e80ae32fadac3 | 2026-01-07T09:44:30.792320Z | false |
kubev2v/forklift | https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/github.com/cloudwego/base64x/internal/native/avx2/b64decode_text_amd64.go | vendor/github.com/cloudwego/base64x/internal/native/avx2/b64decode_text_amd64.go | // +build amd64
// Code generated by asm2asm, DO NOT EDIT.
package avx2
var _text_b64decode = []byte{
// .p2align 5, 0x00
// LCPI0_0
0xa8, // .byte 168
0xf8, //0x00000001 .byte 248
0xf8, //0x00000002 .byte 248
0xf8, //0x00000003 .byte 248
0xf8, //0x00000004 .byte 248
0xf8, //0x00000005 .byte 248
0xf8, //0x00000006 .byte 248
0xf8, //0x00000007 .byte 248
0xf8, //0x00000008 .byte 248
0xf8, //0x00000009 .byte 248
0xf0, //0x0000000a .byte 240
0x54, //0x0000000b .byte 84
0x50, //0x0000000c .byte 80
0x50, //0x0000000d .byte 80
0x50, //0x0000000e .byte 80
0x54, //0x0000000f .byte 84
0xa8, //0x00000010 .byte 168
0xf8, //0x00000011 .byte 248
0xf8, //0x00000012 .byte 248
0xf8, //0x00000013 .byte 248
0xf8, //0x00000014 .byte 248
0xf8, //0x00000015 .byte 248
0xf8, //0x00000016 .byte 248
0xf8, //0x00000017 .byte 248
0xf8, //0x00000018 .byte 248
0xf8, //0x00000019 .byte 248
0xf0, //0x0000001a .byte 240
0x54, //0x0000001b .byte 84
0x50, //0x0000001c .byte 80
0x50, //0x0000001d .byte 80
0x50, //0x0000001e .byte 80
0x54, //0x0000001f .byte 84
//0x00000020 LCPI0_1
0xa8, //0x00000020 .byte 168
0xf8, //0x00000021 .byte 248
0xf8, //0x00000022 .byte 248
0xf8, //0x00000023 .byte 248
0xf8, //0x00000024 .byte 248
0xf8, //0x00000025 .byte 248
0xf8, //0x00000026 .byte 248
0xf8, //0x00000027 .byte 248
0xf8, //0x00000028 .byte 248
0xf8, //0x00000029 .byte 248
0xf0, //0x0000002a .byte 240
0x50, //0x0000002b .byte 80
0x50, //0x0000002c .byte 80
0x54, //0x0000002d .byte 84
0x50, //0x0000002e .byte 80
0x70, //0x0000002f .byte 112
0xa8, //0x00000030 .byte 168
0xf8, //0x00000031 .byte 248
0xf8, //0x00000032 .byte 248
0xf8, //0x00000033 .byte 248
0xf8, //0x00000034 .byte 248
0xf8, //0x00000035 .byte 248
0xf8, //0x00000036 .byte 248
0xf8, //0x00000037 .byte 248
0xf8, //0x00000038 .byte 248
0xf8, //0x00000039 .byte 248
0xf0, //0x0000003a .byte 240
0x50, //0x0000003b .byte 80
0x50, //0x0000003c .byte 80
0x54, //0x0000003d .byte 84
0x50, //0x0000003e .byte 80
0x70, //0x0000003f .byte 112
//0x00000040 LCPI0_2
0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, //0x00000040 QUAD $0x2f2f2f2f2f2f2f2f; QUAD $0x2f2f2f2f2f2f2f2f // .space 16, '////////////////'
0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, //0x00000050 QUAD $0x2f2f2f2f2f2f2f2f; QUAD $0x2f2f2f2f2f2f2f2f // .space 16, '////////////////'
//0x00000060 LCPI0_3
0x5f, 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, //0x00000060 QUAD $0x5f5f5f5f5f5f5f5f; QUAD $0x5f5f5f5f5f5f5f5f // .space 16, '________________'
0x5f, 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, //0x00000070 QUAD $0x5f5f5f5f5f5f5f5f; QUAD $0x5f5f5f5f5f5f5f5f // .space 16, '________________'
//0x00000080 LCPI0_4
0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, //0x00000080 QUAD $0x1010101010101010; QUAD $0x1010101010101010 // .space 16, '\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10'
0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, //0x00000090 QUAD $0x1010101010101010; QUAD $0x1010101010101010 // .space 16, '\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10'
//0x000000a0 LCPI0_5
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, //0x000000a0 QUAD $0x2020202020202020; QUAD $0x2020202020202020 // .space 16, ' '
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, //0x000000b0 QUAD $0x2020202020202020; QUAD $0x2020202020202020 // .space 16, ' '
//0x000000c0 LCPI0_6
0x00, //0x000000c0 .byte 0
0x00, //0x000000c1 .byte 0
0x13, //0x000000c2 .byte 19
0x04, //0x000000c3 .byte 4
0xbf, //0x000000c4 .byte 191
0xbf, //0x000000c5 .byte 191
0xb9, //0x000000c6 .byte 185
0xb9, //0x000000c7 .byte 185
0x00, //0x000000c8 .byte 0
0x00, //0x000000c9 .byte 0
0x00, //0x000000ca .byte 0
0x00, //0x000000cb .byte 0
0x00, //0x000000cc .byte 0
0x00, //0x000000cd .byte 0
0x00, //0x000000ce .byte 0
0x00, //0x000000cf .byte 0
0x00, //0x000000d0 .byte 0
0x00, //0x000000d1 .byte 0
0x13, //0x000000d2 .byte 19
0x04, //0x000000d3 .byte 4
0xbf, //0x000000d4 .byte 191
0xbf, //0x000000d5 .byte 191
0xb9, //0x000000d6 .byte 185
0xb9, //0x000000d7 .byte 185
0x00, //0x000000d8 .byte 0
0x00, //0x000000d9 .byte 0
0x00, //0x000000da .byte 0
0x00, //0x000000db .byte 0
0x00, //0x000000dc .byte 0
0x00, //0x000000dd .byte 0
0x00, //0x000000de .byte 0
0x00, //0x000000df .byte 0
//0x000000e0 LCPI0_7
0x00, //0x000000e0 .byte 0
0x00, //0x000000e1 .byte 0
0x11, //0x000000e2 .byte 17
0x04, //0x000000e3 .byte 4
0xbf, //0x000000e4 .byte 191
0xbf, //0x000000e5 .byte 191
0xb9, //0x000000e6 .byte 185
0xb9, //0x000000e7 .byte 185
0x00, //0x000000e8 .byte 0
0x00, //0x000000e9 .byte 0
0x00, //0x000000ea .byte 0
0x00, //0x000000eb .byte 0
0x00, //0x000000ec .byte 0
0x00, //0x000000ed .byte 0
0x00, //0x000000ee .byte 0
0x00, //0x000000ef .byte 0
0x00, //0x000000f0 .byte 0
0x00, //0x000000f1 .byte 0
0x11, //0x000000f2 .byte 17
0x04, //0x000000f3 .byte 4
0xbf, //0x000000f4 .byte 191
0xbf, //0x000000f5 .byte 191
0xb9, //0x000000f6 .byte 185
0xb9, //0x000000f7 .byte 185
0x00, //0x000000f8 .byte 0
0x00, //0x000000f9 .byte 0
0x00, //0x000000fa .byte 0
0x00, //0x000000fb .byte 0
0x00, //0x000000fc .byte 0
0x00, //0x000000fd .byte 0
0x00, //0x000000fe .byte 0
0x00, //0x000000ff .byte 0
//0x00000100 LCPI0_8
0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, //0x00000100 QUAD $0x0f0f0f0f0f0f0f0f; QUAD $0x0f0f0f0f0f0f0f0f // .space 16, '\x0f\x0f\x0f\x0f\x0f\x0f\x0f\x0f\x0f\x0f\x0f\x0f\x0f\x0f\x0f\x0f'
0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, //0x00000110 QUAD $0x0f0f0f0f0f0f0f0f; QUAD $0x0f0f0f0f0f0f0f0f // .space 16, '\x0f\x0f\x0f\x0f\x0f\x0f\x0f\x0f\x0f\x0f\x0f\x0f\x0f\x0f\x0f\x0f'
//0x00000120 LCPI0_9
0x01, //0x00000120 .byte 1
0x02, //0x00000121 .byte 2
0x04, //0x00000122 .byte 4
0x08, //0x00000123 .byte 8
0x10, //0x00000124 .byte 16
0x20, //0x00000125 .byte 32
0x40, //0x00000126 .byte 64
0x80, //0x00000127 .byte 128
0x00, //0x00000128 .byte 0
0x00, //0x00000129 .byte 0
0x00, //0x0000012a .byte 0
0x00, //0x0000012b .byte 0
0x00, //0x0000012c .byte 0
0x00, //0x0000012d .byte 0
0x00, //0x0000012e .byte 0
0x00, //0x0000012f .byte 0
0x01, //0x00000130 .byte 1
0x02, //0x00000131 .byte 2
0x04, //0x00000132 .byte 4
0x08, //0x00000133 .byte 8
0x10, //0x00000134 .byte 16
0x20, //0x00000135 .byte 32
0x40, //0x00000136 .byte 64
0x80, //0x00000137 .byte 128
0x00, //0x00000138 .byte 0
0x00, //0x00000139 .byte 0
0x00, //0x0000013a .byte 0
0x00, //0x0000013b .byte 0
0x00, //0x0000013c .byte 0
0x00, //0x0000013d .byte 0
0x00, //0x0000013e .byte 0
0x00, //0x0000013f .byte 0
//0x00000140 LCPI0_10
0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, //0x00000140 QUAD $0x3f3f3f3f3f3f3f3f; QUAD $0x3f3f3f3f3f3f3f3f // .space 16, '????????????????'
0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, //0x00000150 QUAD $0x3f3f3f3f3f3f3f3f; QUAD $0x3f3f3f3f3f3f3f3f // .space 16, '????????????????'
//0x00000160 LCPI0_11
0x40, //0x00000160 .byte 64
0x01, //0x00000161 .byte 1
0x40, //0x00000162 .byte 64
0x01, //0x00000163 .byte 1
0x40, //0x00000164 .byte 64
0x01, //0x00000165 .byte 1
0x40, //0x00000166 .byte 64
0x01, //0x00000167 .byte 1
0x40, //0x00000168 .byte 64
0x01, //0x00000169 .byte 1
0x40, //0x0000016a .byte 64
0x01, //0x0000016b .byte 1
0x40, //0x0000016c .byte 64
0x01, //0x0000016d .byte 1
0x40, //0x0000016e .byte 64
0x01, //0x0000016f .byte 1
0x40, //0x00000170 .byte 64
0x01, //0x00000171 .byte 1
0x40, //0x00000172 .byte 64
0x01, //0x00000173 .byte 1
0x40, //0x00000174 .byte 64
0x01, //0x00000175 .byte 1
0x40, //0x00000176 .byte 64
0x01, //0x00000177 .byte 1
0x40, //0x00000178 .byte 64
0x01, //0x00000179 .byte 1
0x40, //0x0000017a .byte 64
0x01, //0x0000017b .byte 1
0x40, //0x0000017c .byte 64
0x01, //0x0000017d .byte 1
0x40, //0x0000017e .byte 64
0x01, //0x0000017f .byte 1
//0x00000180 LCPI0_12
0x00, 0x10, //0x00000180 .word 4096
0x01, 0x00, //0x00000182 .word 1
0x00, 0x10, //0x00000184 .word 4096
0x01, 0x00, //0x00000186 .word 1
0x00, 0x10, //0x00000188 .word 4096
0x01, 0x00, //0x0000018a .word 1
0x00, 0x10, //0x0000018c .word 4096
0x01, 0x00, //0x0000018e .word 1
0x00, 0x10, //0x00000190 .word 4096
0x01, 0x00, //0x00000192 .word 1
0x00, 0x10, //0x00000194 .word 4096
0x01, 0x00, //0x00000196 .word 1
0x00, 0x10, //0x00000198 .word 4096
0x01, 0x00, //0x0000019a .word 1
0x00, 0x10, //0x0000019c .word 4096
0x01, 0x00, //0x0000019e .word 1
//0x000001a0 LCPI0_14
0x02, //0x000001a0 .byte 2
0x01, //0x000001a1 .byte 1
0x00, //0x000001a2 .byte 0
0x06, //0x000001a3 .byte 6
0x05, //0x000001a4 .byte 5
0x04, //0x000001a5 .byte 4
0x0a, //0x000001a6 .byte 10
0x09, //0x000001a7 .byte 9
0x08, //0x000001a8 .byte 8
0x0e, //0x000001a9 .byte 14
0x0d, //0x000001aa .byte 13
0x0c, //0x000001ab .byte 12
0x00, //0x000001ac BYTE $0x00 // .space 1, '\x00'
0x00, //0x000001ad BYTE $0x00 // .space 1, '\x00'
0x00, //0x000001ae BYTE $0x00 // .space 1, '\x00'
0x00, //0x000001af BYTE $0x00 // .space 1, '\x00'
0x05, //0x000001b0 .byte 5
0x04, //0x000001b1 .byte 4
0x0a, //0x000001b2 .byte 10
0x09, //0x000001b3 .byte 9
0x08, //0x000001b4 .byte 8
0x0e, //0x000001b5 .byte 14
0x0d, //0x000001b6 .byte 13
0x0c, //0x000001b7 .byte 12
0x00, //0x000001b8 BYTE $0x00 // .space 1, '\x00'
0x00, //0x000001b9 BYTE $0x00 // .space 1, '\x00'
0x00, //0x000001ba BYTE $0x00 // .space 1, '\x00'
0x00, //0x000001bb BYTE $0x00 // .space 1, '\x00'
0x00, //0x000001bc BYTE $0x00 // .space 1, '\x00'
0x00, //0x000001bd BYTE $0x00 // .space 1, '\x00'
0x00, //0x000001be BYTE $0x00 // .space 1, '\x00'
0x00, //0x000001bf BYTE $0x00 // .space 1, '\x00'
//0x000001c0 .p2align 4, 0x00
//0x000001c0 LCPI0_13
0x00, //0x000001c0 BYTE $0x00 // .space 1, '\x00'
0x00, //0x000001c1 BYTE $0x00 // .space 1, '\x00'
0x00, //0x000001c2 BYTE $0x00 // .space 1, '\x00'
0x00, //0x000001c3 BYTE $0x00 // .space 1, '\x00'
0x00, //0x000001c4 BYTE $0x00 // .space 1, '\x00'
0x00, //0x000001c5 BYTE $0x00 // .space 1, '\x00'
0x00, //0x000001c6 BYTE $0x00 // .space 1, '\x00'
0x00, //0x000001c7 BYTE $0x00 // .space 1, '\x00'
0x00, //0x000001c8 BYTE $0x00 // .space 1, '\x00'
0x00, //0x000001c9 BYTE $0x00 // .space 1, '\x00'
0x00, //0x000001ca BYTE $0x00 // .space 1, '\x00'
0x00, //0x000001cb BYTE $0x00 // .space 1, '\x00'
0x02, //0x000001cc .byte 2
0x01, //0x000001cd .byte 1
0x00, //0x000001ce .byte 0
0x06, //0x000001cf .byte 6
//0x000001d0 .p2align 4, 0x90
//0x000001d0 _b64decode
0x55, //0x000001d0 pushq %rbp
0x48, 0x89, 0xe5, //0x000001d1 movq %rsp, %rbp
0x41, 0x57, //0x000001d4 pushq %r15
0x41, 0x56, //0x000001d6 pushq %r14
0x41, 0x55, //0x000001d8 pushq %r13
0x41, 0x54, //0x000001da pushq %r12
0x53, //0x000001dc pushq %rbx
0x48, 0x83, 0xec, 0x58, //0x000001dd subq $88, %rsp
0x48, 0x85, 0xd2, //0x000001e1 testq %rdx, %rdx
0x0f, 0x84, 0x85, 0x00, 0x00, 0x00, //0x000001e4 je LBB0_6
0x41, 0x89, 0xca, //0x000001ea movl %ecx, %r10d
0x48, 0x8b, 0x07, //0x000001ed movq (%rdi), %rax
0x48, 0x8b, 0x4f, 0x10, //0x000001f0 movq $16(%rdi), %rcx
0x48, 0x89, 0x7d, 0x80, //0x000001f4 movq %rdi, $-128(%rbp)
0x48, 0x8b, 0x7f, 0x08, //0x000001f8 movq $8(%rdi), %rdi
0x48, 0x01, 0xc7, //0x000001fc addq %rax, %rdi
0x48, 0x89, 0x7d, 0x98, //0x000001ff movq %rdi, $-104(%rbp)
0x48, 0x8d, 0x3c, 0x08, //0x00000203 leaq (%rax,%rcx), %rdi
0x48, 0x89, 0x7d, 0xb8, //0x00000207 movq %rdi, $-72(%rbp)
0x4c, 0x8d, 0x0c, 0x16, //0x0000020b leaq (%rsi,%rdx), %r9
0x48, 0x8d, 0x1d, 0x6a, 0x34, 0x00, 0x00, //0x0000020f leaq $13418(%rip), %rbx /* _VecDecodeCharsetStd+0(%rip) */
0x48, 0x8d, 0x3d, 0x63, 0x35, 0x00, 0x00, //0x00000216 leaq $13667(%rip), %rdi /* _VecDecodeCharsetURL+0(%rip) */
0x41, 0xf6, 0xc2, 0x01, //0x0000021d testb $1, %r10b
0x48, 0x0f, 0x44, 0xfb, //0x00000221 cmoveq %rbx, %rdi
0x48, 0x89, 0x7d, 0xd0, //0x00000225 movq %rdi, $-48(%rbp)
0x0f, 0x84, 0x47, 0x00, 0x00, 0x00, //0x00000229 je LBB0_7
0xc5, 0xfe, 0x6f, 0x05, 0xe9, 0xfd, 0xff, 0xff, //0x0000022f vmovdqu $-535(%rip), %ymm0 /* LCPI0_1+0(%rip) */
0x0f, 0x85, 0x47, 0x00, 0x00, 0x00, //0x00000237 jne LBB0_8
//0x0000023d LBB0_3
0xc5, 0xfe, 0x6f, 0x0d, 0xfb, 0xfd, 0xff, 0xff, //0x0000023d vmovdqu $-517(%rip), %ymm1 /* LCPI0_2+0(%rip) */
0x0f, 0x85, 0x47, 0x00, 0x00, 0x00, //0x00000245 jne LBB0_9
//0x0000024b LBB0_4
0xc5, 0xfe, 0x6f, 0x15, 0x2d, 0xfe, 0xff, 0xff, //0x0000024b vmovdqu $-467(%rip), %ymm2 /* LCPI0_4+0(%rip) */
0x4c, 0x8d, 0x74, 0x16, 0xe0, //0x00000253 leaq $-32(%rsi,%rdx), %r14
0x48, 0x89, 0x55, 0xa0, //0x00000258 movq %rdx, $-96(%rbp)
0x0f, 0x85, 0x47, 0x00, 0x00, 0x00, //0x0000025c jne LBB0_10
//0x00000262 LBB0_5
0xc5, 0xfe, 0x6f, 0x1d, 0x56, 0xfe, 0xff, 0xff, //0x00000262 vmovdqu $-426(%rip), %ymm3 /* LCPI0_6+0(%rip) */
0xe9, 0x42, 0x00, 0x00, 0x00, //0x0000026a jmp LBB0_11
//0x0000026f LBB0_6
0x31, 0xc0, //0x0000026f xorl %eax, %eax
0xe9, 0xf4, 0x33, 0x00, 0x00, //0x00000271 jmp LBB0_865
//0x00000276 LBB0_7
0xc5, 0xfe, 0x6f, 0x05, 0x82, 0xfd, 0xff, 0xff, //0x00000276 vmovdqu $-638(%rip), %ymm0 /* LCPI0_0+0(%rip) */
0x0f, 0x84, 0xb9, 0xff, 0xff, 0xff, //0x0000027e je LBB0_3
//0x00000284 LBB0_8
0xc5, 0xfe, 0x6f, 0x0d, 0xd4, 0xfd, 0xff, 0xff, //0x00000284 vmovdqu $-556(%rip), %ymm1 /* LCPI0_3+0(%rip) */
0x0f, 0x84, 0xb9, 0xff, 0xff, 0xff, //0x0000028c je LBB0_4
//0x00000292 LBB0_9
0xc5, 0xfe, 0x6f, 0x15, 0x06, 0xfe, 0xff, 0xff, //0x00000292 vmovdqu $-506(%rip), %ymm2 /* LCPI0_5+0(%rip) */
0x4c, 0x8d, 0x74, 0x16, 0xe0, //0x0000029a leaq $-32(%rsi,%rdx), %r14
0x48, 0x89, 0x55, 0xa0, //0x0000029f movq %rdx, $-96(%rbp)
0x0f, 0x84, 0xb9, 0xff, 0xff, 0xff, //0x000002a3 je LBB0_5
//0x000002a9 LBB0_10
0xc5, 0xfe, 0x6f, 0x1d, 0x2f, 0xfe, 0xff, 0xff, //0x000002a9 vmovdqu $-465(%rip), %ymm3 /* LCPI0_7+0(%rip) */
//0x000002b1 LBB0_11
0x48, 0x8b, 0x7d, 0x98, //0x000002b1 movq $-104(%rbp), %rdi
0x49, 0x89, 0xf3, //0x000002b5 movq %rsi, %r11
0x48, 0x89, 0xf2, //0x000002b8 movq %rsi, %rdx
0x48, 0x89, 0x75, 0xb0, //0x000002bb movq %rsi, $-80(%rbp)
0x49, 0x39, 0xf6, //0x000002bf cmpq %rsi, %r14
0x48, 0x89, 0xfa, //0x000002c2 movq %rdi, %rdx
0x44, 0x89, 0x55, 0xcc, //0x000002c5 movl %r10d, $-52(%rbp)
0x0f, 0x82, 0x6e, 0x0d, 0x00, 0x00, //0x000002c9 jb LBB0_227
0x4c, 0x8d, 0x3c, 0x08, //0x000002cf leaq (%rax,%rcx), %r15
0x49, 0x83, 0xc7, 0xe0, //0x000002d3 addq $-32, %r15
0x48, 0x8b, 0x45, 0x98, //0x000002d7 movq $-104(%rbp), %rax
0x48, 0x89, 0xc2, //0x000002db movq %rax, %rdx
0x4c, 0x8b, 0x5d, 0xb0, //0x000002de movq $-80(%rbp), %r11
0x4c, 0x39, 0xf8, //0x000002e2 cmpq %r15, %rax
0x0f, 0x87, 0x52, 0x0d, 0x00, 0x00, //0x000002e5 ja LBB0_227
0x4c, 0x8b, 0x5d, 0xb0, //0x000002eb movq $-80(%rbp), %r11
0x48, 0x8b, 0x45, 0xa0, //0x000002ef movq $-96(%rbp), %rax
0x4c, 0x01, 0xd8, //0x000002f3 addq %r11, %rax
0x48, 0x83, 0xc0, 0xff, //0x000002f6 addq $-1, %rax
0x48, 0x89, 0x45, 0xa8, //0x000002fa movq %rax, $-88(%rbp)
0xc5, 0xfe, 0x6f, 0x25, 0xfa, 0xfd, 0xff, 0xff, //0x000002fe vmovdqu $-518(%rip), %ymm4 /* LCPI0_8+0(%rip) */
0xc5, 0xfe, 0x6f, 0x2d, 0x12, 0xfe, 0xff, 0xff, //0x00000306 vmovdqu $-494(%rip), %ymm5 /* LCPI0_9+0(%rip) */
0xc5, 0xc9, 0xef, 0xf6, //0x0000030e vpxor %xmm6, %xmm6, %xmm6
0x49, 0xb8, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, //0x00000312 movabsq $-4294967296, %r8
0xc5, 0x7e, 0x6f, 0x05, 0x3c, 0xfe, 0xff, 0xff, //0x0000031c vmovdqu $-452(%rip), %ymm8 /* LCPI0_11+0(%rip) */
0xc5, 0x7e, 0x6f, 0x0d, 0x54, 0xfe, 0xff, 0xff, //0x00000324 vmovdqu $-428(%rip), %ymm9 /* LCPI0_12+0(%rip) */
0xc5, 0x7a, 0x6f, 0x15, 0x8c, 0xfe, 0xff, 0xff, //0x0000032c vmovdqu $-372(%rip), %xmm10 /* LCPI0_13+0(%rip) */
0xc5, 0x7e, 0x6f, 0x1d, 0x64, 0xfe, 0xff, 0xff, //0x00000334 vmovdqu $-412(%rip), %ymm11 /* LCPI0_14+0(%rip) */
0x48, 0x8b, 0x55, 0x98, //0x0000033c movq $-104(%rbp), %rdx
//0x00000340 .p2align 4, 0x90
//0x00000340 LBB0_14
0xc4, 0x41, 0x7e, 0x6f, 0x23, //0x00000340 vmovdqu (%r11), %ymm12
0xc4, 0xc1, 0x15, 0x72, 0xd4, 0x04, //0x00000345 vpsrld $4, %ymm12, %ymm13
0xc5, 0x15, 0xdb, 0xec, //0x0000034b vpand %ymm4, %ymm13, %ymm13
0xc5, 0x1d, 0xdb, 0xf4, //0x0000034f vpand %ymm4, %ymm12, %ymm14
0xc4, 0x42, 0x7d, 0x00, 0xf6, //0x00000353 vpshufb %ymm14, %ymm0, %ymm14
0xc4, 0x42, 0x55, 0x00, 0xfd, //0x00000358 vpshufb %ymm13, %ymm5, %ymm15
0xc4, 0x41, 0x05, 0xdb, 0xf6, //0x0000035d vpand %ymm14, %ymm15, %ymm14
0xc5, 0x0d, 0x74, 0xf6, //0x00000362 vpcmpeqb %ymm6, %ymm14, %ymm14
0xc4, 0xc1, 0x7d, 0xd7, 0xc6, //0x00000366 vpmovmskb %ymm14, %eax
0x4c, 0x09, 0xc0, //0x0000036b orq %r8, %rax
0x48, 0x0f, 0xbc, 0xc0, //0x0000036e bsfq %rax, %rax
0x83, 0xf8, 0x1f, //0x00000372 cmpl $31, %eax
0x0f, 0x87, 0x85, 0x00, 0x00, 0x00, //0x00000375 ja LBB0_22
0x4d, 0x39, 0xcb, //0x0000037b cmpq %r9, %r11
0x0f, 0x83, 0xca, 0x00, 0x00, 0x00, //0x0000037e jae LBB0_23
0x48, 0x89, 0x55, 0xc0, //0x00000384 movq %rdx, $-64(%rbp)
0x4d, 0x89, 0xdc, //0x00000388 movq %r11, %r12
0x41, 0xf6, 0xc2, 0x08, //0x0000038b testb $8, %r10b
0x0f, 0x85, 0x47, 0x01, 0x00, 0x00, //0x0000038f jne LBB0_32
0xe9, 0x13, 0x00, 0x00, 0x00, //0x00000395 jmp LBB0_18
0x90, 0x90, 0x90, 0x90, 0x90, 0x90, //0x0000039a .p2align 4, 0x90
//0x000003a0 LBB0_17
0x49, 0x83, 0xc4, 0x01, //0x000003a0 addq $1, %r12
0x4d, 0x39, 0xcc, //0x000003a4 cmpq %r9, %r12
0x0f, 0x83, 0x5d, 0x02, 0x00, 0x00, //0x000003a7 jae LBB0_48
//0x000003ad LBB0_18
0x41, 0x0f, 0xb6, 0x34, 0x24, //0x000003ad movzbl (%r12), %esi
0x48, 0x83, 0xfe, 0x0d, //0x000003b2 cmpq $13, %rsi
0x0f, 0x84, 0xe4, 0xff, 0xff, 0xff, //0x000003b6 je LBB0_17
0x40, 0x80, 0xfe, 0x0a, //0x000003bc cmpb $10, %sil
0x0f, 0x84, 0xda, 0xff, 0xff, 0xff, //0x000003c0 je LBB0_17
0x48, 0x8b, 0x45, 0xd0, //0x000003c6 movq $-48(%rbp), %rax
0x44, 0x0f, 0xb6, 0x2c, 0x30, //0x000003ca movzbl (%rax,%rsi), %r13d
0x49, 0x83, 0xc4, 0x01, //0x000003cf addq $1, %r12
0x41, 0x81, 0xfd, 0xff, 0x00, 0x00, 0x00, //0x000003d3 cmpl $255, %r13d
0x0f, 0x84, 0x5f, 0x03, 0x00, 0x00, //0x000003da je LBB0_72
0xbf, 0x01, 0x00, 0x00, 0x00, //0x000003e0 movl $1, %edi
0x4d, 0x39, 0xcc, //0x000003e5 cmpq %r9, %r12
0x0f, 0x82, 0x8f, 0x00, 0x00, 0x00, //0x000003e8 jb LBB0_26
0xe9, 0xd8, 0x02, 0x00, 0x00, //0x000003ee jmp LBB0_62
0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, //0x000003f3 .p2align 4, 0x90
//0x00000400 LBB0_22
0xc5, 0x1d, 0x74, 0xf1, //0x00000400 vpcmpeqb %ymm1, %ymm12, %ymm14
0xc4, 0x42, 0x65, 0x00, 0xed, //0x00000404 vpshufb %ymm13, %ymm3, %ymm13
0xc4, 0x63, 0x15, 0x4c, 0xea, 0xe0, //0x00000409 vpblendvb %ymm14, %ymm2, %ymm13, %ymm13
0xc4, 0x41, 0x15, 0xfc, 0xe4, //0x0000040f vpaddb %ymm12, %ymm13, %ymm12
0xc5, 0x1d, 0xdb, 0x25, 0x24, 0xfd, 0xff, 0xff, //0x00000414 vpand $-732(%rip), %ymm12, %ymm12 /* LCPI0_10+0(%rip) */
0xc4, 0x42, 0x1d, 0x04, 0xe0, //0x0000041c vpmaddubsw %ymm8, %ymm12, %ymm12
0xc4, 0x41, 0x1d, 0xf5, 0xe1, //0x00000421 vpmaddwd %ymm9, %ymm12, %ymm12
0xc4, 0x63, 0x7d, 0x39, 0xe7, 0x01, //0x00000426 vextracti128 $1, %ymm12, %xmm7
0xc4, 0xc2, 0x41, 0x00, 0xfa, //0x0000042c vpshufb %xmm10, %xmm7, %xmm7
0xc4, 0x42, 0x1d, 0x00, 0xe3, //0x00000431 vpshufb %ymm11, %ymm12, %ymm12
0xc4, 0xe3, 0x1d, 0x02, 0xff, 0x08, //0x00000436 vpblendd $8, %ymm7, %ymm12, %ymm7
0xc4, 0xe3, 0x45, 0x02, 0xfe, 0xc0, //0x0000043c vpblendd $192, %ymm6, %ymm7, %ymm7
0xc5, 0xfe, 0x7f, 0x3a, //0x00000442 vmovdqu %ymm7, (%rdx)
0x49, 0x83, 0xc3, 0x20, //0x00000446 addq $32, %r11
0x48, 0x83, 0xc2, 0x18, //0x0000044a addq $24, %rdx
//0x0000044e LBB0_23
0x4d, 0x39, 0xf3, //0x0000044e cmpq %r14, %r11
0x0f, 0x87, 0xe6, 0x0b, 0x00, 0x00, //0x00000451 ja LBB0_227
0x4c, 0x39, 0xfa, //0x00000457 cmpq %r15, %rdx
0x0f, 0x86, 0xe0, 0xfe, 0xff, 0xff, //0x0000045a jbe LBB0_14
0xe9, 0xd8, 0x0b, 0x00, 0x00, //0x00000460 jmp LBB0_227
0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, //0x00000465 .p2align 4, 0x90
//0x00000470 LBB0_25
0x49, 0x83, 0xc4, 0x01, //0x00000470 addq $1, %r12
0x4d, 0x39, 0xcc, //0x00000474 cmpq %r9, %r12
0x0f, 0x83, 0xbd, 0x04, 0x00, 0x00, //0x00000477 jae LBB0_105
//0x0000047d LBB0_26
0x41, 0x0f, 0xb6, 0x34, 0x24, //0x0000047d movzbl (%r12), %esi
0x48, 0x83, 0xfe, 0x0d, //0x00000482 cmpq $13, %rsi
0x0f, 0x84, 0xe4, 0xff, 0xff, 0xff, //0x00000486 je LBB0_25
0x40, 0x80, 0xfe, 0x0a, //0x0000048c cmpb $10, %sil
0x0f, 0x84, 0xda, 0xff, 0xff, 0xff, //0x00000490 je LBB0_25
0x48, 0x8b, 0x45, 0xd0, //0x00000496 movq $-48(%rbp), %rax
0x0f, 0xb6, 0x04, 0x30, //0x0000049a movzbl (%rax,%rsi), %eax
0x49, 0x83, 0xc4, 0x01, //0x0000049e addq $1, %r12
0x3d, 0xff, 0x00, 0x00, 0x00, //0x000004a2 cmpl $255, %eax
0x0f, 0x84, 0x2d, 0x08, 0x00, 0x00, //0x000004a7 je LBB0_158
0x41, 0xc1, 0xe5, 0x06, //0x000004ad shll $6, %r13d
0x41, 0x09, 0xc5, //0x000004b1 orl %eax, %r13d
0xbf, 0x02, 0x00, 0x00, 0x00, //0x000004b4 movl $2, %edi
0x4d, 0x39, 0xcc, //0x000004b9 cmpq %r9, %r12
0x0f, 0x82, 0x80, 0x01, 0x00, 0x00, //0x000004bc jb LBB0_52
0xe9, 0x04, 0x02, 0x00, 0x00, //0x000004c2 jmp LBB0_62
//0x000004c7 LBB0_46
0x80, 0xf9, 0x6e, //0x000004c7 cmpb $110, %cl
0x0f, 0x85, 0xc4, 0x01, 0x00, 0x00, //0x000004ca jne LBB0_57
//0x000004d0 LBB0_30
0x49, 0x89, 0xc4, //0x000004d0 movq %rax, %r12
//0x000004d3 LBB0_31
0x4d, 0x39, 0xcc, //0x000004d3 cmpq %r9, %r12
0x0f, 0x83, 0x2e, 0x01, 0x00, 0x00, //0x000004d6 jae LBB0_48
//0x000004dc LBB0_32
0x49, 0x8d, 0x4c, 0x24, 0x01, //0x000004dc leaq $1(%r12), %rcx
0x41, 0x0f, 0xb6, 0x04, 0x24, //0x000004e1 movzbl (%r12), %eax
0x3c, 0x5c, //0x000004e6 cmpb $92, %al
0x0f, 0x85, 0x02, 0x01, 0x00, 0x00, //0x000004e8 jne LBB0_44
0x49, 0x8d, 0x44, 0x24, 0x02, //0x000004ee leaq $2(%r12), %rax
0x40, 0xb6, 0xff, //0x000004f3 movb $-1, %sil
0x4c, 0x39, 0xc8, //0x000004f6 cmpq %r9, %rax
0x0f, 0x87, 0x8d, 0x01, 0x00, 0x00, //0x000004f9 ja LBB0_56
0x0f, 0xb6, 0x09, //0x000004ff movzbl (%rcx), %ecx
0x80, 0xf9, 0x71, //0x00000502 cmpb $113, %cl
0x0f, 0x8e, 0xbc, 0xff, 0xff, 0xff, //0x00000505 jle LBB0_46
0x80, 0xf9, 0x72, //0x0000050b cmpb $114, %cl
0x0f, 0x84, 0xbc, 0xff, 0xff, 0xff, //0x0000050e je LBB0_30
0x80, 0xf9, 0x75, //0x00000514 cmpb $117, %cl
0x0f, 0x85, 0x83, 0x01, 0x00, 0x00, //0x00000517 jne LBB0_59
0x4c, 0x89, 0xc9, //0x0000051d movq %r9, %rcx
0x48, 0x29, 0xc1, //0x00000520 subq %rax, %rcx
0x48, 0x83, 0xf9, 0x04, //0x00000523 cmpq $4, %rcx
0x0f, 0x8c, 0x73, 0x01, 0x00, 0x00, //0x00000527 jl LBB0_59
0x8b, 0x08, //0x0000052d movl (%rax), %ecx
0x89, 0xca, //0x0000052f movl %ecx, %edx
0xf7, 0xd2, //0x00000531 notl %edx
0x8d, 0xb9, 0xd0, 0xcf, 0xcf, 0xcf, //0x00000533 leal $-808464432(%rcx), %edi
0x81, 0xe2, 0x80, 0x80, 0x80, 0x80, //0x00000539 andl $-2139062144, %edx
0x85, 0xfa, //0x0000053f testl %edi, %edx
0x0f, 0x85, 0x59, 0x01, 0x00, 0x00, //0x00000541 jne LBB0_59
0x8d, 0xb9, 0x19, 0x19, 0x19, 0x19, //0x00000547 leal $421075225(%rcx), %edi
0x09, 0xcf, //0x0000054d orl %ecx, %edi
0xf7, 0xc7, 0x80, 0x80, 0x80, 0x80, //0x0000054f testl $-2139062144, %edi
0x0f, 0x85, 0x45, 0x01, 0x00, 0x00, //0x00000555 jne LBB0_59
0x89, 0xcf, //0x0000055b movl %ecx, %edi
0x81, 0xe7, 0x7f, 0x7f, 0x7f, 0x7f, //0x0000055d andl $2139062143, %edi
0xbb, 0xc0, 0xc0, 0xc0, 0xc0, //0x00000563 movl $-1061109568, %ebx
0x29, 0xfb, //0x00000568 subl %edi, %ebx
0x44, 0x8d, 0xaf, 0x46, 0x46, 0x46, 0x46, //0x0000056a leal $1179010630(%rdi), %r13d
0x21, 0xd3, //0x00000571 andl %edx, %ebx
0x44, 0x85, 0xeb, //0x00000573 testl %r13d, %ebx
0x0f, 0x85, 0x2f, 0x05, 0x00, 0x00, //0x00000576 jne LBB0_125
0xbb, 0xe0, 0xe0, 0xe0, 0xe0, //0x0000057c movl $-522133280, %ebx
0x29, 0xfb, //0x00000581 subl %edi, %ebx
0x81, 0xc7, 0x39, 0x39, 0x39, 0x39, //0x00000583 addl $960051513, %edi
0x21, 0xda, //0x00000589 andl %ebx, %edx
0x85, 0xfa, //0x0000058b testl %edi, %edx
0x44, 0x8b, 0x55, 0xcc, //0x0000058d movl $-52(%rbp), %r10d
0x0f, 0x85, 0x09, 0x01, 0x00, 0x00, //0x00000591 jne LBB0_59
0x0f, 0xc9, //0x00000597 bswapl %ecx
0x89, 0xc8, //0x00000599 movl %ecx, %eax
0xc1, 0xe8, 0x04, //0x0000059b shrl $4, %eax
0xf7, 0xd0, //0x0000059e notl %eax
0x25, 0x01, 0x01, 0x01, 0x01, //0x000005a0 andl $16843009, %eax
0x8d, 0x04, 0xc0, //0x000005a5 leal (%rax,%rax,8), %eax
0x81, 0xe1, 0x0f, 0x0f, 0x0f, 0x0f, //0x000005a8 andl $252645135, %ecx
0x01, 0xc1, //0x000005ae addl %eax, %ecx
0x89, 0xc8, //0x000005b0 movl %ecx, %eax
0xc1, 0xe8, 0x04, //0x000005b2 shrl $4, %eax
0x09, 0xc8, //0x000005b5 orl %ecx, %eax
0x89, 0xc1, //0x000005b7 movl %eax, %ecx
0xc1, 0xe9, 0x08, //0x000005b9 shrl $8, %ecx
0x81, 0xe1, 0x00, 0xff, 0x00, 0x00, //0x000005bc andl $65280, %ecx
0x89, 0xc2, //0x000005c2 movl %eax, %edx
0x81, 0xe2, 0x80, 0x00, 0x00, 0x00, //0x000005c4 andl $128, %edx
0x49, 0x83, 0xc4, 0x06, //0x000005ca addq $6, %r12
0x09, 0xca, //0x000005ce orl %ecx, %edx
0x0f, 0x85, 0xcd, 0x00, 0x00, 0x00, //0x000005d0 jne LBB0_60
0x3c, 0x0d, //0x000005d6 cmpb $13, %al
0x0f, 0x85, 0x1d, 0x00, 0x00, 0x00, //0x000005d8 jne LBB0_45
0xe9, 0xf0, 0xfe, 0xff, 0xff, //0x000005de jmp LBB0_31
0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, //0x000005e3 .p2align 4, 0x90
//0x000005f0 LBB0_44
0x49, 0x89, 0xcc, //0x000005f0 movq %rcx, %r12
0x3c, 0x0d, //0x000005f3 cmpb $13, %al
0x0f, 0x84, 0xd8, 0xfe, 0xff, 0xff, //0x000005f5 je LBB0_31
//0x000005fb LBB0_45
0x89, 0xc6, //0x000005fb movl %eax, %esi
0x3c, 0x0a, //0x000005fd cmpb $10, %al
0x0f, 0x84, 0xce, 0xfe, 0xff, 0xff, //0x000005ff je LBB0_31
0xe9, 0x99, 0x00, 0x00, 0x00, //0x00000605 jmp LBB0_60
//0x0000060a LBB0_48
0x31, 0xff, //0x0000060a xorl %edi, %edi
0x45, 0x31, 0xed, //0x0000060c xorl %r13d, %r13d
//0x0000060f LBB0_49
0x85, 0xff, //0x0000060f testl %edi, %edi
0x48, 0x8b, 0x55, 0xc0, //0x00000611 movq $-64(%rbp), %rdx
0x0f, 0x85, 0xb0, 0x00, 0x00, 0x00, //0x00000615 jne LBB0_62
0x4d, 0x89, 0xe3, //0x0000061b movq %r12, %r11
0xe9, 0x2b, 0xfe, 0xff, 0xff, //0x0000061e jmp LBB0_23
0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, //0x00000623 .p2align 4, 0x90
//0x00000630 LBB0_51
0x49, 0x83, 0xc4, 0x01, //0x00000630 addq $1, %r12
0xbf, 0x02, 0x00, 0x00, 0x00, //0x00000634 movl $2, %edi
0x4d, 0x39, 0xcc, //0x00000639 cmpq %r9, %r12
0x0f, 0x83, 0xcd, 0xff, 0xff, 0xff, //0x0000063c jae LBB0_49
//0x00000642 LBB0_52
0x41, 0x0f, 0xb6, 0x34, 0x24, //0x00000642 movzbl (%r12), %esi
0x48, 0x83, 0xfe, 0x0d, //0x00000647 cmpq $13, %rsi
0x0f, 0x84, 0xdf, 0xff, 0xff, 0xff, //0x0000064b je LBB0_51
0x40, 0x80, 0xfe, 0x0a, //0x00000651 cmpb $10, %sil
0x0f, 0x84, 0xd5, 0xff, 0xff, 0xff, //0x00000655 je LBB0_51
0x48, 0x8b, 0x45, 0xd0, //0x0000065b movq $-48(%rbp), %rax
0x0f, 0xb6, 0x04, 0x30, //0x0000065f movzbl (%rax,%rsi), %eax
0x49, 0x83, 0xc4, 0x01, //0x00000663 addq $1, %r12
0x3d, 0xff, 0x00, 0x00, 0x00, //0x00000667 cmpl $255, %eax
0x0f, 0x84, 0x3e, 0x09, 0x00, 0x00, //0x0000066c je LBB0_191
0x41, 0xc1, 0xe5, 0x06, //0x00000672 shll $6, %r13d
0x41, 0x09, 0xc5, //0x00000676 orl %eax, %r13d
0xbf, 0x03, 0x00, 0x00, 0x00, //0x00000679 movl $3, %edi
0x4d, 0x39, 0xcc, //0x0000067e cmpq %r9, %r12
0x0f, 0x82, 0x91, 0x04, 0x00, 0x00, //0x00000681 jb LBB0_131
0xe9, 0x3f, 0x00, 0x00, 0x00, //0x00000687 jmp LBB0_62
//0x0000068c LBB0_56
0x49, 0x89, 0xcc, //0x0000068c movq %rcx, %r12
0xe9, 0x0f, 0x00, 0x00, 0x00, //0x0000068f jmp LBB0_60
//0x00000694 LBB0_57
0x80, 0xf9, 0x2f, //0x00000694 cmpb $47, %cl
0x0f, 0x85, 0x03, 0x00, 0x00, 0x00, //0x00000697 jne LBB0_59
0x40, 0xb6, 0x2f, //0x0000069d movb $47, %sil
//0x000006a0 LBB0_59
0x49, 0x89, 0xc4, //0x000006a0 movq %rax, %r12
//0x000006a3 LBB0_60
0x40, 0x0f, 0xb6, 0xc6, //0x000006a3 movzbl %sil, %eax
0x48, 0x8b, 0x4d, 0xd0, //0x000006a7 movq $-48(%rbp), %rcx
0x44, 0x0f, 0xb6, 0x2c, 0x01, //0x000006ab movzbl (%rcx,%rax), %r13d
0x41, 0x81, 0xfd, 0xff, 0x00, 0x00, 0x00, //0x000006b0 cmpl $255, %r13d
0x0f, 0x84, 0x82, 0x00, 0x00, 0x00, //0x000006b7 je LBB0_72
0xbf, 0x01, 0x00, 0x00, 0x00, //0x000006bd movl $1, %edi
0x4d, 0x39, 0xcc, //0x000006c2 cmpq %r9, %r12
0x0f, 0x82, 0x39, 0x01, 0x00, 0x00, //0x000006c5 jb LBB0_88
//0x000006cb LBB0_62
0x41, 0xf6, 0xc2, 0x02, //0x000006cb testb $2, %r10b
0x0f, 0x94, 0xc0, //0x000006cf sete %al
0x83, 0xff, 0x01, //0x000006d2 cmpl $1, %edi
0x0f, 0x94, 0xc1, //0x000006d5 sete %cl
0x4d, 0x39, 0xcc, //0x000006d8 cmpq %r9, %r12
0x0f, 0x82, 0x11, 0x00, 0x00, 0x00, //0x000006db jb LBB0_65
0x83, 0xff, 0x04, //0x000006e1 cmpl $4, %edi
0x0f, 0x84, 0x08, 0x00, 0x00, 0x00, //0x000006e4 je LBB0_65
0x08, 0xc8, //0x000006ea orb %cl, %al
0x0f, 0x85, 0xef, 0x03, 0x00, 0x00, //0x000006ec jne LBB0_167
//0x000006f2 LBB0_65
0xb0, 0x04, //0x000006f2 movb $4, %al
0x40, 0x28, 0xf8, //0x000006f4 subb %dil, %al
0x0f, 0xb6, 0xc0, //0x000006f7 movzbl %al, %eax
0x01, 0xc0, //0x000006fa addl %eax, %eax
0x8d, 0x0c, 0x40, //0x000006fc leal (%rax,%rax,2), %ecx
0x44, 0x89, 0xe8, //0x000006ff movl %r13d, %eax
0xd3, 0xe0, //0x00000702 shll %cl, %eax
0x83, 0xff, 0x02, //0x00000704 cmpl $2, %edi
0x48, 0x8b, 0x55, 0xc0, //0x00000707 movq $-64(%rbp), %rdx
0x0f, 0x84, 0x18, 0x00, 0x00, 0x00, //0x0000070b je LBB0_70
0x83, 0xff, 0x03, //0x00000711 cmpl $3, %edi
0x0f, 0x84, 0x0c, 0x00, 0x00, 0x00, //0x00000714 je LBB0_69
0x83, 0xff, 0x04, //0x0000071a cmpl $4, %edi
0x0f, 0x85, 0x0b, 0x00, 0x00, 0x00, //0x0000071d jne LBB0_71
0x88, 0x42, 0x02, //0x00000723 movb %al, $2(%rdx)
//0x00000726 LBB0_69
0x88, 0x62, 0x01, //0x00000726 movb %ah, $1(%rdx)
//0x00000729 LBB0_70
0xc1, 0xe8, 0x10, //0x00000729 shrl $16, %eax
0x88, 0x02, //0x0000072c movb %al, (%rdx)
//0x0000072e LBB0_71
0x89, 0xf8, //0x0000072e movl %edi, %eax
0x48, 0x01, 0xc2, //0x00000730 addq %rax, %rdx
0x48, 0x83, 0xc2, 0xff, //0x00000733 addq $-1, %rdx
0x4d, 0x89, 0xe3, //0x00000737 movq %r12, %r11
| go | Apache-2.0 | b3b4703e958c25d54c4d48138d9e80ae32fadac3 | 2026-01-07T09:44:30.792320Z | true |
kubev2v/forklift | https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/github.com/cloudwego/base64x/internal/native/avx2/b64encode_text_amd64.go | vendor/github.com/cloudwego/base64x/internal/native/avx2/b64encode_text_amd64.go | // +build amd64
// Code generated by asm2asm, DO NOT EDIT.
package avx2
var _text_b64encode = []byte{
// .p2align 5, 0x00
// LCPI0_0
0x47, // .byte 71
0xfc, //0x00000001 .byte 252
0xfc, //0x00000002 .byte 252
0xfc, //0x00000003 .byte 252
0xfc, //0x00000004 .byte 252
0xfc, //0x00000005 .byte 252
0xfc, //0x00000006 .byte 252
0xfc, //0x00000007 .byte 252
0xfc, //0x00000008 .byte 252
0xfc, //0x00000009 .byte 252
0xfc, //0x0000000a .byte 252
0xed, //0x0000000b .byte 237
0xf0, //0x0000000c .byte 240
0x41, //0x0000000d .byte 65
0x00, //0x0000000e .byte 0
0x00, //0x0000000f .byte 0
0x47, //0x00000010 .byte 71
0xfc, //0x00000011 .byte 252
0xfc, //0x00000012 .byte 252
0xfc, //0x00000013 .byte 252
0xfc, //0x00000014 .byte 252
0xfc, //0x00000015 .byte 252
0xfc, //0x00000016 .byte 252
0xfc, //0x00000017 .byte 252
0xfc, //0x00000018 .byte 252
0xfc, //0x00000019 .byte 252
0xfc, //0x0000001a .byte 252
0xed, //0x0000001b .byte 237
0xf0, //0x0000001c .byte 240
0x41, //0x0000001d .byte 65
0x00, //0x0000001e .byte 0
0x00, //0x0000001f .byte 0
//0x00000020 LCPI0_1
0x47, //0x00000020 .byte 71
0xfc, //0x00000021 .byte 252
0xfc, //0x00000022 .byte 252
0xfc, //0x00000023 .byte 252
0xfc, //0x00000024 .byte 252
0xfc, //0x00000025 .byte 252
0xfc, //0x00000026 .byte 252
0xfc, //0x00000027 .byte 252
0xfc, //0x00000028 .byte 252
0xfc, //0x00000029 .byte 252
0xfc, //0x0000002a .byte 252
0xef, //0x0000002b .byte 239
0x20, //0x0000002c .byte 32
0x41, //0x0000002d .byte 65
0x00, //0x0000002e .byte 0
0x00, //0x0000002f .byte 0
0x47, //0x00000030 .byte 71
0xfc, //0x00000031 .byte 252
0xfc, //0x00000032 .byte 252
0xfc, //0x00000033 .byte 252
0xfc, //0x00000034 .byte 252
0xfc, //0x00000035 .byte 252
0xfc, //0x00000036 .byte 252
0xfc, //0x00000037 .byte 252
0xfc, //0x00000038 .byte 252
0xfc, //0x00000039 .byte 252
0xfc, //0x0000003a .byte 252
0xef, //0x0000003b .byte 239
0x20, //0x0000003c .byte 32
0x41, //0x0000003d .byte 65
0x00, //0x0000003e .byte 0
0x00, //0x0000003f .byte 0
//0x00000040 LCPI0_2
0x01, //0x00000040 .byte 1
0x00, //0x00000041 .byte 0
0x02, //0x00000042 .byte 2
0x01, //0x00000043 .byte 1
0x04, //0x00000044 .byte 4
0x03, //0x00000045 .byte 3
0x05, //0x00000046 .byte 5
0x04, //0x00000047 .byte 4
0x07, //0x00000048 .byte 7
0x06, //0x00000049 .byte 6
0x08, //0x0000004a .byte 8
0x07, //0x0000004b .byte 7
0x0a, //0x0000004c .byte 10
0x09, //0x0000004d .byte 9
0x0b, //0x0000004e .byte 11
0x0a, //0x0000004f .byte 10
0x01, //0x00000050 .byte 1
0x00, //0x00000051 .byte 0
0x02, //0x00000052 .byte 2
0x01, //0x00000053 .byte 1
0x04, //0x00000054 .byte 4
0x03, //0x00000055 .byte 3
0x05, //0x00000056 .byte 5
0x04, //0x00000057 .byte 4
0x07, //0x00000058 .byte 7
0x06, //0x00000059 .byte 6
0x08, //0x0000005a .byte 8
0x07, //0x0000005b .byte 7
0x0a, //0x0000005c .byte 10
0x09, //0x0000005d .byte 9
0x0b, //0x0000005e .byte 11
0x0a, //0x0000005f .byte 10
//0x00000060 LCPI0_3
0x00, 0xfc, //0x00000060 .word 64512
0xc0, 0x0f, //0x00000062 .word 4032
0x00, 0xfc, //0x00000064 .word 64512
0xc0, 0x0f, //0x00000066 .word 4032
0x00, 0xfc, //0x00000068 .word 64512
0xc0, 0x0f, //0x0000006a .word 4032
0x00, 0xfc, //0x0000006c .word 64512
0xc0, 0x0f, //0x0000006e .word 4032
0x00, 0xfc, //0x00000070 .word 64512
0xc0, 0x0f, //0x00000072 .word 4032
0x00, 0xfc, //0x00000074 .word 64512
0xc0, 0x0f, //0x00000076 .word 4032
0x00, 0xfc, //0x00000078 .word 64512
0xc0, 0x0f, //0x0000007a .word 4032
0x00, 0xfc, //0x0000007c .word 64512
0xc0, 0x0f, //0x0000007e .word 4032
//0x00000080 LCPI0_4
0x40, 0x00, //0x00000080 .word 64
0x00, 0x04, //0x00000082 .word 1024
0x40, 0x00, //0x00000084 .word 64
0x00, 0x04, //0x00000086 .word 1024
0x40, 0x00, //0x00000088 .word 64
0x00, 0x04, //0x0000008a .word 1024
0x40, 0x00, //0x0000008c .word 64
0x00, 0x04, //0x0000008e .word 1024
0x40, 0x00, //0x00000090 .word 64
0x00, 0x04, //0x00000092 .word 1024
0x40, 0x00, //0x00000094 .word 64
0x00, 0x04, //0x00000096 .word 1024
0x40, 0x00, //0x00000098 .word 64
0x00, 0x04, //0x0000009a .word 1024
0x40, 0x00, //0x0000009c .word 64
0x00, 0x04, //0x0000009e .word 1024
//0x000000a0 LCPI0_5
0xf0, 0x03, //0x000000a0 .word 1008
0x3f, 0x00, //0x000000a2 .word 63
0xf0, 0x03, //0x000000a4 .word 1008
0x3f, 0x00, //0x000000a6 .word 63
0xf0, 0x03, //0x000000a8 .word 1008
0x3f, 0x00, //0x000000aa .word 63
0xf0, 0x03, //0x000000ac .word 1008
0x3f, 0x00, //0x000000ae .word 63
0xf0, 0x03, //0x000000b0 .word 1008
0x3f, 0x00, //0x000000b2 .word 63
0xf0, 0x03, //0x000000b4 .word 1008
0x3f, 0x00, //0x000000b6 .word 63
0xf0, 0x03, //0x000000b8 .word 1008
0x3f, 0x00, //0x000000ba .word 63
0xf0, 0x03, //0x000000bc .word 1008
0x3f, 0x00, //0x000000be .word 63
//0x000000c0 LCPI0_6
0x1a, 0x1a, 0x1a, 0x1a, 0x1a, 0x1a, 0x1a, 0x1a, 0x1a, 0x1a, 0x1a, 0x1a, 0x1a, 0x1a, 0x1a, 0x1a, //0x000000c0 QUAD $0x1a1a1a1a1a1a1a1a; QUAD $0x1a1a1a1a1a1a1a1a // .space 16, '\x1a\x1a\x1a\x1a\x1a\x1a\x1a\x1a\x1a\x1a\x1a\x1a\x1a\x1a\x1a\x1a'
0x1a, 0x1a, 0x1a, 0x1a, 0x1a, 0x1a, 0x1a, 0x1a, 0x1a, 0x1a, 0x1a, 0x1a, 0x1a, 0x1a, 0x1a, 0x1a, //0x000000d0 QUAD $0x1a1a1a1a1a1a1a1a; QUAD $0x1a1a1a1a1a1a1a1a // .space 16, '\x1a\x1a\x1a\x1a\x1a\x1a\x1a\x1a\x1a\x1a\x1a\x1a\x1a\x1a\x1a\x1a'
//0x000000e0 LCPI0_7
0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, //0x000000e0 QUAD $0x3333333333333333; QUAD $0x3333333333333333 // .space 16, '3333333333333333'
0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, //0x000000f0 QUAD $0x3333333333333333; QUAD $0x3333333333333333 // .space 16, '3333333333333333'
//0x00000100 LCPI0_8
0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, //0x00000100 QUAD $0x0d0d0d0d0d0d0d0d; QUAD $0x0d0d0d0d0d0d0d0d // .space 16, '\r\r\r\r\r\r\r\r\r\r\r\r\r\r\r\r'
0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, 0x0d, //0x00000110 QUAD $0x0d0d0d0d0d0d0d0d; QUAD $0x0d0d0d0d0d0d0d0d // .space 16, '\r\r\r\r\r\r\r\r\r\r\r\r\r\r\r\r'
//0x00000120 .p2align 4, 0x90
//0x00000120 _b64encode
0x55, //0x00000120 pushq %rbp
0x48, 0x89, 0xe5, //0x00000121 movq %rsp, %rbp
0x41, 0x57, //0x00000124 pushq %r15
0x41, 0x56, //0x00000126 pushq %r14
0x41, 0x54, //0x00000128 pushq %r12
0x53, //0x0000012a pushq %rbx
0x4c, 0x8b, 0x4e, 0x08, //0x0000012b movq $8(%rsi), %r9
0x4d, 0x85, 0xc9, //0x0000012f testq %r9, %r9
0x0f, 0x84, 0x11, 0x03, 0x00, 0x00, //0x00000132 je LBB0_26
0x4c, 0x8b, 0x26, //0x00000138 movq (%rsi), %r12
0x4c, 0x8b, 0x07, //0x0000013b movq (%rdi), %r8
0x4d, 0x01, 0xe1, //0x0000013e addq %r12, %r9
0x49, 0x8d, 0x71, 0xe4, //0x00000141 leaq $-28(%r9), %rsi
0x48, 0x8d, 0x0d, 0x14, 0x03, 0x00, 0x00, //0x00000145 leaq $788(%rip), %rcx /* _TabEncodeCharsetStd+0(%rip) */
0x4c, 0x8d, 0x15, 0x4d, 0x03, 0x00, 0x00, //0x0000014c leaq $845(%rip), %r10 /* _TabEncodeCharsetURL+0(%rip) */
0xf6, 0xc2, 0x01, //0x00000153 testb $1, %dl
0x4c, 0x0f, 0x44, 0xd1, //0x00000156 cmoveq %rcx, %r10
0x0f, 0x84, 0x30, 0x02, 0x00, 0x00, //0x0000015a je LBB0_2
0xc5, 0xfe, 0x6f, 0x05, 0xb8, 0xfe, 0xff, 0xff, //0x00000160 vmovdqu $-328(%rip), %ymm0 /* LCPI0_1+0(%rip) */
0x4c, 0x03, 0x47, 0x08, //0x00000168 addq $8(%rdi), %r8
0x4c, 0x39, 0xe6, //0x0000016c cmpq %r12, %rsi
0x0f, 0x82, 0x30, 0x02, 0x00, 0x00, //0x0000016f jb LBB0_5
//0x00000175 LBB0_6
0xc5, 0xfe, 0x6f, 0x0d, 0xc3, 0xfe, 0xff, 0xff, //0x00000175 vmovdqu $-317(%rip), %ymm1 /* LCPI0_2+0(%rip) */
0xc5, 0xfe, 0x6f, 0x15, 0xdb, 0xfe, 0xff, 0xff, //0x0000017d vmovdqu $-293(%rip), %ymm2 /* LCPI0_3+0(%rip) */
0xc5, 0xfe, 0x6f, 0x1d, 0xf3, 0xfe, 0xff, 0xff, //0x00000185 vmovdqu $-269(%rip), %ymm3 /* LCPI0_4+0(%rip) */
0xc5, 0xfe, 0x6f, 0x25, 0x0b, 0xff, 0xff, 0xff, //0x0000018d vmovdqu $-245(%rip), %ymm4 /* LCPI0_5+0(%rip) */
0xc5, 0xfe, 0x6f, 0x2d, 0x23, 0xff, 0xff, 0xff, //0x00000195 vmovdqu $-221(%rip), %ymm5 /* LCPI0_6+0(%rip) */
0xc5, 0xfe, 0x6f, 0x35, 0x3b, 0xff, 0xff, 0xff, //0x0000019d vmovdqu $-197(%rip), %ymm6 /* LCPI0_7+0(%rip) */
0xc5, 0xfe, 0x6f, 0x3d, 0x53, 0xff, 0xff, 0xff, //0x000001a5 vmovdqu $-173(%rip), %ymm7 /* LCPI0_8+0(%rip) */
0x4d, 0x89, 0xc6, //0x000001ad movq %r8, %r14
//0x000001b0 .p2align 4, 0x90
//0x000001b0 LBB0_7
0xc4, 0x41, 0x7a, 0x6f, 0x04, 0x24, //0x000001b0 vmovdqu (%r12), %xmm8
0xc4, 0x43, 0x3d, 0x38, 0x44, 0x24, 0x0c, 0x01, //0x000001b6 vinserti128 $1, $12(%r12), %ymm8, %ymm8
0xc4, 0x62, 0x3d, 0x00, 0xc1, //0x000001be vpshufb %ymm1, %ymm8, %ymm8
0xc5, 0x3d, 0xdb, 0xca, //0x000001c3 vpand %ymm2, %ymm8, %ymm9
0xc5, 0x35, 0xe4, 0xcb, //0x000001c7 vpmulhuw %ymm3, %ymm9, %ymm9
0xc5, 0x3d, 0xdb, 0xc4, //0x000001cb vpand %ymm4, %ymm8, %ymm8
0xc4, 0xc1, 0x2d, 0x71, 0xf0, 0x08, //0x000001cf vpsllw $8, %ymm8, %ymm10
0xc4, 0xc1, 0x3d, 0x71, 0xf0, 0x04, //0x000001d5 vpsllw $4, %ymm8, %ymm8
0xc4, 0x43, 0x3d, 0x0e, 0xc2, 0xaa, //0x000001db vpblendw $170, %ymm10, %ymm8, %ymm8
0xc4, 0x41, 0x3d, 0xeb, 0xc1, //0x000001e1 vpor %ymm9, %ymm8, %ymm8
0xc4, 0x41, 0x55, 0x64, 0xc8, //0x000001e6 vpcmpgtb %ymm8, %ymm5, %ymm9
0xc5, 0x35, 0xdb, 0xcf, //0x000001eb vpand %ymm7, %ymm9, %ymm9
0xc5, 0x3d, 0xd8, 0xd6, //0x000001ef vpsubusb %ymm6, %ymm8, %ymm10
0xc4, 0x41, 0x35, 0xeb, 0xca, //0x000001f3 vpor %ymm10, %ymm9, %ymm9
0xc4, 0x42, 0x7d, 0x00, 0xc9, //0x000001f8 vpshufb %ymm9, %ymm0, %ymm9
0xc4, 0x41, 0x35, 0xfc, 0xc0, //0x000001fd vpaddb %ymm8, %ymm9, %ymm8
0xc4, 0x41, 0x7e, 0x7f, 0x06, //0x00000202 vmovdqu %ymm8, (%r14)
0x49, 0x83, 0xc6, 0x20, //0x00000207 addq $32, %r14
0x49, 0x83, 0xc4, 0x18, //0x0000020b addq $24, %r12
0x49, 0x39, 0xf4, //0x0000020f cmpq %rsi, %r12
0x0f, 0x86, 0x98, 0xff, 0xff, 0xff, //0x00000212 jbe LBB0_7
0x49, 0x8d, 0x71, 0xe8, //0x00000218 leaq $-24(%r9), %rsi
0x49, 0x39, 0xf4, //0x0000021c cmpq %rsi, %r12
0x0f, 0x87, 0x83, 0x00, 0x00, 0x00, //0x0000021f ja LBB0_10
//0x00000225 LBB0_9
0xc4, 0xc1, 0x7a, 0x6f, 0x0c, 0x24, //0x00000225 vmovdqu (%r12), %xmm1
0xc4, 0xc1, 0x7a, 0x6f, 0x54, 0x24, 0x08, //0x0000022b vmovdqu $8(%r12), %xmm2
0xc5, 0xe9, 0x73, 0xda, 0x04, //0x00000232 vpsrldq $4, %xmm2, %xmm2
0xc4, 0xe3, 0x75, 0x38, 0xca, 0x01, //0x00000237 vinserti128 $1, %xmm2, %ymm1, %ymm1
0xc4, 0xe2, 0x75, 0x00, 0x0d, 0xfa, 0xfd, 0xff, 0xff, //0x0000023d vpshufb $-518(%rip), %ymm1, %ymm1 /* LCPI0_2+0(%rip) */
0xc5, 0xf5, 0xdb, 0x15, 0x12, 0xfe, 0xff, 0xff, //0x00000246 vpand $-494(%rip), %ymm1, %ymm2 /* LCPI0_3+0(%rip) */
0xc5, 0xed, 0xe4, 0x15, 0x2a, 0xfe, 0xff, 0xff, //0x0000024e vpmulhuw $-470(%rip), %ymm2, %ymm2 /* LCPI0_4+0(%rip) */
0xc5, 0xf5, 0xdb, 0x0d, 0x42, 0xfe, 0xff, 0xff, //0x00000256 vpand $-446(%rip), %ymm1, %ymm1 /* LCPI0_5+0(%rip) */
0xc5, 0xe5, 0x71, 0xf1, 0x08, //0x0000025e vpsllw $8, %ymm1, %ymm3
0xc5, 0xf5, 0x71, 0xf1, 0x04, //0x00000263 vpsllw $4, %ymm1, %ymm1
0xc4, 0xe3, 0x75, 0x0e, 0xcb, 0xaa, //0x00000268 vpblendw $170, %ymm3, %ymm1, %ymm1
0xc5, 0xf5, 0xeb, 0xca, //0x0000026e vpor %ymm2, %ymm1, %ymm1
0xc5, 0xfe, 0x6f, 0x15, 0x46, 0xfe, 0xff, 0xff, //0x00000272 vmovdqu $-442(%rip), %ymm2 /* LCPI0_6+0(%rip) */
0xc5, 0xed, 0x64, 0xd1, //0x0000027a vpcmpgtb %ymm1, %ymm2, %ymm2
0xc5, 0xf5, 0xd8, 0x1d, 0x5a, 0xfe, 0xff, 0xff, //0x0000027e vpsubusb $-422(%rip), %ymm1, %ymm3 /* LCPI0_7+0(%rip) */
0xc5, 0xed, 0xdb, 0x15, 0x72, 0xfe, 0xff, 0xff, //0x00000286 vpand $-398(%rip), %ymm2, %ymm2 /* LCPI0_8+0(%rip) */
0xc5, 0xed, 0xeb, 0xd3, //0x0000028e vpor %ymm3, %ymm2, %ymm2
0xc4, 0xe2, 0x7d, 0x00, 0xc2, //0x00000292 vpshufb %ymm2, %ymm0, %ymm0
0xc5, 0xfd, 0xfc, 0xc1, //0x00000297 vpaddb %ymm1, %ymm0, %ymm0
0xc4, 0xc1, 0x7e, 0x7f, 0x06, //0x0000029b vmovdqu %ymm0, (%r14)
0x49, 0x83, 0xc6, 0x20, //0x000002a0 addq $32, %r14
0x49, 0x83, 0xc4, 0x18, //0x000002a4 addq $24, %r12
//0x000002a8 LBB0_10
0x4d, 0x39, 0xcc, //0x000002a8 cmpq %r9, %r12
0x0f, 0x84, 0x91, 0x01, 0x00, 0x00, //0x000002ab je LBB0_25
0x4d, 0x8d, 0x59, 0xfc, //0x000002b1 leaq $-4(%r9), %r11
0x4d, 0x39, 0xdc, //0x000002b5 cmpq %r11, %r12
0x0f, 0x87, 0x59, 0x00, 0x00, 0x00, //0x000002b8 ja LBB0_14
0x90, 0x90, //0x000002be .p2align 4, 0x90
//0x000002c0 LBB0_12
0x41, 0x8b, 0x34, 0x24, //0x000002c0 movl (%r12), %esi
0x0f, 0xce, //0x000002c4 bswapl %esi
0x49, 0x89, 0xf7, //0x000002c6 movq %rsi, %r15
0x49, 0xc1, 0xef, 0x1a, //0x000002c9 shrq $26, %r15
0x89, 0xf1, //0x000002cd movl %esi, %ecx
0xc1, 0xe9, 0x14, //0x000002cf shrl $20, %ecx
0x83, 0xe1, 0x3f, //0x000002d2 andl $63, %ecx
0x89, 0xf3, //0x000002d5 movl %esi, %ebx
0xc1, 0xeb, 0x0e, //0x000002d7 shrl $14, %ebx
0x83, 0xe3, 0x3f, //0x000002da andl $63, %ebx
0xc1, 0xee, 0x08, //0x000002dd shrl $8, %esi
0x83, 0xe6, 0x3f, //0x000002e0 andl $63, %esi
0x49, 0x83, 0xc4, 0x03, //0x000002e3 addq $3, %r12
0x43, 0x0f, 0xb6, 0x04, 0x3a, //0x000002e7 movzbl (%r10,%r15), %eax
0x41, 0x88, 0x06, //0x000002ec movb %al, (%r14)
0x41, 0x0f, 0xb6, 0x04, 0x0a, //0x000002ef movzbl (%r10,%rcx), %eax
0x41, 0x88, 0x46, 0x01, //0x000002f4 movb %al, $1(%r14)
0x41, 0x0f, 0xb6, 0x04, 0x1a, //0x000002f8 movzbl (%r10,%rbx), %eax
0x41, 0x88, 0x46, 0x02, //0x000002fd movb %al, $2(%r14)
0x41, 0x0f, 0xb6, 0x04, 0x32, //0x00000301 movzbl (%r10,%rsi), %eax
0x41, 0x88, 0x46, 0x03, //0x00000306 movb %al, $3(%r14)
0x49, 0x83, 0xc6, 0x04, //0x0000030a addq $4, %r14
0x4d, 0x39, 0xdc, //0x0000030e cmpq %r11, %r12
0x0f, 0x86, 0xa9, 0xff, 0xff, 0xff, //0x00000311 jbe LBB0_12
//0x00000317 LBB0_14
0x4d, 0x29, 0xe1, //0x00000317 subq %r12, %r9
0x45, 0x0f, 0xb6, 0x1c, 0x24, //0x0000031a movzbl (%r12), %r11d
0x49, 0x83, 0xf9, 0x01, //0x0000031f cmpq $1, %r9
0x0f, 0x84, 0xd5, 0x00, 0x00, 0x00, //0x00000323 je LBB0_21
0x4c, 0x89, 0xde, //0x00000329 movq %r11, %rsi
0x48, 0xc1, 0xe6, 0x10, //0x0000032c shlq $16, %rsi
0x49, 0x83, 0xf9, 0x02, //0x00000330 cmpq $2, %r9
0x0f, 0x84, 0x80, 0x00, 0x00, 0x00, //0x00000334 je LBB0_18
0x49, 0x83, 0xf9, 0x03, //0x0000033a cmpq $3, %r9
0x0f, 0x85, 0xfe, 0x00, 0x00, 0x00, //0x0000033e jne LBB0_25
0x41, 0x0f, 0xb6, 0x54, 0x24, 0x02, //0x00000344 movzbl $2(%r12), %edx
0x09, 0xd6, //0x0000034a orl %edx, %esi
0x41, 0x0f, 0xb6, 0x44, 0x24, 0x01, //0x0000034c movzbl $1(%r12), %eax
0xc1, 0xe0, 0x08, //0x00000352 shll $8, %eax
0x09, 0xf0, //0x00000355 orl %esi, %eax
0x49, 0xc1, 0xeb, 0x02, //0x00000357 shrq $2, %r11
0x43, 0x8a, 0x0c, 0x1a, //0x0000035b movb (%r10,%r11), %cl
0x41, 0x88, 0x0e, //0x0000035f movb %cl, (%r14)
0x89, 0xc1, //0x00000362 movl %eax, %ecx
0xc1, 0xe9, 0x0c, //0x00000364 shrl $12, %ecx
0x83, 0xe1, 0x3f, //0x00000367 andl $63, %ecx
0x41, 0x8a, 0x0c, 0x0a, //0x0000036a movb (%r10,%rcx), %cl
0x41, 0x88, 0x4e, 0x01, //0x0000036e movb %cl, $1(%r14)
0xc1, 0xe8, 0x06, //0x00000372 shrl $6, %eax
0x83, 0xe0, 0x3f, //0x00000375 andl $63, %eax
0x41, 0x8a, 0x04, 0x02, //0x00000378 movb (%r10,%rax), %al
0x41, 0x88, 0x46, 0x02, //0x0000037c movb %al, $2(%r14)
0x83, 0xe2, 0x3f, //0x00000380 andl $63, %edx
0x41, 0x8a, 0x04, 0x12, //0x00000383 movb (%r10,%rdx), %al
0x41, 0x88, 0x46, 0x03, //0x00000387 movb %al, $3(%r14)
0xe9, 0x9c, 0x00, 0x00, 0x00, //0x0000038b jmp LBB0_24
//0x00000390 LBB0_2
0xc5, 0xfe, 0x6f, 0x05, 0x68, 0xfc, 0xff, 0xff, //0x00000390 vmovdqu $-920(%rip), %ymm0 /* LCPI0_0+0(%rip) */
0x4c, 0x03, 0x47, 0x08, //0x00000398 addq $8(%rdi), %r8
0x4c, 0x39, 0xe6, //0x0000039c cmpq %r12, %rsi
0x0f, 0x83, 0xd0, 0xfd, 0xff, 0xff, //0x0000039f jae LBB0_6
//0x000003a5 LBB0_5
0x4d, 0x89, 0xc6, //0x000003a5 movq %r8, %r14
0x49, 0x8d, 0x71, 0xe8, //0x000003a8 leaq $-24(%r9), %rsi
0x49, 0x39, 0xf4, //0x000003ac cmpq %rsi, %r12
0x0f, 0x86, 0x70, 0xfe, 0xff, 0xff, //0x000003af jbe LBB0_9
0xe9, 0xee, 0xfe, 0xff, 0xff, //0x000003b5 jmp LBB0_10
//0x000003ba LBB0_18
0x41, 0x0f, 0xb6, 0x44, 0x24, 0x01, //0x000003ba movzbl $1(%r12), %eax
0x89, 0xc1, //0x000003c0 movl %eax, %ecx
0xc1, 0xe1, 0x08, //0x000003c2 shll $8, %ecx
0x09, 0xf1, //0x000003c5 orl %esi, %ecx
0x49, 0xc1, 0xeb, 0x02, //0x000003c7 shrq $2, %r11
0x43, 0x8a, 0x1c, 0x1a, //0x000003cb movb (%r10,%r11), %bl
0x41, 0x88, 0x1e, //0x000003cf movb %bl, (%r14)
0xc1, 0xe9, 0x0c, //0x000003d2 shrl $12, %ecx
0x83, 0xe1, 0x3f, //0x000003d5 andl $63, %ecx
0x41, 0x8a, 0x0c, 0x0a, //0x000003d8 movb (%r10,%rcx), %cl
0x41, 0x88, 0x4e, 0x01, //0x000003dc movb %cl, $1(%r14)
0x83, 0xe0, 0x0f, //0x000003e0 andl $15, %eax
0x41, 0x8a, 0x04, 0x82, //0x000003e3 movb (%r10,%rax,4), %al
0x41, 0x88, 0x46, 0x02, //0x000003e7 movb %al, $2(%r14)
0xf6, 0xc2, 0x02, //0x000003eb testb $2, %dl
0x0f, 0x85, 0x41, 0x00, 0x00, 0x00, //0x000003ee jne LBB0_19
0x41, 0xc6, 0x46, 0x03, 0x3d, //0x000003f4 movb $61, $3(%r14)
0xe9, 0x2e, 0x00, 0x00, 0x00, //0x000003f9 jmp LBB0_24
//0x000003fe LBB0_21
0x4c, 0x89, 0xd8, //0x000003fe movq %r11, %rax
0x48, 0xc1, 0xe8, 0x02, //0x00000401 shrq $2, %rax
0x41, 0x8a, 0x04, 0x02, //0x00000405 movb (%r10,%rax), %al
0x41, 0x88, 0x06, //0x00000409 movb %al, (%r14)
0x41, 0xc1, 0xe3, 0x04, //0x0000040c shll $4, %r11d
0x41, 0x83, 0xe3, 0x30, //0x00000410 andl $48, %r11d
0x43, 0x8a, 0x04, 0x1a, //0x00000414 movb (%r10,%r11), %al
0x41, 0x88, 0x46, 0x01, //0x00000418 movb %al, $1(%r14)
0xf6, 0xc2, 0x02, //0x0000041c testb $2, %dl
0x0f, 0x85, 0x19, 0x00, 0x00, 0x00, //0x0000041f jne LBB0_22
0x66, 0x41, 0xc7, 0x46, 0x02, 0x3d, 0x3d, //0x00000425 movw $15677, $2(%r14)
//0x0000042c LBB0_24
0x49, 0x83, 0xc6, 0x04, //0x0000042c addq $4, %r14
0xe9, 0x0d, 0x00, 0x00, 0x00, //0x00000430 jmp LBB0_25
//0x00000435 LBB0_19
0x49, 0x83, 0xc6, 0x03, //0x00000435 addq $3, %r14
0xe9, 0x04, 0x00, 0x00, 0x00, //0x00000439 jmp LBB0_25
//0x0000043e LBB0_22
0x49, 0x83, 0xc6, 0x02, //0x0000043e addq $2, %r14
//0x00000442 LBB0_25
0x4d, 0x29, 0xc6, //0x00000442 subq %r8, %r14
0x4c, 0x01, 0x77, 0x08, //0x00000445 addq %r14, $8(%rdi)
//0x00000449 LBB0_26
0x5b, //0x00000449 popq %rbx
0x41, 0x5c, //0x0000044a popq %r12
0x41, 0x5e, //0x0000044c popq %r14
0x41, 0x5f, //0x0000044e popq %r15
0x5d, //0x00000450 popq %rbp
0xc5, 0xf8, 0x77, //0x00000451 vzeroupper
0xc3, //0x00000454 retq
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //0x00000455 .p2align 4, 0x00
//0x00000460 _TabEncodeCharsetStd
0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50, //0x00000460 QUAD $0x4847464544434241; QUAD $0x504f4e4d4c4b4a49 // .ascii 16, 'ABCDEFGHIJKLMNOP'
0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, //0x00000470 QUAD $0x5857565554535251; QUAD $0x6665646362615a59 // .ascii 16, 'QRSTUVWXYZabcdef'
0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, //0x00000480 QUAD $0x6e6d6c6b6a696867; QUAD $0x767574737271706f // .ascii 16, 'ghijklmnopqrstuv'
0x77, 0x78, 0x79, 0x7a, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x2b, 0x2f, //0x00000490 QUAD $0x333231307a797877; QUAD $0x2f2b393837363534 // .ascii 16, 'wxyz0123456789+/'
//0x000004a0 .p2align 4, 0x00
//0x000004a0 _TabEncodeCharsetURL
0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50, //0x000004a0 QUAD $0x4847464544434241; QUAD $0x504f4e4d4c4b4a49 // .ascii 16, 'ABCDEFGHIJKLMNOP'
0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, //0x000004b0 QUAD $0x5857565554535251; QUAD $0x6665646362615a59 // .ascii 16, 'QRSTUVWXYZabcdef'
0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, //0x000004c0 QUAD $0x6e6d6c6b6a696867; QUAD $0x767574737271706f // .ascii 16, 'ghijklmnopqrstuv'
0x77, 0x78, 0x79, 0x7a, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x2d, 0x5f, //0x000004d0 QUAD $0x333231307a797877; QUAD $0x5f2d393837363534 // .ascii 16, 'wxyz0123456789-_'
}
| go | Apache-2.0 | b3b4703e958c25d54c4d48138d9e80ae32fadac3 | 2026-01-07T09:44:30.792320Z | false |
kubev2v/forklift | https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/github.com/cloudwego/base64x/internal/native/avx2/b64decode_subr.go | vendor/github.com/cloudwego/base64x/internal/native/avx2/b64decode_subr.go | // +build !noasm !appengine
// Code generated by asm2asm, DO NOT EDIT.
package avx2
import (
`github.com/bytedance/sonic/loader`
)
const (
_entry__b64decode = 464
)
const (
_stack__b64decode = 136
)
const (
_size__b64decode = 13488
)
var (
_pcsp__b64decode = [][2]uint32{
{0x1, 0},
{0x6, 8},
{0x8, 16},
{0xa, 24},
{0xc, 32},
{0xd, 40},
{0x11, 48},
{0x349e, 136},
{0x349f, 48},
{0x34a1, 40},
{0x34a3, 32},
{0x34a5, 24},
{0x34a7, 16},
{0x34a8, 8},
{0x34b0, 0},
}
)
var _cfunc_b64decode = []loader.CFunc{
{"_b64decode_entry", 0, _entry__b64decode, 0, nil},
{"_b64decode", _entry__b64decode, _size__b64decode, _stack__b64decode, _pcsp__b64decode},
}
| go | Apache-2.0 | b3b4703e958c25d54c4d48138d9e80ae32fadac3 | 2026-01-07T09:44:30.792320Z | false |
kubev2v/forklift | https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/github.com/cloudwego/base64x/internal/native/avx2/b64encode_subr.go | vendor/github.com/cloudwego/base64x/internal/native/avx2/b64encode_subr.go | // +build !noasm !appengine
// Code generated by asm2asm, DO NOT EDIT.
package avx2
import (
`github.com/bytedance/sonic/loader`
)
const (
_entry__b64encode = 288
)
const (
_stack__b64encode = 40
)
const (
_size__b64encode = 832
)
var (
_pcsp__b64encode = [][2]uint32{
{0x1, 0},
{0x6, 8},
{0x8, 16},
{0xa, 24},
{0xb, 32},
{0x32a, 40},
{0x32c, 32},
{0x32e, 24},
{0x330, 16},
{0x331, 8},
{0x340, 0},
}
)
var _cfunc_b64encode = []loader.CFunc{
{"_b64encode_entry", 0, _entry__b64encode, 0, nil},
{"_b64encode", _entry__b64encode, _size__b64encode, _stack__b64encode, _pcsp__b64encode},
}
| go | Apache-2.0 | b3b4703e958c25d54c4d48138d9e80ae32fadac3 | 2026-01-07T09:44:30.792320Z | false |
kubev2v/forklift | https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/github.com/cloudwego/base64x/internal/rt/fastmem.go | vendor/github.com/cloudwego/base64x/internal/rt/fastmem.go | /*
* Copyright 2021 ByteDance Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package rt
import (
"unsafe"
)
// NoEscape hides a pointer from escape analysis. NoEscape is
// the identity function but escape analysis doesn't think the
// output depends on the input. NoEscape is inlined and currently
// compiles down to zero instructions.
// USE CAREFULLY!
//go:nosplit
//goland:noinspection GoVetUnsafePointer
func NoEscape(p unsafe.Pointer) unsafe.Pointer {
x := uintptr(p)
return unsafe.Pointer(x ^ 0)
}
//go:nosplit
func MoreStack(size uintptr)
//go:nosplit
func Add(ptr unsafe.Pointer, off uintptr) unsafe.Pointer {
return unsafe.Pointer(uintptr(ptr) + off)
}
| go | Apache-2.0 | b3b4703e958c25d54c4d48138d9e80ae32fadac3 | 2026-01-07T09:44:30.792320Z | false |
kubev2v/forklift | https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/github.com/mattn/go-isatty/isatty_bsd.go | vendor/github.com/mattn/go-isatty/isatty_bsd.go | //go:build (darwin || freebsd || openbsd || netbsd || dragonfly || hurd) && !appengine && !tinygo
// +build darwin freebsd openbsd netbsd dragonfly hurd
// +build !appengine
// +build !tinygo
package isatty
import "golang.org/x/sys/unix"
// IsTerminal return true if the file descriptor is terminal.
func IsTerminal(fd uintptr) bool {
_, err := unix.IoctlGetTermios(int(fd), unix.TIOCGETA)
return err == nil
}
// IsCygwinTerminal return true if the file descriptor is a cygwin or msys2
// terminal. This is also always false on this environment.
func IsCygwinTerminal(fd uintptr) bool {
return false
}
| go | Apache-2.0 | b3b4703e958c25d54c4d48138d9e80ae32fadac3 | 2026-01-07T09:44:30.792320Z | false |
kubev2v/forklift | https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/github.com/mattn/go-isatty/isatty_windows.go | vendor/github.com/mattn/go-isatty/isatty_windows.go | //go:build windows && !appengine
// +build windows,!appengine
package isatty
import (
"errors"
"strings"
"syscall"
"unicode/utf16"
"unsafe"
)
const (
objectNameInfo uintptr = 1
fileNameInfo = 2
fileTypePipe = 3
)
var (
kernel32 = syscall.NewLazyDLL("kernel32.dll")
ntdll = syscall.NewLazyDLL("ntdll.dll")
procGetConsoleMode = kernel32.NewProc("GetConsoleMode")
procGetFileInformationByHandleEx = kernel32.NewProc("GetFileInformationByHandleEx")
procGetFileType = kernel32.NewProc("GetFileType")
procNtQueryObject = ntdll.NewProc("NtQueryObject")
)
func init() {
// Check if GetFileInformationByHandleEx is available.
if procGetFileInformationByHandleEx.Find() != nil {
procGetFileInformationByHandleEx = nil
}
}
// IsTerminal return true if the file descriptor is terminal.
func IsTerminal(fd uintptr) bool {
var st uint32
r, _, e := syscall.Syscall(procGetConsoleMode.Addr(), 2, fd, uintptr(unsafe.Pointer(&st)), 0)
return r != 0 && e == 0
}
// Check pipe name is used for cygwin/msys2 pty.
// Cygwin/MSYS2 PTY has a name like:
// \{cygwin,msys}-XXXXXXXXXXXXXXXX-ptyN-{from,to}-master
func isCygwinPipeName(name string) bool {
token := strings.Split(name, "-")
if len(token) < 5 {
return false
}
if token[0] != `\msys` &&
token[0] != `\cygwin` &&
token[0] != `\Device\NamedPipe\msys` &&
token[0] != `\Device\NamedPipe\cygwin` {
return false
}
if token[1] == "" {
return false
}
if !strings.HasPrefix(token[2], "pty") {
return false
}
if token[3] != `from` && token[3] != `to` {
return false
}
if token[4] != "master" {
return false
}
return true
}
// getFileNameByHandle use the undocomented ntdll NtQueryObject to get file full name from file handler
// since GetFileInformationByHandleEx is not available under windows Vista and still some old fashion
// guys are using Windows XP, this is a workaround for those guys, it will also work on system from
// Windows vista to 10
// see https://stackoverflow.com/a/18792477 for details
func getFileNameByHandle(fd uintptr) (string, error) {
if procNtQueryObject == nil {
return "", errors.New("ntdll.dll: NtQueryObject not supported")
}
var buf [4 + syscall.MAX_PATH]uint16
var result int
r, _, e := syscall.Syscall6(procNtQueryObject.Addr(), 5,
fd, objectNameInfo, uintptr(unsafe.Pointer(&buf)), uintptr(2*len(buf)), uintptr(unsafe.Pointer(&result)), 0)
if r != 0 {
return "", e
}
return string(utf16.Decode(buf[4 : 4+buf[0]/2])), nil
}
// IsCygwinTerminal() return true if the file descriptor is a cygwin or msys2
// terminal.
func IsCygwinTerminal(fd uintptr) bool {
if procGetFileInformationByHandleEx == nil {
name, err := getFileNameByHandle(fd)
if err != nil {
return false
}
return isCygwinPipeName(name)
}
// Cygwin/msys's pty is a pipe.
ft, _, e := syscall.Syscall(procGetFileType.Addr(), 1, fd, 0, 0)
if ft != fileTypePipe || e != 0 {
return false
}
var buf [2 + syscall.MAX_PATH]uint16
r, _, e := syscall.Syscall6(procGetFileInformationByHandleEx.Addr(),
4, fd, fileNameInfo, uintptr(unsafe.Pointer(&buf)),
uintptr(len(buf)*2), 0, 0)
if r == 0 || e != 0 {
return false
}
l := *(*uint32)(unsafe.Pointer(&buf))
return isCygwinPipeName(string(utf16.Decode(buf[2 : 2+l/2])))
}
| go | Apache-2.0 | b3b4703e958c25d54c4d48138d9e80ae32fadac3 | 2026-01-07T09:44:30.792320Z | false |
kubev2v/forklift | https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/github.com/mattn/go-isatty/isatty_solaris.go | vendor/github.com/mattn/go-isatty/isatty_solaris.go | //go:build solaris && !appengine
// +build solaris,!appengine
package isatty
import (
"golang.org/x/sys/unix"
)
// IsTerminal returns true if the given file descriptor is a terminal.
// see: https://src.illumos.org/source/xref/illumos-gate/usr/src/lib/libc/port/gen/isatty.c
func IsTerminal(fd uintptr) bool {
_, err := unix.IoctlGetTermio(int(fd), unix.TCGETA)
return err == nil
}
// IsCygwinTerminal return true if the file descriptor is a cygwin or msys2
// terminal. This is also always false on this environment.
func IsCygwinTerminal(fd uintptr) bool {
return false
}
| go | Apache-2.0 | b3b4703e958c25d54c4d48138d9e80ae32fadac3 | 2026-01-07T09:44:30.792320Z | false |
kubev2v/forklift | https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/github.com/mattn/go-isatty/isatty_plan9.go | vendor/github.com/mattn/go-isatty/isatty_plan9.go | //go:build plan9
// +build plan9
package isatty
import (
"syscall"
)
// IsTerminal returns true if the given file descriptor is a terminal.
func IsTerminal(fd uintptr) bool {
path, err := syscall.Fd2path(int(fd))
if err != nil {
return false
}
return path == "/dev/cons" || path == "/mnt/term/dev/cons"
}
// IsCygwinTerminal return true if the file descriptor is a cygwin or msys2
// terminal. This is also always false on this environment.
func IsCygwinTerminal(fd uintptr) bool {
return false
}
| go | Apache-2.0 | b3b4703e958c25d54c4d48138d9e80ae32fadac3 | 2026-01-07T09:44:30.792320Z | false |
kubev2v/forklift | https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/github.com/mattn/go-isatty/isatty_others.go | vendor/github.com/mattn/go-isatty/isatty_others.go | //go:build (appengine || js || nacl || tinygo || wasm) && !windows
// +build appengine js nacl tinygo wasm
// +build !windows
package isatty
// IsTerminal returns true if the file descriptor is terminal which
// is always false on js and appengine classic which is a sandboxed PaaS.
func IsTerminal(fd uintptr) bool {
return false
}
// IsCygwinTerminal() return true if the file descriptor is a cygwin or msys2
// terminal. This is also always false on this environment.
func IsCygwinTerminal(fd uintptr) bool {
return false
}
| go | Apache-2.0 | b3b4703e958c25d54c4d48138d9e80ae32fadac3 | 2026-01-07T09:44:30.792320Z | false |
kubev2v/forklift | https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/github.com/mattn/go-isatty/doc.go | vendor/github.com/mattn/go-isatty/doc.go | // Package isatty implements interface to isatty
package isatty
| go | Apache-2.0 | b3b4703e958c25d54c4d48138d9e80ae32fadac3 | 2026-01-07T09:44:30.792320Z | false |
kubev2v/forklift | https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/github.com/mattn/go-isatty/isatty_tcgets.go | vendor/github.com/mattn/go-isatty/isatty_tcgets.go | //go:build (linux || aix || zos) && !appengine && !tinygo
// +build linux aix zos
// +build !appengine
// +build !tinygo
package isatty
import "golang.org/x/sys/unix"
// IsTerminal return true if the file descriptor is terminal.
func IsTerminal(fd uintptr) bool {
_, err := unix.IoctlGetTermios(int(fd), unix.TCGETS)
return err == nil
}
// IsCygwinTerminal return true if the file descriptor is a cygwin or msys2
// terminal. This is also always false on this environment.
func IsCygwinTerminal(fd uintptr) bool {
return false
}
| go | Apache-2.0 | b3b4703e958c25d54c4d48138d9e80ae32fadac3 | 2026-01-07T09:44:30.792320Z | false |
kubev2v/forklift | https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/github.com/onsi/gomega/matchers.go | vendor/github.com/onsi/gomega/matchers.go | package gomega
import (
"fmt"
"time"
"github.com/google/go-cmp/cmp"
"github.com/onsi/gomega/matchers"
"github.com/onsi/gomega/types"
)
// Equal uses reflect.DeepEqual to compare actual with expected. Equal is strict about
// types when performing comparisons.
// It is an error for both actual and expected to be nil. Use BeNil() instead.
func Equal(expected interface{}) types.GomegaMatcher {
return &matchers.EqualMatcher{
Expected: expected,
}
}
// BeEquivalentTo is more lax than Equal, allowing equality between different types.
// This is done by converting actual to have the type of expected before
// attempting equality with reflect.DeepEqual.
// It is an error for actual and expected to be nil. Use BeNil() instead.
func BeEquivalentTo(expected interface{}) types.GomegaMatcher {
return &matchers.BeEquivalentToMatcher{
Expected: expected,
}
}
// BeComparableTo uses gocmp.Equal from github.com/google/go-cmp (instead of reflect.DeepEqual) to perform a deep comparison.
// You can pass cmp.Option as options.
// It is an error for actual and expected to be nil. Use BeNil() instead.
func BeComparableTo(expected interface{}, opts ...cmp.Option) types.GomegaMatcher {
return &matchers.BeComparableToMatcher{
Expected: expected,
Options: opts,
}
}
// BeIdenticalTo uses the == operator to compare actual with expected.
// BeIdenticalTo is strict about types when performing comparisons.
// It is an error for both actual and expected to be nil. Use BeNil() instead.
func BeIdenticalTo(expected interface{}) types.GomegaMatcher {
return &matchers.BeIdenticalToMatcher{
Expected: expected,
}
}
// BeNil succeeds if actual is nil
func BeNil() types.GomegaMatcher {
return &matchers.BeNilMatcher{}
}
// BeTrue succeeds if actual is true
//
// In general, it's better to use `BeTrueBecause(reason)` to provide a more useful error message if a true check fails.
func BeTrue() types.GomegaMatcher {
return &matchers.BeTrueMatcher{}
}
// BeFalse succeeds if actual is false
//
// In general, it's better to use `BeFalseBecause(reason)` to provide a more useful error message if a false check fails.
func BeFalse() types.GomegaMatcher {
return &matchers.BeFalseMatcher{}
}
// BeTrueBecause succeeds if actual is true and displays the provided reason if it is false
// fmt.Sprintf is used to render the reason
func BeTrueBecause(format string, args ...any) types.GomegaMatcher {
return &matchers.BeTrueMatcher{Reason: fmt.Sprintf(format, args...)}
}
// BeFalseBecause succeeds if actual is false and displays the provided reason if it is true.
// fmt.Sprintf is used to render the reason
func BeFalseBecause(format string, args ...any) types.GomegaMatcher {
return &matchers.BeFalseMatcher{Reason: fmt.Sprintf(format, args...)}
}
// HaveOccurred succeeds if actual is a non-nil error
// The typical Go error checking pattern looks like:
//
// err := SomethingThatMightFail()
// Expect(err).ShouldNot(HaveOccurred())
func HaveOccurred() types.GomegaMatcher {
return &matchers.HaveOccurredMatcher{}
}
// Succeed passes if actual is a nil error
// Succeed is intended to be used with functions that return a single error value. Instead of
//
// err := SomethingThatMightFail()
// Expect(err).ShouldNot(HaveOccurred())
//
// You can write:
//
// Expect(SomethingThatMightFail()).Should(Succeed())
//
// It is a mistake to use Succeed with a function that has multiple return values. Gomega's Ω and Expect
// functions automatically trigger failure if any return values after the first return value are non-zero/non-nil.
// This means that Ω(MultiReturnFunc()).ShouldNot(Succeed()) can never pass.
func Succeed() types.GomegaMatcher {
return &matchers.SucceedMatcher{}
}
// MatchError succeeds if actual is a non-nil error that matches the passed in
// string, error, function, or matcher.
//
// These are valid use-cases:
//
// When passed a string:
//
// Expect(err).To(MatchError("an error"))
//
// asserts that err.Error() == "an error"
//
// When passed an error:
//
// Expect(err).To(MatchError(SomeError))
//
// First checks if errors.Is(err, SomeError).
// If that fails then it checks if reflect.DeepEqual(err, SomeError) repeatedly for err and any errors wrapped by err
//
// When passed a matcher:
//
// Expect(err).To(MatchError(ContainSubstring("sprocket not found")))
//
// the matcher is passed err.Error(). In this case it asserts that err.Error() contains substring "sprocket not found"
//
// When passed a func(err) bool and a description:
//
// Expect(err).To(MatchError(os.IsNotExist, "IsNotExist"))
//
// the function is passed err and matches if the return value is true. The description is required to allow Gomega
// to print a useful error message.
//
// It is an error for err to be nil or an object that does not implement the
// Error interface
//
// The optional second argument is a description of the error function, if used. This is required when passing a function but is ignored in all other cases.
func MatchError(expected interface{}, functionErrorDescription ...any) types.GomegaMatcher {
return &matchers.MatchErrorMatcher{
Expected: expected,
FuncErrDescription: functionErrorDescription,
}
}
// BeClosed succeeds if actual is a closed channel.
// It is an error to pass a non-channel to BeClosed, it is also an error to pass nil
//
// In order to check whether or not the channel is closed, Gomega must try to read from the channel
// (even in the `ShouldNot(BeClosed())` case). You should keep this in mind if you wish to make subsequent assertions about
// values coming down the channel.
//
// Also, if you are testing that a *buffered* channel is closed you must first read all values out of the channel before
// asserting that it is closed (it is not possible to detect that a buffered-channel has been closed until all its buffered values are read).
//
// Finally, as a corollary: it is an error to check whether or not a send-only channel is closed.
func BeClosed() types.GomegaMatcher {
return &matchers.BeClosedMatcher{}
}
// Receive succeeds if there is a value to be received on actual.
// Actual must be a channel (and cannot be a send-only channel) -- anything else is an error.
//
// Receive returns immediately and never blocks:
//
// - If there is nothing on the channel `c` then Expect(c).Should(Receive()) will fail and Ω(c).ShouldNot(Receive()) will pass.
//
// - If the channel `c` is closed then Expect(c).Should(Receive()) will fail and Ω(c).ShouldNot(Receive()) will pass.
//
// - If there is something on the channel `c` ready to be read, then Expect(c).Should(Receive()) will pass and Ω(c).ShouldNot(Receive()) will fail.
//
// If you have a go-routine running in the background that will write to channel `c` you can:
//
// Eventually(c).Should(Receive())
//
// This will timeout if nothing gets sent to `c` (you can modify the timeout interval as you normally do with `Eventually`)
//
// A similar use-case is to assert that no go-routine writes to a channel (for a period of time). You can do this with `Consistently`:
//
// Consistently(c).ShouldNot(Receive())
//
// You can pass `Receive` a matcher. If you do so, it will match the received object against the matcher. For example:
//
// Expect(c).Should(Receive(Equal("foo")))
//
// When given a matcher, `Receive` will always fail if there is nothing to be received on the channel.
//
// Passing Receive a matcher is especially useful when paired with Eventually:
//
// Eventually(c).Should(Receive(ContainSubstring("bar")))
//
// will repeatedly attempt to pull values out of `c` until a value matching "bar" is received.
//
// Furthermore, if you want to have a reference to the value *sent* to the channel you can pass the `Receive` matcher a pointer to a variable of the appropriate type:
//
// var myThing thing
// Eventually(thingChan).Should(Receive(&myThing))
// Expect(myThing.Sprocket).Should(Equal("foo"))
// Expect(myThing.IsValid()).Should(BeTrue())
//
// Finally, if you want to match the received object as well as get the actual received value into a variable, so you can reason further about the value received,
// you can pass a pointer to a variable of the approriate type first, and second a matcher:
//
// var myThing thing
// Eventually(thingChan).Should(Receive(&myThing, ContainSubstring("bar")))
func Receive(args ...interface{}) types.GomegaMatcher {
return &matchers.ReceiveMatcher{
Args: args,
}
}
// BeSent succeeds if a value can be sent to actual.
// Actual must be a channel (and cannot be a receive-only channel) that can sent the type of the value passed into BeSent -- anything else is an error.
// In addition, actual must not be closed.
//
// BeSent never blocks:
//
// - If the channel `c` is not ready to receive then Expect(c).Should(BeSent("foo")) will fail immediately
// - If the channel `c` is eventually ready to receive then Eventually(c).Should(BeSent("foo")) will succeed.. presuming the channel becomes ready to receive before Eventually's timeout
// - If the channel `c` is closed then Expect(c).Should(BeSent("foo")) and Ω(c).ShouldNot(BeSent("foo")) will both fail immediately
//
// Of course, the value is actually sent to the channel. The point of `BeSent` is less to make an assertion about the availability of the channel (which is typically an implementation detail that your test should not be concerned with).
// Rather, the point of `BeSent` is to make it possible to easily and expressively write tests that can timeout on blocked channel sends.
func BeSent(arg interface{}) types.GomegaMatcher {
return &matchers.BeSentMatcher{
Arg: arg,
}
}
// MatchRegexp succeeds if actual is a string or stringer that matches the
// passed-in regexp. Optional arguments can be provided to construct a regexp
// via fmt.Sprintf().
func MatchRegexp(regexp string, args ...interface{}) types.GomegaMatcher {
return &matchers.MatchRegexpMatcher{
Regexp: regexp,
Args: args,
}
}
// ContainSubstring succeeds if actual is a string or stringer that contains the
// passed-in substring. Optional arguments can be provided to construct the substring
// via fmt.Sprintf().
func ContainSubstring(substr string, args ...interface{}) types.GomegaMatcher {
return &matchers.ContainSubstringMatcher{
Substr: substr,
Args: args,
}
}
// HavePrefix succeeds if actual is a string or stringer that contains the
// passed-in string as a prefix. Optional arguments can be provided to construct
// via fmt.Sprintf().
func HavePrefix(prefix string, args ...interface{}) types.GomegaMatcher {
return &matchers.HavePrefixMatcher{
Prefix: prefix,
Args: args,
}
}
// HaveSuffix succeeds if actual is a string or stringer that contains the
// passed-in string as a suffix. Optional arguments can be provided to construct
// via fmt.Sprintf().
func HaveSuffix(suffix string, args ...interface{}) types.GomegaMatcher {
return &matchers.HaveSuffixMatcher{
Suffix: suffix,
Args: args,
}
}
// MatchJSON succeeds if actual is a string or stringer of JSON that matches
// the expected JSON. The JSONs are decoded and the resulting objects are compared via
// reflect.DeepEqual so things like key-ordering and whitespace shouldn't matter.
func MatchJSON(json interface{}) types.GomegaMatcher {
return &matchers.MatchJSONMatcher{
JSONToMatch: json,
}
}
// MatchXML succeeds if actual is a string or stringer of XML that matches
// the expected XML. The XMLs are decoded and the resulting objects are compared via
// reflect.DeepEqual so things like whitespaces shouldn't matter.
func MatchXML(xml interface{}) types.GomegaMatcher {
return &matchers.MatchXMLMatcher{
XMLToMatch: xml,
}
}
// MatchYAML succeeds if actual is a string or stringer of YAML that matches
// the expected YAML. The YAML's are decoded and the resulting objects are compared via
// reflect.DeepEqual so things like key-ordering and whitespace shouldn't matter.
func MatchYAML(yaml interface{}) types.GomegaMatcher {
return &matchers.MatchYAMLMatcher{
YAMLToMatch: yaml,
}
}
// BeEmpty succeeds if actual is empty. Actual must be of type string, array, map, chan, or slice.
func BeEmpty() types.GomegaMatcher {
return &matchers.BeEmptyMatcher{}
}
// HaveLen succeeds if actual has the passed-in length. Actual must be of type string, array, map, chan, or slice.
func HaveLen(count int) types.GomegaMatcher {
return &matchers.HaveLenMatcher{
Count: count,
}
}
// HaveCap succeeds if actual has the passed-in capacity. Actual must be of type array, chan, or slice.
func HaveCap(count int) types.GomegaMatcher {
return &matchers.HaveCapMatcher{
Count: count,
}
}
// BeZero succeeds if actual is the zero value for its type or if actual is nil.
func BeZero() types.GomegaMatcher {
return &matchers.BeZeroMatcher{}
}
// ContainElement succeeds if actual contains the passed in element. By default
// ContainElement() uses Equal() to perform the match, however a matcher can be
// passed in instead:
//
// Expect([]string{"Foo", "FooBar"}).Should(ContainElement(ContainSubstring("Bar")))
//
// Actual must be an array, slice or map. For maps, ContainElement searches
// through the map's values.
//
// If you want to have a copy of the matching element(s) found you can pass a
// pointer to a variable of the appropriate type. If the variable isn't a slice
// or map, then exactly one match will be expected and returned. If the variable
// is a slice or map, then at least one match is expected and all matches will be
// stored in the variable.
//
// var findings []string
// Expect([]string{"Foo", "FooBar"}).Should(ContainElement(ContainSubString("Bar", &findings)))
func ContainElement(element interface{}, result ...interface{}) types.GomegaMatcher {
return &matchers.ContainElementMatcher{
Element: element,
Result: result,
}
}
// BeElementOf succeeds if actual is contained in the passed in elements.
// BeElementOf() always uses Equal() to perform the match.
// When the passed in elements are comprised of a single element that is either an Array or Slice, BeElementOf() behaves
// as the reverse of ContainElement() that operates with Equal() to perform the match.
//
// Expect(2).Should(BeElementOf([]int{1, 2}))
// Expect(2).Should(BeElementOf([2]int{1, 2}))
//
// Otherwise, BeElementOf() provides a syntactic sugar for Or(Equal(_), Equal(_), ...):
//
// Expect(2).Should(BeElementOf(1, 2))
//
// Actual must be typed.
func BeElementOf(elements ...interface{}) types.GomegaMatcher {
return &matchers.BeElementOfMatcher{
Elements: elements,
}
}
// BeKeyOf succeeds if actual is contained in the keys of the passed in map.
// BeKeyOf() always uses Equal() to perform the match between actual and the map keys.
//
// Expect("foo").Should(BeKeyOf(map[string]bool{"foo": true, "bar": false}))
func BeKeyOf(element interface{}) types.GomegaMatcher {
return &matchers.BeKeyOfMatcher{
Map: element,
}
}
// ConsistOf succeeds if actual contains precisely the elements passed into the matcher. The ordering of the elements does not matter.
// By default ConsistOf() uses Equal() to match the elements, however custom matchers can be passed in instead. Here are some examples:
//
// Expect([]string{"Foo", "FooBar"}).Should(ConsistOf("FooBar", "Foo"))
// Expect([]string{"Foo", "FooBar"}).Should(ConsistOf(ContainSubstring("Bar"), "Foo"))
// Expect([]string{"Foo", "FooBar"}).Should(ConsistOf(ContainSubstring("Foo"), ContainSubstring("Foo")))
//
// Actual must be an array, slice or map. For maps, ConsistOf matches against the map's values.
//
// You typically pass variadic arguments to ConsistOf (as in the examples above). However, if you need to pass in a slice you can provided that it
// is the only element passed in to ConsistOf:
//
// Expect([]string{"Foo", "FooBar"}).Should(ConsistOf([]string{"FooBar", "Foo"}))
//
// Note that Go's type system does not allow you to write this as ConsistOf([]string{"FooBar", "Foo"}...) as []string and []interface{} are different types - hence the need for this special rule.
func ConsistOf(elements ...interface{}) types.GomegaMatcher {
return &matchers.ConsistOfMatcher{
Elements: elements,
}
}
// HaveExactElements succeeds if actual contains elements that precisely match the elemets passed into the matcher. The ordering of the elements does matter.
// By default HaveExactElements() uses Equal() to match the elements, however custom matchers can be passed in instead. Here are some examples:
//
// Expect([]string{"Foo", "FooBar"}).Should(HaveExactElements("Foo", "FooBar"))
// Expect([]string{"Foo", "FooBar"}).Should(HaveExactElements("Foo", ContainSubstring("Bar")))
// Expect([]string{"Foo", "FooBar"}).Should(HaveExactElements(ContainSubstring("Foo"), ContainSubstring("Foo")))
//
// Actual must be an array or slice.
func HaveExactElements(elements ...interface{}) types.GomegaMatcher {
return &matchers.HaveExactElementsMatcher{
Elements: elements,
}
}
// ContainElements succeeds if actual contains the passed in elements. The ordering of the elements does not matter.
// By default ContainElements() uses Equal() to match the elements, however custom matchers can be passed in instead. Here are some examples:
//
// Expect([]string{"Foo", "FooBar"}).Should(ContainElements("FooBar"))
// Expect([]string{"Foo", "FooBar"}).Should(ContainElements(ContainSubstring("Bar"), "Foo"))
//
// Actual must be an array, slice or map.
// For maps, ContainElements searches through the map's values.
func ContainElements(elements ...interface{}) types.GomegaMatcher {
return &matchers.ContainElementsMatcher{
Elements: elements,
}
}
// HaveEach succeeds if actual solely contains elements that match the passed in element.
// Please note that if actual is empty, HaveEach always will fail.
// By default HaveEach() uses Equal() to perform the match, however a
// matcher can be passed in instead:
//
// Expect([]string{"Foo", "FooBar"}).Should(HaveEach(ContainSubstring("Foo")))
//
// Actual must be an array, slice or map.
// For maps, HaveEach searches through the map's values.
func HaveEach(element interface{}) types.GomegaMatcher {
return &matchers.HaveEachMatcher{
Element: element,
}
}
// HaveKey succeeds if actual is a map with the passed in key.
// By default HaveKey uses Equal() to perform the match, however a
// matcher can be passed in instead:
//
// Expect(map[string]string{"Foo": "Bar", "BazFoo": "Duck"}).Should(HaveKey(MatchRegexp(`.+Foo$`)))
func HaveKey(key interface{}) types.GomegaMatcher {
return &matchers.HaveKeyMatcher{
Key: key,
}
}
// HaveKeyWithValue succeeds if actual is a map with the passed in key and value.
// By default HaveKeyWithValue uses Equal() to perform the match, however a
// matcher can be passed in instead:
//
// Expect(map[string]string{"Foo": "Bar", "BazFoo": "Duck"}).Should(HaveKeyWithValue("Foo", "Bar"))
// Expect(map[string]string{"Foo": "Bar", "BazFoo": "Duck"}).Should(HaveKeyWithValue(MatchRegexp(`.+Foo$`), "Bar"))
func HaveKeyWithValue(key interface{}, value interface{}) types.GomegaMatcher {
return &matchers.HaveKeyWithValueMatcher{
Key: key,
Value: value,
}
}
// HaveField succeeds if actual is a struct and the value at the passed in field
// matches the passed in matcher. By default HaveField used Equal() to perform the match,
// however a matcher can be passed in in stead.
//
// The field must be a string that resolves to the name of a field in the struct. Structs can be traversed
// using the '.' delimiter. If the field ends with '()' a method named field is assumed to exist on the struct and is invoked.
// Such methods must take no arguments and return a single value:
//
// type Book struct {
// Title string
// Author Person
// }
// type Person struct {
// FirstName string
// LastName string
// DOB time.Time
// }
// Expect(book).To(HaveField("Title", "Les Miserables"))
// Expect(book).To(HaveField("Title", ContainSubstring("Les"))
// Expect(book).To(HaveField("Author.FirstName", Equal("Victor"))
// Expect(book).To(HaveField("Author.DOB.Year()", BeNumerically("<", 1900))
func HaveField(field string, expected interface{}) types.GomegaMatcher {
return &matchers.HaveFieldMatcher{
Field: field,
Expected: expected,
}
}
// HaveExistingField succeeds if actual is a struct and the specified field
// exists.
//
// HaveExistingField can be combined with HaveField in order to cover use cases
// with optional fields. HaveField alone would trigger an error in such situations.
//
// Expect(MrHarmless).NotTo(And(HaveExistingField("Title"), HaveField("Title", "Supervillain")))
func HaveExistingField(field string) types.GomegaMatcher {
return &matchers.HaveExistingFieldMatcher{
Field: field,
}
}
// HaveValue applies the given matcher to the value of actual, optionally and
// repeatedly dereferencing pointers or taking the concrete value of interfaces.
// Thus, the matcher will always be applied to non-pointer and non-interface
// values only. HaveValue will fail with an error if a pointer or interface is
// nil. It will also fail for more than 31 pointer or interface dereferences to
// guard against mistakenly applying it to arbitrarily deep linked pointers.
//
// HaveValue differs from gstruct.PointTo in that it does not expect actual to
// be a pointer (as gstruct.PointTo does) but instead also accepts non-pointer
// and even interface values.
//
// actual := 42
// Expect(actual).To(HaveValue(42))
// Expect(&actual).To(HaveValue(42))
func HaveValue(matcher types.GomegaMatcher) types.GomegaMatcher {
return &matchers.HaveValueMatcher{
Matcher: matcher,
}
}
// BeNumerically performs numerical assertions in a type-agnostic way.
// Actual and expected should be numbers, though the specific type of
// number is irrelevant (float32, float64, uint8, etc...).
//
// There are six, self-explanatory, supported comparators:
//
// Expect(1.0).Should(BeNumerically("==", 1))
// Expect(1.0).Should(BeNumerically("~", 0.999, 0.01))
// Expect(1.0).Should(BeNumerically(">", 0.9))
// Expect(1.0).Should(BeNumerically(">=", 1.0))
// Expect(1.0).Should(BeNumerically("<", 3))
// Expect(1.0).Should(BeNumerically("<=", 1.0))
func BeNumerically(comparator string, compareTo ...interface{}) types.GomegaMatcher {
return &matchers.BeNumericallyMatcher{
Comparator: comparator,
CompareTo: compareTo,
}
}
// BeTemporally compares time.Time's like BeNumerically
// Actual and expected must be time.Time. The comparators are the same as for BeNumerically
//
// Expect(time.Now()).Should(BeTemporally(">", time.Time{}))
// Expect(time.Now()).Should(BeTemporally("~", time.Now(), time.Second))
func BeTemporally(comparator string, compareTo time.Time, threshold ...time.Duration) types.GomegaMatcher {
return &matchers.BeTemporallyMatcher{
Comparator: comparator,
CompareTo: compareTo,
Threshold: threshold,
}
}
// BeAssignableToTypeOf succeeds if actual is assignable to the type of expected.
// It will return an error when one of the values is nil.
//
// Expect(0).Should(BeAssignableToTypeOf(0)) // Same values
// Expect(5).Should(BeAssignableToTypeOf(-1)) // different values same type
// Expect("foo").Should(BeAssignableToTypeOf("bar")) // different values same type
// Expect(struct{ Foo string }{}).Should(BeAssignableToTypeOf(struct{ Foo string }{}))
func BeAssignableToTypeOf(expected interface{}) types.GomegaMatcher {
return &matchers.AssignableToTypeOfMatcher{
Expected: expected,
}
}
// Panic succeeds if actual is a function that, when invoked, panics.
// Actual must be a function that takes no arguments and returns no results.
func Panic() types.GomegaMatcher {
return &matchers.PanicMatcher{}
}
// PanicWith succeeds if actual is a function that, when invoked, panics with a specific value.
// Actual must be a function that takes no arguments and returns no results.
//
// By default PanicWith uses Equal() to perform the match, however a
// matcher can be passed in instead:
//
// Expect(fn).Should(PanicWith(MatchRegexp(`.+Foo$`)))
func PanicWith(expected interface{}) types.GomegaMatcher {
return &matchers.PanicMatcher{Expected: expected}
}
// BeAnExistingFile succeeds if a file exists.
// Actual must be a string representing the abs path to the file being checked.
func BeAnExistingFile() types.GomegaMatcher {
return &matchers.BeAnExistingFileMatcher{}
}
// BeARegularFile succeeds if a file exists and is a regular file.
// Actual must be a string representing the abs path to the file being checked.
func BeARegularFile() types.GomegaMatcher {
return &matchers.BeARegularFileMatcher{}
}
// BeADirectory succeeds if a file exists and is a directory.
// Actual must be a string representing the abs path to the file being checked.
func BeADirectory() types.GomegaMatcher {
return &matchers.BeADirectoryMatcher{}
}
// HaveHTTPStatus succeeds if the Status or StatusCode field of an HTTP response matches.
// Actual must be either a *http.Response or *httptest.ResponseRecorder.
// Expected must be either an int or a string.
//
// Expect(resp).Should(HaveHTTPStatus(http.StatusOK)) // asserts that resp.StatusCode == 200
// Expect(resp).Should(HaveHTTPStatus("404 Not Found")) // asserts that resp.Status == "404 Not Found"
// Expect(resp).Should(HaveHTTPStatus(http.StatusOK, http.StatusNoContent)) // asserts that resp.StatusCode == 200 || resp.StatusCode == 204
func HaveHTTPStatus(expected ...interface{}) types.GomegaMatcher {
return &matchers.HaveHTTPStatusMatcher{Expected: expected}
}
// HaveHTTPHeaderWithValue succeeds if the header is found and the value matches.
// Actual must be either a *http.Response or *httptest.ResponseRecorder.
// Expected must be a string header name, followed by a header value which
// can be a string, or another matcher.
func HaveHTTPHeaderWithValue(header string, value interface{}) types.GomegaMatcher {
return &matchers.HaveHTTPHeaderWithValueMatcher{
Header: header,
Value: value,
}
}
// HaveHTTPBody matches if the body matches.
// Actual must be either a *http.Response or *httptest.ResponseRecorder.
// Expected must be either a string, []byte, or other matcher
func HaveHTTPBody(expected interface{}) types.GomegaMatcher {
return &matchers.HaveHTTPBodyMatcher{Expected: expected}
}
// And succeeds only if all of the given matchers succeed.
// The matchers are tried in order, and will fail-fast if one doesn't succeed.
//
// Expect("hi").To(And(HaveLen(2), Equal("hi"))
//
// And(), Or(), Not() and WithTransform() allow matchers to be composed into complex expressions.
func And(ms ...types.GomegaMatcher) types.GomegaMatcher {
return &matchers.AndMatcher{Matchers: ms}
}
// SatisfyAll is an alias for And().
//
// Expect("hi").Should(SatisfyAll(HaveLen(2), Equal("hi")))
func SatisfyAll(matchers ...types.GomegaMatcher) types.GomegaMatcher {
return And(matchers...)
}
// Or succeeds if any of the given matchers succeed.
// The matchers are tried in order and will return immediately upon the first successful match.
//
// Expect("hi").To(Or(HaveLen(3), HaveLen(2))
//
// And(), Or(), Not() and WithTransform() allow matchers to be composed into complex expressions.
func Or(ms ...types.GomegaMatcher) types.GomegaMatcher {
return &matchers.OrMatcher{Matchers: ms}
}
// SatisfyAny is an alias for Or().
//
// Expect("hi").SatisfyAny(Or(HaveLen(3), HaveLen(2))
func SatisfyAny(matchers ...types.GomegaMatcher) types.GomegaMatcher {
return Or(matchers...)
}
// Not negates the given matcher; it succeeds if the given matcher fails.
//
// Expect(1).To(Not(Equal(2))
//
// And(), Or(), Not() and WithTransform() allow matchers to be composed into complex expressions.
func Not(matcher types.GomegaMatcher) types.GomegaMatcher {
return &matchers.NotMatcher{Matcher: matcher}
}
// WithTransform applies the `transform` to the actual value and matches it against `matcher`.
// The given transform must be either a function of one parameter that returns one value or a
// function of one parameter that returns two values, where the second value must be of the
// error type.
//
// var plus1 = func(i int) int { return i + 1 }
// Expect(1).To(WithTransform(plus1, Equal(2))
//
// var failingplus1 = func(i int) (int, error) { return 42, "this does not compute" }
// Expect(1).To(WithTransform(failingplus1, Equal(2)))
//
// And(), Or(), Not() and WithTransform() allow matchers to be composed into complex expressions.
func WithTransform(transform interface{}, matcher types.GomegaMatcher) types.GomegaMatcher {
return matchers.NewWithTransformMatcher(transform, matcher)
}
// Satisfy matches the actual value against the `predicate` function.
// The given predicate must be a function of one paramter that returns bool.
//
// var isEven = func(i int) bool { return i%2 == 0 }
// Expect(2).To(Satisfy(isEven))
func Satisfy(predicate interface{}) types.GomegaMatcher {
return matchers.NewSatisfyMatcher(predicate)
}
| go | Apache-2.0 | b3b4703e958c25d54c4d48138d9e80ae32fadac3 | 2026-01-07T09:44:30.792320Z | false |
kubev2v/forklift | https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/github.com/onsi/gomega/gomega_dsl.go | vendor/github.com/onsi/gomega/gomega_dsl.go | /*
Gomega is the Ginkgo BDD-style testing framework's preferred matcher library.
The godoc documentation describes Gomega's API. More comprehensive documentation (with examples!) is available at http://onsi.github.io/gomega/
Gomega on Github: http://github.com/onsi/gomega
Learn more about Ginkgo online: http://onsi.github.io/ginkgo
Ginkgo on Github: http://github.com/onsi/ginkgo
Gomega is MIT-Licensed
*/
package gomega
import (
"errors"
"fmt"
"time"
"github.com/onsi/gomega/internal"
"github.com/onsi/gomega/types"
)
const GOMEGA_VERSION = "1.36.1"
const nilGomegaPanic = `You are trying to make an assertion, but haven't registered Gomega's fail handler.
If you're using Ginkgo then you probably forgot to put your assertion in an It().
Alternatively, you may have forgotten to register a fail handler with RegisterFailHandler() or RegisterTestingT().
Depending on your vendoring solution you may be inadvertently importing gomega and subpackages (e.g. ghhtp, gexec,...) from different locations.
`
// Gomega describes the essential Gomega DSL. This interface allows libraries
// to abstract between the standard package-level function implementations
// and alternatives like *WithT.
//
// The types in the top-level DSL have gotten a bit messy due to earlier deprecations that avoid stuttering
// and due to an accidental use of a concrete type (*WithT) in an earlier release.
//
// As of 1.15 both the WithT and Ginkgo variants of Gomega are implemented by the same underlying object
// however one (the Ginkgo variant) is exported as an interface (types.Gomega) whereas the other (the withT variant)
// is shared as a concrete type (*WithT, which is aliased to *internal.Gomega). 1.15 did not clean this mess up to ensure
// that declarations of *WithT in existing code are not broken by the upgrade to 1.15.
type Gomega = types.Gomega
// DefaultGomega supplies the standard package-level implementation
var Default = Gomega(internal.NewGomega(internal.FetchDefaultDurationBundle()))
// NewGomega returns an instance of Gomega wired into the passed-in fail handler.
// You generally don't need to use this when using Ginkgo - RegisterFailHandler will wire up the global gomega
// However creating a NewGomega with a custom fail handler can be useful in contexts where you want to use Gomega's
// rich ecosystem of matchers without causing a test to fail. For example, to aggregate a series of potential failures
// or for use in a non-test setting.
func NewGomega(fail types.GomegaFailHandler) Gomega {
return internal.NewGomega(internalGomega(Default).DurationBundle).ConfigureWithFailHandler(fail)
}
// WithT wraps a *testing.T and provides `Expect`, `Eventually`, and `Consistently` methods. This allows you to leverage
// Gomega's rich ecosystem of matchers in standard `testing` test suites.
//
// Use `NewWithT` to instantiate a `WithT`
//
// As of 1.15 both the WithT and Ginkgo variants of Gomega are implemented by the same underlying object
// however one (the Ginkgo variant) is exported as an interface (types.Gomega) whereas the other (the withT variant)
// is shared as a concrete type (*WithT, which is aliased to *internal.Gomega). 1.15 did not clean this mess up to ensure
// that declarations of *WithT in existing code are not broken by the upgrade to 1.15.
type WithT = internal.Gomega
// GomegaWithT is deprecated in favor of gomega.WithT, which does not stutter.
type GomegaWithT = WithT
// inner is an interface that allows users to provide a wrapper around Default. The wrapper
// must implement the inner interface and return either the original Default or the result of
// a call to NewGomega().
type inner interface {
Inner() Gomega
}
func internalGomega(g Gomega) *internal.Gomega {
if v, ok := g.(inner); ok {
return v.Inner().(*internal.Gomega)
}
return g.(*internal.Gomega)
}
// NewWithT takes a *testing.T and returns a `gomega.WithT` allowing you to use `Expect`, `Eventually`, and `Consistently` along with
// Gomega's rich ecosystem of matchers in standard `testing` test suits.
//
// func TestFarmHasCow(t *testing.T) {
// g := gomega.NewWithT(t)
//
// f := farm.New([]string{"Cow", "Horse"})
// g.Expect(f.HasCow()).To(BeTrue(), "Farm should have cow")
// }
func NewWithT(t types.GomegaTestingT) *WithT {
return internal.NewGomega(internalGomega(Default).DurationBundle).ConfigureWithT(t)
}
// NewGomegaWithT is deprecated in favor of gomega.NewWithT, which does not stutter.
var NewGomegaWithT = NewWithT
// RegisterFailHandler connects Ginkgo to Gomega. When a matcher fails
// the fail handler passed into RegisterFailHandler is called.
func RegisterFailHandler(fail types.GomegaFailHandler) {
internalGomega(Default).ConfigureWithFailHandler(fail)
}
// RegisterFailHandlerWithT is deprecated and will be removed in a future release.
// users should use RegisterFailHandler, or RegisterTestingT
func RegisterFailHandlerWithT(_ types.GomegaTestingT, fail types.GomegaFailHandler) {
fmt.Println("RegisterFailHandlerWithT is deprecated. Please use RegisterFailHandler or RegisterTestingT instead.")
internalGomega(Default).ConfigureWithFailHandler(fail)
}
// RegisterTestingT connects Gomega to Golang's XUnit style
// Testing.T tests. It is now deprecated and you should use NewWithT() instead to get a fresh instance of Gomega for each test.
func RegisterTestingT(t types.GomegaTestingT) {
internalGomega(Default).ConfigureWithT(t)
}
// InterceptGomegaFailures runs a given callback and returns an array of
// failure messages generated by any Gomega assertions within the callback.
// Execution continues after the first failure allowing users to collect all failures
// in the callback.
//
// This is most useful when testing custom matchers, but can also be used to check
// on a value using a Gomega assertion without causing a test failure.
func InterceptGomegaFailures(f func()) []string {
originalHandler := internalGomega(Default).Fail
failures := []string{}
internalGomega(Default).Fail = func(message string, callerSkip ...int) {
failures = append(failures, message)
}
defer func() {
internalGomega(Default).Fail = originalHandler
}()
f()
return failures
}
// InterceptGomegaFailure runs a given callback and returns the first
// failure message generated by any Gomega assertions within the callback, wrapped in an error.
//
// The callback ceases execution as soon as the first failed assertion occurs, however Gomega
// does not register a failure with the FailHandler registered via RegisterFailHandler - it is up
// to the user to decide what to do with the returned error
func InterceptGomegaFailure(f func()) (err error) {
originalHandler := internalGomega(Default).Fail
internalGomega(Default).Fail = func(message string, callerSkip ...int) {
err = errors.New(message)
panic("stop execution")
}
defer func() {
internalGomega(Default).Fail = originalHandler
if e := recover(); e != nil {
if err == nil {
panic(e)
}
}
}()
f()
return err
}
func ensureDefaultGomegaIsConfigured() {
if !internalGomega(Default).IsConfigured() {
panic(nilGomegaPanic)
}
}
// Ω wraps an actual value allowing assertions to be made on it:
//
// Ω("foo").Should(Equal("foo"))
//
// If Ω is passed more than one argument it will pass the *first* argument to the matcher.
// All subsequent arguments will be required to be nil/zero.
//
// This is convenient if you want to make an assertion on a method/function that returns
// a value and an error - a common patter in Go.
//
// For example, given a function with signature:
//
// func MyAmazingThing() (int, error)
//
// Then:
//
// Ω(MyAmazingThing()).Should(Equal(3))
//
// Will succeed only if `MyAmazingThing()` returns `(3, nil)`
//
// Ω and Expect are identical
func Ω(actual interface{}, extra ...interface{}) Assertion {
ensureDefaultGomegaIsConfigured()
return Default.Ω(actual, extra...)
}
// Expect wraps an actual value allowing assertions to be made on it:
//
// Expect("foo").To(Equal("foo"))
//
// If Expect is passed more than one argument it will pass the *first* argument to the matcher.
// All subsequent arguments will be required to be nil/zero.
//
// This is convenient if you want to make an assertion on a method/function that returns
// a value and an error - a common pattern in Go.
//
// For example, given a function with signature:
//
// func MyAmazingThing() (int, error)
//
// Then:
//
// Expect(MyAmazingThing()).Should(Equal(3))
//
// Will succeed only if `MyAmazingThing()` returns `(3, nil)`
//
// Expect and Ω are identical
func Expect(actual interface{}, extra ...interface{}) Assertion {
ensureDefaultGomegaIsConfigured()
return Default.Expect(actual, extra...)
}
// ExpectWithOffset wraps an actual value allowing assertions to be made on it:
//
// ExpectWithOffset(1, "foo").To(Equal("foo"))
//
// Unlike `Expect` and `Ω`, `ExpectWithOffset` takes an additional integer argument
// that is used to modify the call-stack offset when computing line numbers. It is
// the same as `Expect(...).WithOffset`.
//
// This is most useful in helper functions that make assertions. If you want Gomega's
// error message to refer to the calling line in the test (as opposed to the line in the helper function)
// set the first argument of `ExpectWithOffset` appropriately.
func ExpectWithOffset(offset int, actual interface{}, extra ...interface{}) Assertion {
ensureDefaultGomegaIsConfigured()
return Default.ExpectWithOffset(offset, actual, extra...)
}
/*
Eventually enables making assertions on asynchronous behavior.
Eventually checks that an assertion *eventually* passes. Eventually blocks when called and attempts an assertion periodically until it passes or a timeout occurs. Both the timeout and polling interval are configurable as optional arguments.
The first optional argument is the timeout (which defaults to 1s), the second is the polling interval (which defaults to 10ms). Both intervals can be specified as time.Duration, parsable duration strings or floats/integers (in which case they are interpreted as seconds). In addition an optional context.Context can be passed in - Eventually will keep trying until either the timeout expires or the context is cancelled, whichever comes first.
Eventually works with any Gomega compatible matcher and supports making assertions against three categories of actual value:
**Category 1: Making Eventually assertions on values**
There are several examples of values that can change over time. These can be passed in to Eventually and will be passed to the matcher repeatedly until a match occurs. For example:
c := make(chan bool)
go DoStuff(c)
Eventually(c, "50ms").Should(BeClosed())
will poll the channel repeatedly until it is closed. In this example `Eventually` will block until either the specified timeout of 50ms has elapsed or the channel is closed, whichever comes first.
Several Gomega libraries allow you to use Eventually in this way. For example, the gomega/gexec package allows you to block until a *gexec.Session exits successfully via:
Eventually(session).Should(gexec.Exit(0))
And the gomega/gbytes package allows you to monitor a streaming *gbytes.Buffer until a given string is seen:
Eventually(buffer).Should(gbytes.Say("hello there"))
In these examples, both `session` and `buffer` are designed to be thread-safe when polled by the `Exit` and `Say` matchers. This is not true in general of most raw values, so while it is tempting to do something like:
// THIS IS NOT THREAD-SAFE
var s *string
go mutateStringEventually(s)
Eventually(s).Should(Equal("I've changed"))
this will trigger Go's race detector as the goroutine polling via Eventually will race over the value of s with the goroutine mutating the string. For cases like this you can use channels or introduce your own locking around s by passing Eventually a function.
**Category 2: Make Eventually assertions on functions**
Eventually can be passed functions that **return at least one value**. When configured this way, Eventually will poll the function repeatedly and pass the first returned value to the matcher.
For example:
Eventually(func() int {
return client.FetchCount()
}).Should(BeNumerically(">=", 17))
will repeatedly poll client.FetchCount until the BeNumerically matcher is satisfied. (Note that this example could have been written as Eventually(client.FetchCount).Should(BeNumerically(">=", 17)))
If multiple values are returned by the function, Eventually will pass the first value to the matcher and require that all others are zero-valued. This allows you to pass Eventually a function that returns a value and an error - a common pattern in Go.
For example, consider a method that returns a value and an error:
func FetchFromDB() (string, error)
Then
Eventually(FetchFromDB).Should(Equal("got it"))
will pass only if and when the returned error is nil *and* the returned string satisfies the matcher.
Eventually can also accept functions that take arguments, however you must provide those arguments using .WithArguments(). For example, consider a function that takes a user-id and makes a network request to fetch a full name:
func FetchFullName(userId int) (string, error)
You can poll this function like so:
Eventually(FetchFullName).WithArguments(1138).Should(Equal("Wookie"))
It is important to note that the function passed into Eventually is invoked *synchronously* when polled. Eventually does not (in fact, it cannot) kill the function if it takes longer to return than Eventually's configured timeout. A common practice here is to use a context. Here's an example that combines Ginkgo's spec timeout support with Eventually:
It("fetches the correct count", func(ctx SpecContext) {
Eventually(ctx, func() int {
return client.FetchCount(ctx, "/users")
}).Should(BeNumerically(">=", 17))
}, SpecTimeout(time.Second))
you an also use Eventually().WithContext(ctx) to pass in the context. Passed-in contexts play nicely with passed-in arguments as long as the context appears first. You can rewrite the above example as:
It("fetches the correct count", func(ctx SpecContext) {
Eventually(client.FetchCount).WithContext(ctx).WithArguments("/users").Should(BeNumerically(">=", 17))
}, SpecTimeout(time.Second))
Either way the context pasesd to Eventually is also passed to the underlying function. Now, when Ginkgo cancels the context both the FetchCount client and Gomega will be informed and can exit.
By default, when a context is passed to Eventually *without* an explicit timeout, Gomega will rely solely on the context's cancellation to determine when to stop polling. If you want to specify a timeout in addition to the context you can do so using the .WithTimeout() method. For example:
Eventually(client.FetchCount).WithContext(ctx).WithTimeout(10*time.Second).Should(BeNumerically(">=", 17))
now either the context cacnellation or the timeout will cause Eventually to stop polling.
If, instead, you would like to opt out of this behavior and have Gomega's default timeouts govern Eventuallys that take a context you can call:
EnforceDefaultTimeoutsWhenUsingContexts()
in the DSL (or on a Gomega instance). Now all calls to Eventually that take a context will fail if eitehr the context is cancelled or the default timeout elapses.
**Category 3: Making assertions _in_ the function passed into Eventually**
When testing complex systems it can be valuable to assert that a _set_ of assertions passes Eventually. Eventually supports this by accepting functions that take a single Gomega argument and return zero or more values.
Here's an example that makes some assertions and returns a value and error:
Eventually(func(g Gomega) (Widget, error) {
ids, err := client.FetchIDs()
g.Expect(err).NotTo(HaveOccurred())
g.Expect(ids).To(ContainElement(1138))
return client.FetchWidget(1138)
}).Should(Equal(expectedWidget))
will pass only if all the assertions in the polled function pass and the return value satisfied the matcher.
Eventually also supports a special case polling function that takes a single Gomega argument and returns no values. Eventually assumes such a function is making assertions and is designed to work with the Succeed matcher to validate that all assertions have passed.
For example:
Eventually(func(g Gomega) {
model, err := client.Find(1138)
g.Expect(err).NotTo(HaveOccurred())
g.Expect(model.Reticulate()).To(Succeed())
g.Expect(model.IsReticulated()).To(BeTrue())
g.Expect(model.Save()).To(Succeed())
}).Should(Succeed())
will rerun the function until all assertions pass.
You can also pass additional arguments to functions that take a Gomega. The only rule is that the Gomega argument must be first. If you also want to pass the context attached to Eventually you must ensure that is the second argument. For example:
Eventually(func(g Gomega, ctx context.Context, path string, expected ...string){
tok, err := client.GetToken(ctx)
g.Expect(err).NotTo(HaveOccurred())
elements, err := client.Fetch(ctx, tok, path)
g.Expect(err).NotTo(HaveOccurred())
g.Expect(elements).To(ConsistOf(expected))
}).WithContext(ctx).WithArguments("/names", "Joe", "Jane", "Sam").Should(Succeed())
You can ensure that you get a number of consecutive successful tries before succeeding using `MustPassRepeatedly(int)`. For Example:
int count := 0
Eventually(func() bool {
count++
return count > 2
}).MustPassRepeatedly(2).Should(BeTrue())
// Because we had to wait for 2 calls that returned true
Expect(count).To(Equal(3))
Finally, in addition to passing timeouts and a context to Eventually you can be more explicit with Eventually's chaining configuration methods:
Eventually(..., "10s", "2s", ctx).Should(...)
is equivalent to
Eventually(...).WithTimeout(10*time.Second).WithPolling(2*time.Second).WithContext(ctx).Should(...)
*/
func Eventually(actualOrCtx interface{}, args ...interface{}) AsyncAssertion {
ensureDefaultGomegaIsConfigured()
return Default.Eventually(actualOrCtx, args...)
}
// EventuallyWithOffset operates like Eventually but takes an additional
// initial argument to indicate an offset in the call stack. This is useful when building helper
// functions that contain matchers. To learn more, read about `ExpectWithOffset`.
//
// `EventuallyWithOffset` is the same as `Eventually(...).WithOffset`.
//
// `EventuallyWithOffset` specifying a timeout interval (and an optional polling interval) are
// the same as `Eventually(...).WithOffset(...).WithTimeout` or
// `Eventually(...).WithOffset(...).WithTimeout(...).WithPolling`.
func EventuallyWithOffset(offset int, actualOrCtx interface{}, args ...interface{}) AsyncAssertion {
ensureDefaultGomegaIsConfigured()
return Default.EventuallyWithOffset(offset, actualOrCtx, args...)
}
/*
Consistently, like Eventually, enables making assertions on asynchronous behavior.
Consistently blocks when called for a specified duration. During that duration Consistently repeatedly polls its matcher and ensures that it is satisfied. If the matcher is consistently satisfied, then Consistently will pass. Otherwise Consistently will fail.
Both the total waiting duration and the polling interval are configurable as optional arguments. The first optional argument is the duration that Consistently will run for (defaults to 100ms), and the second argument is the polling interval (defaults to 10ms). As with Eventually, these intervals can be passed in as time.Duration, parsable duration strings or an integer or float number of seconds. You can also pass in an optional context.Context - Consistently will exit early (with a failure) if the context is cancelled before the waiting duration expires.
Consistently accepts the same three categories of actual as Eventually, check the Eventually docs to learn more.
Consistently is useful in cases where you want to assert that something *does not happen* for a period of time. For example, you may want to assert that a goroutine does *not* send data down a channel. In this case you could write:
Consistently(channel, "200ms").ShouldNot(Receive())
This will block for 200 milliseconds and repeatedly check the channel and ensure nothing has been received.
*/
func Consistently(actualOrCtx interface{}, args ...interface{}) AsyncAssertion {
ensureDefaultGomegaIsConfigured()
return Default.Consistently(actualOrCtx, args...)
}
// ConsistentlyWithOffset operates like Consistently but takes an additional
// initial argument to indicate an offset in the call stack. This is useful when building helper
// functions that contain matchers. To learn more, read about `ExpectWithOffset`.
//
// `ConsistentlyWithOffset` is the same as `Consistently(...).WithOffset` and
// optional `WithTimeout` and `WithPolling`.
func ConsistentlyWithOffset(offset int, actualOrCtx interface{}, args ...interface{}) AsyncAssertion {
ensureDefaultGomegaIsConfigured()
return Default.ConsistentlyWithOffset(offset, actualOrCtx, args...)
}
/*
StopTrying can be used to signal to Eventually and Consistentlythat they should abort and stop trying. This always results in a failure of the assertion - and the failure message is the content of the StopTrying signal.
You can send the StopTrying signal by either returning StopTrying("message") as an error from your passed-in function _or_ by calling StopTrying("message").Now() to trigger a panic and end execution.
You can also wrap StopTrying around an error with `StopTrying("message").Wrap(err)` and can attach additional objects via `StopTrying("message").Attach("description", object). When rendered, the signal will include the wrapped error and any attached objects rendered using Gomega's default formatting.
Here are a couple of examples. This is how you might use StopTrying() as an error to signal that Eventually should stop:
playerIndex, numPlayers := 0, 11
Eventually(func() (string, error) {
if playerIndex == numPlayers {
return "", StopTrying("no more players left")
}
name := client.FetchPlayer(playerIndex)
playerIndex += 1
return name, nil
}).Should(Equal("Patrick Mahomes"))
And here's an example where `StopTrying().Now()` is called to halt execution immediately:
Eventually(func() []string {
names, err := client.FetchAllPlayers()
if err == client.IRRECOVERABLE_ERROR {
StopTrying("Irrecoverable error occurred").Wrap(err).Now()
}
return names
}).Should(ContainElement("Patrick Mahomes"))
*/
var StopTrying = internal.StopTrying
/*
TryAgainAfter(<duration>) allows you to adjust the polling interval for the _next_ iteration of `Eventually` or `Consistently`. Like `StopTrying` you can either return `TryAgainAfter` as an error or trigger it immedieately with `.Now()`
When `TryAgainAfter(<duration>` is triggered `Eventually` and `Consistently` will wait for that duration. If a timeout occurs before the next poll is triggered both `Eventually` and `Consistently` will always fail with the content of the TryAgainAfter message. As with StopTrying you can `.Wrap()` and error and `.Attach()` additional objects to `TryAgainAfter`.
*/
var TryAgainAfter = internal.TryAgainAfter
/*
PollingSignalError is the error returned by StopTrying() and TryAgainAfter()
*/
type PollingSignalError = internal.PollingSignalError
// SetDefaultEventuallyTimeout sets the default timeout duration for Eventually. Eventually will repeatedly poll your condition until it succeeds, or until this timeout elapses.
func SetDefaultEventuallyTimeout(t time.Duration) {
Default.SetDefaultEventuallyTimeout(t)
}
// SetDefaultEventuallyPollingInterval sets the default polling interval for Eventually.
func SetDefaultEventuallyPollingInterval(t time.Duration) {
Default.SetDefaultEventuallyPollingInterval(t)
}
// SetDefaultConsistentlyDuration sets the default duration for Consistently. Consistently will verify that your condition is satisfied for this long.
func SetDefaultConsistentlyDuration(t time.Duration) {
Default.SetDefaultConsistentlyDuration(t)
}
// SetDefaultConsistentlyPollingInterval sets the default polling interval for Consistently.
func SetDefaultConsistentlyPollingInterval(t time.Duration) {
Default.SetDefaultConsistentlyPollingInterval(t)
}
// EnforceDefaultTimeoutsWhenUsingContexts forces `Eventually` to apply a default timeout even when a context is provided.
func EnforceDefaultTimeoutsWhenUsingContexts() {
Default.EnforceDefaultTimeoutsWhenUsingContexts()
}
// DisableDefaultTimeoutsWhenUsingContext disables the default timeout when a context is provided to `Eventually`.
func DisableDefaultTimeoutsWhenUsingContext() {
Default.DisableDefaultTimeoutsWhenUsingContext()
}
// AsyncAssertion is returned by Eventually and Consistently and polls the actual value passed into Eventually against
// the matcher passed to the Should and ShouldNot methods.
//
// Both Should and ShouldNot take a variadic optionalDescription argument.
// This argument allows you to make your failure messages more descriptive.
// If a single argument of type `func() string` is passed, this function will be lazily evaluated if a failure occurs
// and the returned string is used to annotate the failure message.
// Otherwise, this argument is passed on to fmt.Sprintf() and then used to annotate the failure message.
//
// Both Should and ShouldNot return a boolean that is true if the assertion passed and false if it failed.
//
// Example:
//
// Eventually(myChannel).Should(Receive(), "Something should have come down the pipe.")
// Consistently(myChannel).ShouldNot(Receive(), func() string { return "Nothing should have come down the pipe." })
type AsyncAssertion = types.AsyncAssertion
// GomegaAsyncAssertion is deprecated in favor of AsyncAssertion, which does not stutter.
type GomegaAsyncAssertion = types.AsyncAssertion
// Assertion is returned by Ω and Expect and compares the actual value to the matcher
// passed to the Should/ShouldNot and To/ToNot/NotTo methods.
//
// Typically Should/ShouldNot are used with Ω and To/ToNot/NotTo are used with Expect
// though this is not enforced.
//
// All methods take a variadic optionalDescription argument.
// This argument allows you to make your failure messages more descriptive.
// If a single argument of type `func() string` is passed, this function will be lazily evaluated if a failure occurs
// and the returned string is used to annotate the failure message.
// Otherwise, this argument is passed on to fmt.Sprintf() and then used to annotate the failure message.
//
// All methods return a bool that is true if the assertion passed and false if it failed.
//
// Example:
//
// Ω(farm.HasCow()).Should(BeTrue(), "Farm %v should have a cow", farm)
type Assertion = types.Assertion
// GomegaAssertion is deprecated in favor of Assertion, which does not stutter.
type GomegaAssertion = types.Assertion
// OmegaMatcher is deprecated in favor of the better-named and better-organized types.GomegaMatcher but sticks around to support existing code that uses it
type OmegaMatcher = types.GomegaMatcher
| go | Apache-2.0 | b3b4703e958c25d54c4d48138d9e80ae32fadac3 | 2026-01-07T09:44:30.792320Z | false |
kubev2v/forklift | https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/github.com/onsi/gomega/types/types.go | vendor/github.com/onsi/gomega/types/types.go | package types
import (
"context"
"time"
)
type GomegaFailHandler func(message string, callerSkip ...int)
// A simple *testing.T interface wrapper
type GomegaTestingT interface {
Helper()
Fatalf(format string, args ...interface{})
}
// Gomega represents an object that can perform synchronous and assynchronous assertions with Gomega matchers
type Gomega interface {
Ω(actual interface{}, extra ...interface{}) Assertion
Expect(actual interface{}, extra ...interface{}) Assertion
ExpectWithOffset(offset int, actual interface{}, extra ...interface{}) Assertion
Eventually(actualOrCtx interface{}, args ...interface{}) AsyncAssertion
EventuallyWithOffset(offset int, actualOrCtx interface{}, args ...interface{}) AsyncAssertion
Consistently(actualOrCtx interface{}, args ...interface{}) AsyncAssertion
ConsistentlyWithOffset(offset int, actualOrCtx interface{}, args ...interface{}) AsyncAssertion
SetDefaultEventuallyTimeout(time.Duration)
SetDefaultEventuallyPollingInterval(time.Duration)
SetDefaultConsistentlyDuration(time.Duration)
SetDefaultConsistentlyPollingInterval(time.Duration)
EnforceDefaultTimeoutsWhenUsingContexts()
DisableDefaultTimeoutsWhenUsingContext()
}
// All Gomega matchers must implement the GomegaMatcher interface
//
// For details on writing custom matchers, check out: http://onsi.github.io/gomega/#adding-your-own-matchers
type GomegaMatcher interface {
Match(actual interface{}) (success bool, err error)
FailureMessage(actual interface{}) (message string)
NegatedFailureMessage(actual interface{}) (message string)
}
/*
GomegaMatchers that also match the OracleMatcher interface can convey information about
whether or not their result will change upon future attempts.
This allows `Eventually` and `Consistently` to short circuit if success becomes impossible.
For example, a process' exit code can never change. So, gexec's Exit matcher returns `true`
for `MatchMayChangeInTheFuture` until the process exits, at which point it returns `false` forevermore.
*/
type OracleMatcher interface {
MatchMayChangeInTheFuture(actual interface{}) bool
}
func MatchMayChangeInTheFuture(matcher GomegaMatcher, value interface{}) bool {
oracleMatcher, ok := matcher.(OracleMatcher)
if !ok {
return true
}
return oracleMatcher.MatchMayChangeInTheFuture(value)
}
// AsyncAssertions are returned by Eventually and Consistently and enable matchers to be polled repeatedly to ensure
// they are eventually satisfied
type AsyncAssertion interface {
Should(matcher GomegaMatcher, optionalDescription ...interface{}) bool
ShouldNot(matcher GomegaMatcher, optionalDescription ...interface{}) bool
WithOffset(offset int) AsyncAssertion
WithTimeout(interval time.Duration) AsyncAssertion
WithPolling(interval time.Duration) AsyncAssertion
Within(timeout time.Duration) AsyncAssertion
ProbeEvery(interval time.Duration) AsyncAssertion
WithContext(ctx context.Context) AsyncAssertion
WithArguments(argsToForward ...interface{}) AsyncAssertion
MustPassRepeatedly(count int) AsyncAssertion
}
// Assertions are returned by Ω and Expect and enable assertions against Gomega matchers
type Assertion interface {
Should(matcher GomegaMatcher, optionalDescription ...interface{}) bool
ShouldNot(matcher GomegaMatcher, optionalDescription ...interface{}) bool
To(matcher GomegaMatcher, optionalDescription ...interface{}) bool
ToNot(matcher GomegaMatcher, optionalDescription ...interface{}) bool
NotTo(matcher GomegaMatcher, optionalDescription ...interface{}) bool
WithOffset(offset int) Assertion
Error() Assertion
}
| go | Apache-2.0 | b3b4703e958c25d54c4d48138d9e80ae32fadac3 | 2026-01-07T09:44:30.792320Z | false |
kubev2v/forklift | https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/github.com/onsi/gomega/internal/polling_signal_error.go | vendor/github.com/onsi/gomega/internal/polling_signal_error.go | package internal
import (
"errors"
"fmt"
"time"
)
type PollingSignalErrorType int
const (
PollingSignalErrorTypeStopTrying PollingSignalErrorType = iota
PollingSignalErrorTypeTryAgainAfter
)
type PollingSignalError interface {
error
Wrap(err error) PollingSignalError
Attach(description string, obj any) PollingSignalError
Successfully() PollingSignalError
Now()
}
var StopTrying = func(message string) PollingSignalError {
return &PollingSignalErrorImpl{
message: message,
pollingSignalErrorType: PollingSignalErrorTypeStopTrying,
}
}
var TryAgainAfter = func(duration time.Duration) PollingSignalError {
return &PollingSignalErrorImpl{
message: fmt.Sprintf("told to try again after %s", duration),
duration: duration,
pollingSignalErrorType: PollingSignalErrorTypeTryAgainAfter,
}
}
type PollingSignalErrorAttachment struct {
Description string
Object any
}
type PollingSignalErrorImpl struct {
message string
wrappedErr error
pollingSignalErrorType PollingSignalErrorType
duration time.Duration
successful bool
Attachments []PollingSignalErrorAttachment
}
func (s *PollingSignalErrorImpl) Wrap(err error) PollingSignalError {
s.wrappedErr = err
return s
}
func (s *PollingSignalErrorImpl) Attach(description string, obj any) PollingSignalError {
s.Attachments = append(s.Attachments, PollingSignalErrorAttachment{description, obj})
return s
}
func (s *PollingSignalErrorImpl) Error() string {
if s.wrappedErr == nil {
return s.message
} else {
return s.message + ": " + s.wrappedErr.Error()
}
}
func (s *PollingSignalErrorImpl) Unwrap() error {
if s == nil {
return nil
}
return s.wrappedErr
}
func (s *PollingSignalErrorImpl) Successfully() PollingSignalError {
s.successful = true
return s
}
func (s *PollingSignalErrorImpl) Now() {
panic(s)
}
func (s *PollingSignalErrorImpl) IsStopTrying() bool {
return s.pollingSignalErrorType == PollingSignalErrorTypeStopTrying
}
func (s *PollingSignalErrorImpl) IsSuccessful() bool {
return s.successful
}
func (s *PollingSignalErrorImpl) IsTryAgainAfter() bool {
return s.pollingSignalErrorType == PollingSignalErrorTypeTryAgainAfter
}
func (s *PollingSignalErrorImpl) TryAgainDuration() time.Duration {
return s.duration
}
func AsPollingSignalError(actual interface{}) (*PollingSignalErrorImpl, bool) {
if actual == nil {
return nil, false
}
if actualErr, ok := actual.(error); ok {
var target *PollingSignalErrorImpl
if errors.As(actualErr, &target) {
return target, true
} else {
return nil, false
}
}
return nil, false
}
| go | Apache-2.0 | b3b4703e958c25d54c4d48138d9e80ae32fadac3 | 2026-01-07T09:44:30.792320Z | false |
kubev2v/forklift | https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/github.com/onsi/gomega/internal/duration_bundle.go | vendor/github.com/onsi/gomega/internal/duration_bundle.go | package internal
import (
"fmt"
"os"
"reflect"
"time"
)
type DurationBundle struct {
EventuallyTimeout time.Duration
EventuallyPollingInterval time.Duration
ConsistentlyDuration time.Duration
ConsistentlyPollingInterval time.Duration
EnforceDefaultTimeoutsWhenUsingContexts bool
}
const (
EventuallyTimeoutEnvVarName = "GOMEGA_DEFAULT_EVENTUALLY_TIMEOUT"
EventuallyPollingIntervalEnvVarName = "GOMEGA_DEFAULT_EVENTUALLY_POLLING_INTERVAL"
ConsistentlyDurationEnvVarName = "GOMEGA_DEFAULT_CONSISTENTLY_DURATION"
ConsistentlyPollingIntervalEnvVarName = "GOMEGA_DEFAULT_CONSISTENTLY_POLLING_INTERVAL"
EnforceDefaultTimeoutsWhenUsingContextsEnvVarName = "GOMEGA_ENFORCE_DEFAULT_TIMEOUTS_WHEN_USING_CONTEXTS"
)
func FetchDefaultDurationBundle() DurationBundle {
_, EnforceDefaultTimeoutsWhenUsingContexts := os.LookupEnv(EnforceDefaultTimeoutsWhenUsingContextsEnvVarName)
return DurationBundle{
EventuallyTimeout: durationFromEnv(EventuallyTimeoutEnvVarName, time.Second),
EventuallyPollingInterval: durationFromEnv(EventuallyPollingIntervalEnvVarName, 10*time.Millisecond),
ConsistentlyDuration: durationFromEnv(ConsistentlyDurationEnvVarName, 100*time.Millisecond),
ConsistentlyPollingInterval: durationFromEnv(ConsistentlyPollingIntervalEnvVarName, 10*time.Millisecond),
EnforceDefaultTimeoutsWhenUsingContexts: EnforceDefaultTimeoutsWhenUsingContexts,
}
}
func durationFromEnv(key string, defaultDuration time.Duration) time.Duration {
value := os.Getenv(key)
if value == "" {
return defaultDuration
}
duration, err := time.ParseDuration(value)
if err != nil {
panic(fmt.Sprintf("Expected a duration when using %s! Parse error %v", key, err))
}
return duration
}
func toDuration(input interface{}) (time.Duration, error) {
duration, ok := input.(time.Duration)
if ok {
return duration, nil
}
value := reflect.ValueOf(input)
kind := reflect.TypeOf(input).Kind()
if reflect.Int <= kind && kind <= reflect.Int64 {
return time.Duration(value.Int()) * time.Second, nil
} else if reflect.Uint <= kind && kind <= reflect.Uint64 {
return time.Duration(value.Uint()) * time.Second, nil
} else if reflect.Float32 <= kind && kind <= reflect.Float64 {
return time.Duration(value.Float() * float64(time.Second)), nil
} else if reflect.String == kind {
duration, err := time.ParseDuration(value.String())
if err != nil {
return 0, fmt.Errorf("%#v is not a valid parsable duration string: %w", input, err)
}
return duration, nil
}
return 0, fmt.Errorf("%#v is not a valid interval. Must be a time.Duration, a parsable duration string, or a number.", input)
}
| go | Apache-2.0 | b3b4703e958c25d54c4d48138d9e80ae32fadac3 | 2026-01-07T09:44:30.792320Z | false |
kubev2v/forklift | https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/github.com/onsi/gomega/internal/gomega.go | vendor/github.com/onsi/gomega/internal/gomega.go | package internal
import (
"context"
"time"
"github.com/onsi/gomega/types"
)
type Gomega struct {
Fail types.GomegaFailHandler
THelper func()
DurationBundle DurationBundle
}
func NewGomega(bundle DurationBundle) *Gomega {
return &Gomega{
Fail: nil,
THelper: nil,
DurationBundle: bundle,
}
}
func (g *Gomega) IsConfigured() bool {
return g.Fail != nil && g.THelper != nil
}
func (g *Gomega) ConfigureWithFailHandler(fail types.GomegaFailHandler) *Gomega {
g.Fail = fail
g.THelper = func() {}
return g
}
func (g *Gomega) ConfigureWithT(t types.GomegaTestingT) *Gomega {
g.Fail = func(message string, _ ...int) {
t.Helper()
t.Fatalf("\n%s", message)
}
g.THelper = t.Helper
return g
}
func (g *Gomega) Ω(actual interface{}, extra ...interface{}) types.Assertion {
return g.ExpectWithOffset(0, actual, extra...)
}
func (g *Gomega) Expect(actual interface{}, extra ...interface{}) types.Assertion {
return g.ExpectWithOffset(0, actual, extra...)
}
func (g *Gomega) ExpectWithOffset(offset int, actual interface{}, extra ...interface{}) types.Assertion {
return NewAssertion(actual, g, offset, extra...)
}
func (g *Gomega) Eventually(actualOrCtx interface{}, args ...interface{}) types.AsyncAssertion {
return g.makeAsyncAssertion(AsyncAssertionTypeEventually, 0, actualOrCtx, args...)
}
func (g *Gomega) EventuallyWithOffset(offset int, actualOrCtx interface{}, args ...interface{}) types.AsyncAssertion {
return g.makeAsyncAssertion(AsyncAssertionTypeEventually, offset, actualOrCtx, args...)
}
func (g *Gomega) Consistently(actualOrCtx interface{}, args ...interface{}) types.AsyncAssertion {
return g.makeAsyncAssertion(AsyncAssertionTypeConsistently, 0, actualOrCtx, args...)
}
func (g *Gomega) ConsistentlyWithOffset(offset int, actualOrCtx interface{}, args ...interface{}) types.AsyncAssertion {
return g.makeAsyncAssertion(AsyncAssertionTypeConsistently, offset, actualOrCtx, args...)
}
func (g *Gomega) makeAsyncAssertion(asyncAssertionType AsyncAssertionType, offset int, actualOrCtx interface{}, args ...interface{}) types.AsyncAssertion {
baseOffset := 3
timeoutInterval := -time.Duration(1)
pollingInterval := -time.Duration(1)
intervals := []interface{}{}
var ctx context.Context
actual := actualOrCtx
startingIndex := 0
if _, isCtx := actualOrCtx.(context.Context); isCtx && len(args) > 0 {
// the first argument is a context, we should accept it as the context _only if_ it is **not** the only argumnent **and** the second argument is not a parseable duration
// this is due to an unfortunate ambiguity in early version of Gomega in which multi-type durations are allowed after the actual
if _, err := toDuration(args[0]); err != nil {
ctx = actualOrCtx.(context.Context)
actual = args[0]
startingIndex = 1
}
}
for _, arg := range args[startingIndex:] {
switch v := arg.(type) {
case context.Context:
ctx = v
default:
intervals = append(intervals, arg)
}
}
var err error
if len(intervals) > 0 {
timeoutInterval, err = toDuration(intervals[0])
if err != nil {
g.Fail(err.Error(), offset+baseOffset)
}
}
if len(intervals) > 1 {
pollingInterval, err = toDuration(intervals[1])
if err != nil {
g.Fail(err.Error(), offset+baseOffset)
}
}
return NewAsyncAssertion(asyncAssertionType, actual, g, timeoutInterval, pollingInterval, 1, ctx, offset)
}
func (g *Gomega) SetDefaultEventuallyTimeout(t time.Duration) {
g.DurationBundle.EventuallyTimeout = t
}
func (g *Gomega) SetDefaultEventuallyPollingInterval(t time.Duration) {
g.DurationBundle.EventuallyPollingInterval = t
}
func (g *Gomega) SetDefaultConsistentlyDuration(t time.Duration) {
g.DurationBundle.ConsistentlyDuration = t
}
func (g *Gomega) SetDefaultConsistentlyPollingInterval(t time.Duration) {
g.DurationBundle.ConsistentlyPollingInterval = t
}
func (g *Gomega) EnforceDefaultTimeoutsWhenUsingContexts() {
g.DurationBundle.EnforceDefaultTimeoutsWhenUsingContexts = true
}
func (g *Gomega) DisableDefaultTimeoutsWhenUsingContext() {
g.DurationBundle.EnforceDefaultTimeoutsWhenUsingContexts = false
}
| go | Apache-2.0 | b3b4703e958c25d54c4d48138d9e80ae32fadac3 | 2026-01-07T09:44:30.792320Z | false |
kubev2v/forklift | https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/github.com/onsi/gomega/internal/async_assertion.go | vendor/github.com/onsi/gomega/internal/async_assertion.go | package internal
import (
"context"
"errors"
"fmt"
"reflect"
"runtime"
"sync"
"time"
"github.com/onsi/gomega/format"
"github.com/onsi/gomega/types"
)
var errInterface = reflect.TypeOf((*error)(nil)).Elem()
var gomegaType = reflect.TypeOf((*types.Gomega)(nil)).Elem()
var contextType = reflect.TypeOf(new(context.Context)).Elem()
type formattedGomegaError interface {
FormattedGomegaError() string
}
type asyncPolledActualError struct {
message string
}
func (err *asyncPolledActualError) Error() string {
return err.message
}
func (err *asyncPolledActualError) FormattedGomegaError() string {
return err.message
}
type contextWithAttachProgressReporter interface {
AttachProgressReporter(func() string) func()
}
type asyncGomegaHaltExecutionError struct{}
func (a asyncGomegaHaltExecutionError) GinkgoRecoverShouldIgnoreThisPanic() {}
func (a asyncGomegaHaltExecutionError) Error() string {
return `An assertion has failed in a goroutine. You should call
defer GinkgoRecover()
at the top of the goroutine that caused this panic. This will allow Ginkgo and Gomega to correctly capture and manage this panic.`
}
type AsyncAssertionType uint
const (
AsyncAssertionTypeEventually AsyncAssertionType = iota
AsyncAssertionTypeConsistently
)
func (at AsyncAssertionType) String() string {
switch at {
case AsyncAssertionTypeEventually:
return "Eventually"
case AsyncAssertionTypeConsistently:
return "Consistently"
}
return "INVALID ASYNC ASSERTION TYPE"
}
type AsyncAssertion struct {
asyncType AsyncAssertionType
actualIsFunc bool
actual interface{}
argsToForward []interface{}
timeoutInterval time.Duration
pollingInterval time.Duration
mustPassRepeatedly int
ctx context.Context
offset int
g *Gomega
}
func NewAsyncAssertion(asyncType AsyncAssertionType, actualInput interface{}, g *Gomega, timeoutInterval time.Duration, pollingInterval time.Duration, mustPassRepeatedly int, ctx context.Context, offset int) *AsyncAssertion {
out := &AsyncAssertion{
asyncType: asyncType,
timeoutInterval: timeoutInterval,
pollingInterval: pollingInterval,
mustPassRepeatedly: mustPassRepeatedly,
offset: offset,
ctx: ctx,
g: g,
}
out.actual = actualInput
if actualInput != nil && reflect.TypeOf(actualInput).Kind() == reflect.Func {
out.actualIsFunc = true
}
return out
}
func (assertion *AsyncAssertion) WithOffset(offset int) types.AsyncAssertion {
assertion.offset = offset
return assertion
}
func (assertion *AsyncAssertion) WithTimeout(interval time.Duration) types.AsyncAssertion {
assertion.timeoutInterval = interval
return assertion
}
func (assertion *AsyncAssertion) WithPolling(interval time.Duration) types.AsyncAssertion {
assertion.pollingInterval = interval
return assertion
}
func (assertion *AsyncAssertion) Within(timeout time.Duration) types.AsyncAssertion {
assertion.timeoutInterval = timeout
return assertion
}
func (assertion *AsyncAssertion) ProbeEvery(interval time.Duration) types.AsyncAssertion {
assertion.pollingInterval = interval
return assertion
}
func (assertion *AsyncAssertion) WithContext(ctx context.Context) types.AsyncAssertion {
assertion.ctx = ctx
return assertion
}
func (assertion *AsyncAssertion) WithArguments(argsToForward ...interface{}) types.AsyncAssertion {
assertion.argsToForward = argsToForward
return assertion
}
func (assertion *AsyncAssertion) MustPassRepeatedly(count int) types.AsyncAssertion {
assertion.mustPassRepeatedly = count
return assertion
}
func (assertion *AsyncAssertion) Should(matcher types.GomegaMatcher, optionalDescription ...interface{}) bool {
assertion.g.THelper()
vetOptionalDescription("Asynchronous assertion", optionalDescription...)
return assertion.match(matcher, true, optionalDescription...)
}
func (assertion *AsyncAssertion) ShouldNot(matcher types.GomegaMatcher, optionalDescription ...interface{}) bool {
assertion.g.THelper()
vetOptionalDescription("Asynchronous assertion", optionalDescription...)
return assertion.match(matcher, false, optionalDescription...)
}
func (assertion *AsyncAssertion) buildDescription(optionalDescription ...interface{}) string {
switch len(optionalDescription) {
case 0:
return ""
case 1:
if describe, ok := optionalDescription[0].(func() string); ok {
return describe() + "\n"
}
}
return fmt.Sprintf(optionalDescription[0].(string), optionalDescription[1:]...) + "\n"
}
func (assertion *AsyncAssertion) processReturnValues(values []reflect.Value) (interface{}, error) {
if len(values) == 0 {
return nil, &asyncPolledActualError{
message: fmt.Sprintf("The function passed to %s did not return any values", assertion.asyncType),
}
}
actual := values[0].Interface()
if _, ok := AsPollingSignalError(actual); ok {
return actual, actual.(error)
}
var err error
for i, extraValue := range values[1:] {
extra := extraValue.Interface()
if extra == nil {
continue
}
if _, ok := AsPollingSignalError(extra); ok {
return actual, extra.(error)
}
extraType := reflect.TypeOf(extra)
zero := reflect.Zero(extraType).Interface()
if reflect.DeepEqual(extra, zero) {
continue
}
if i == len(values)-2 && extraType.Implements(errInterface) {
err = extra.(error)
}
if err == nil {
err = &asyncPolledActualError{
message: fmt.Sprintf("The function passed to %s had an unexpected non-nil/non-zero return value at index %d:\n%s", assertion.asyncType, i+1, format.Object(extra, 1)),
}
}
}
return actual, err
}
func (assertion *AsyncAssertion) invalidFunctionError(t reflect.Type) error {
return fmt.Errorf(`The function passed to %s had an invalid signature of %s. Functions passed to %s must either:
(a) have return values or
(b) take a Gomega interface as their first argument and use that Gomega instance to make assertions.
You can learn more at https://onsi.github.io/gomega/#eventually
`, assertion.asyncType, t, assertion.asyncType)
}
func (assertion *AsyncAssertion) noConfiguredContextForFunctionError() error {
return fmt.Errorf(`The function passed to %s requested a context.Context, but no context has been provided. Please pass one in using %s().WithContext().
You can learn more at https://onsi.github.io/gomega/#eventually
`, assertion.asyncType, assertion.asyncType)
}
func (assertion *AsyncAssertion) argumentMismatchError(t reflect.Type, numProvided int) error {
have := "have"
if numProvided == 1 {
have = "has"
}
return fmt.Errorf(`The function passed to %s has signature %s takes %d arguments but %d %s been provided. Please use %s().WithArguments() to pass the corect set of arguments.
You can learn more at https://onsi.github.io/gomega/#eventually
`, assertion.asyncType, t, t.NumIn(), numProvided, have, assertion.asyncType)
}
func (assertion *AsyncAssertion) invalidMustPassRepeatedlyError(reason string) error {
return fmt.Errorf(`Invalid use of MustPassRepeatedly with %s %s
You can learn more at https://onsi.github.io/gomega/#eventually
`, assertion.asyncType, reason)
}
func (assertion *AsyncAssertion) buildActualPoller() (func() (interface{}, error), error) {
if !assertion.actualIsFunc {
return func() (interface{}, error) { return assertion.actual, nil }, nil
}
actualValue := reflect.ValueOf(assertion.actual)
actualType := reflect.TypeOf(assertion.actual)
numIn, numOut, isVariadic := actualType.NumIn(), actualType.NumOut(), actualType.IsVariadic()
if numIn == 0 && numOut == 0 {
return nil, assertion.invalidFunctionError(actualType)
}
takesGomega, takesContext := false, false
if numIn > 0 {
takesGomega, takesContext = actualType.In(0).Implements(gomegaType), actualType.In(0).Implements(contextType)
}
if takesGomega && numIn > 1 && actualType.In(1).Implements(contextType) {
takesContext = true
}
if takesContext && len(assertion.argsToForward) > 0 && reflect.TypeOf(assertion.argsToForward[0]).Implements(contextType) {
takesContext = false
}
if !takesGomega && numOut == 0 {
return nil, assertion.invalidFunctionError(actualType)
}
if takesContext && assertion.ctx == nil {
return nil, assertion.noConfiguredContextForFunctionError()
}
var assertionFailure error
inValues := []reflect.Value{}
if takesGomega {
inValues = append(inValues, reflect.ValueOf(NewGomega(assertion.g.DurationBundle).ConfigureWithFailHandler(func(message string, callerSkip ...int) {
skip := 0
if len(callerSkip) > 0 {
skip = callerSkip[0]
}
_, file, line, _ := runtime.Caller(skip + 1)
assertionFailure = &asyncPolledActualError{
message: fmt.Sprintf("The function passed to %s failed at %s:%d with:\n%s", assertion.asyncType, file, line, message),
}
// we throw an asyncGomegaHaltExecutionError so that defer GinkgoRecover() can catch this error if the user makes an assertion in a goroutine
panic(asyncGomegaHaltExecutionError{})
})))
}
if takesContext {
inValues = append(inValues, reflect.ValueOf(assertion.ctx))
}
for _, arg := range assertion.argsToForward {
inValues = append(inValues, reflect.ValueOf(arg))
}
if !isVariadic && numIn != len(inValues) {
return nil, assertion.argumentMismatchError(actualType, len(inValues))
} else if isVariadic && len(inValues) < numIn-1 {
return nil, assertion.argumentMismatchError(actualType, len(inValues))
}
if assertion.mustPassRepeatedly != 1 && assertion.asyncType != AsyncAssertionTypeEventually {
return nil, assertion.invalidMustPassRepeatedlyError("it can only be used with Eventually")
}
if assertion.mustPassRepeatedly < 1 {
return nil, assertion.invalidMustPassRepeatedlyError("parameter can't be < 1")
}
return func() (actual interface{}, err error) {
var values []reflect.Value
assertionFailure = nil
defer func() {
if numOut == 0 && takesGomega {
actual = assertionFailure
} else {
actual, err = assertion.processReturnValues(values)
_, isAsyncError := AsPollingSignalError(err)
if assertionFailure != nil && !isAsyncError {
err = assertionFailure
}
}
if e := recover(); e != nil {
if _, isAsyncError := AsPollingSignalError(e); isAsyncError {
err = e.(error)
} else if assertionFailure == nil {
panic(e)
}
}
}()
values = actualValue.Call(inValues)
return
}, nil
}
func (assertion *AsyncAssertion) afterTimeout() <-chan time.Time {
if assertion.timeoutInterval >= 0 {
return time.After(assertion.timeoutInterval)
}
if assertion.asyncType == AsyncAssertionTypeConsistently {
return time.After(assertion.g.DurationBundle.ConsistentlyDuration)
} else {
if assertion.ctx == nil || assertion.g.DurationBundle.EnforceDefaultTimeoutsWhenUsingContexts {
return time.After(assertion.g.DurationBundle.EventuallyTimeout)
} else {
return nil
}
}
}
func (assertion *AsyncAssertion) afterPolling() <-chan time.Time {
if assertion.pollingInterval >= 0 {
return time.After(assertion.pollingInterval)
}
if assertion.asyncType == AsyncAssertionTypeConsistently {
return time.After(assertion.g.DurationBundle.ConsistentlyPollingInterval)
} else {
return time.After(assertion.g.DurationBundle.EventuallyPollingInterval)
}
}
func (assertion *AsyncAssertion) matcherSaysStopTrying(matcher types.GomegaMatcher, value interface{}) bool {
if assertion.actualIsFunc || types.MatchMayChangeInTheFuture(matcher, value) {
return false
}
return true
}
func (assertion *AsyncAssertion) pollMatcher(matcher types.GomegaMatcher, value interface{}) (matches bool, err error) {
defer func() {
if e := recover(); e != nil {
if _, isAsyncError := AsPollingSignalError(e); isAsyncError {
err = e.(error)
} else {
panic(e)
}
}
}()
matches, err = matcher.Match(value)
return
}
func (assertion *AsyncAssertion) match(matcher types.GomegaMatcher, desiredMatch bool, optionalDescription ...interface{}) bool {
timer := time.Now()
timeout := assertion.afterTimeout()
lock := sync.Mutex{}
var matches, hasLastValidActual bool
var actual, lastValidActual interface{}
var actualErr, matcherErr error
var oracleMatcherSaysStop bool
assertion.g.THelper()
pollActual, buildActualPollerErr := assertion.buildActualPoller()
if buildActualPollerErr != nil {
assertion.g.Fail(buildActualPollerErr.Error(), 2+assertion.offset)
return false
}
actual, actualErr = pollActual()
if actualErr == nil {
lastValidActual = actual
hasLastValidActual = true
oracleMatcherSaysStop = assertion.matcherSaysStopTrying(matcher, actual)
matches, matcherErr = assertion.pollMatcher(matcher, actual)
}
renderError := func(preamble string, err error) string {
message := ""
if pollingSignalErr, ok := AsPollingSignalError(err); ok {
message = err.Error()
for _, attachment := range pollingSignalErr.Attachments {
message += fmt.Sprintf("\n%s:\n", attachment.Description)
message += format.Object(attachment.Object, 1)
}
} else {
message = preamble + "\n" + format.Object(err, 1)
}
return message
}
messageGenerator := func() string {
// can be called out of band by Ginkgo if the user requests a progress report
lock.Lock()
defer lock.Unlock()
message := ""
if actualErr == nil {
if matcherErr == nil {
if desiredMatch != matches {
if desiredMatch {
message += matcher.FailureMessage(actual)
} else {
message += matcher.NegatedFailureMessage(actual)
}
} else {
if assertion.asyncType == AsyncAssertionTypeConsistently {
message += "There is no failure as the matcher passed to Consistently has not yet failed"
} else {
message += "There is no failure as the matcher passed to Eventually succeeded on its most recent iteration"
}
}
} else {
var fgErr formattedGomegaError
if errors.As(actualErr, &fgErr) {
message += fgErr.FormattedGomegaError() + "\n"
} else {
message += renderError(fmt.Sprintf("The matcher passed to %s returned the following error:", assertion.asyncType), matcherErr)
}
}
} else {
var fgErr formattedGomegaError
if errors.As(actualErr, &fgErr) {
message += fgErr.FormattedGomegaError() + "\n"
} else {
message += renderError(fmt.Sprintf("The function passed to %s returned the following error:", assertion.asyncType), actualErr)
}
if hasLastValidActual {
message += fmt.Sprintf("\nAt one point, however, the function did return successfully.\nYet, %s failed because", assertion.asyncType)
_, e := matcher.Match(lastValidActual)
if e != nil {
message += renderError(" the matcher returned the following error:", e)
} else {
message += " the matcher was not satisfied:\n"
if desiredMatch {
message += matcher.FailureMessage(lastValidActual)
} else {
message += matcher.NegatedFailureMessage(lastValidActual)
}
}
}
}
description := assertion.buildDescription(optionalDescription...)
return fmt.Sprintf("%s%s", description, message)
}
fail := func(preamble string) {
assertion.g.THelper()
assertion.g.Fail(fmt.Sprintf("%s after %.3fs.\n%s", preamble, time.Since(timer).Seconds(), messageGenerator()), 3+assertion.offset)
}
var contextDone <-chan struct{}
if assertion.ctx != nil {
contextDone = assertion.ctx.Done()
if v, ok := assertion.ctx.Value("GINKGO_SPEC_CONTEXT").(contextWithAttachProgressReporter); ok {
detach := v.AttachProgressReporter(messageGenerator)
defer detach()
}
}
// Used to count the number of times in a row a step passed
passedRepeatedlyCount := 0
for {
var nextPoll <-chan time.Time = nil
var isTryAgainAfterError = false
for _, err := range []error{actualErr, matcherErr} {
if pollingSignalErr, ok := AsPollingSignalError(err); ok {
if pollingSignalErr.IsStopTrying() {
if pollingSignalErr.IsSuccessful() {
if assertion.asyncType == AsyncAssertionTypeEventually {
fail("Told to stop trying (and ignoring call to Successfully(), as it is only relevant with Consistently)")
} else {
return true // early escape hatch for Consistently
}
} else {
fail("Told to stop trying")
}
return false
}
if pollingSignalErr.IsTryAgainAfter() {
nextPoll = time.After(pollingSignalErr.TryAgainDuration())
isTryAgainAfterError = true
}
}
}
if actualErr == nil && matcherErr == nil && matches == desiredMatch {
if assertion.asyncType == AsyncAssertionTypeEventually {
passedRepeatedlyCount += 1
if passedRepeatedlyCount == assertion.mustPassRepeatedly {
return true
}
}
} else if !isTryAgainAfterError {
if assertion.asyncType == AsyncAssertionTypeConsistently {
fail("Failed")
return false
}
// Reset the consecutive pass count
passedRepeatedlyCount = 0
}
if oracleMatcherSaysStop {
if assertion.asyncType == AsyncAssertionTypeEventually {
fail("No future change is possible. Bailing out early")
return false
} else {
return true
}
}
if nextPoll == nil {
nextPoll = assertion.afterPolling()
}
select {
case <-nextPoll:
a, e := pollActual()
lock.Lock()
actual, actualErr = a, e
lock.Unlock()
if actualErr == nil {
lock.Lock()
lastValidActual = actual
hasLastValidActual = true
lock.Unlock()
oracleMatcherSaysStop = assertion.matcherSaysStopTrying(matcher, actual)
m, e := assertion.pollMatcher(matcher, actual)
lock.Lock()
matches, matcherErr = m, e
lock.Unlock()
}
case <-contextDone:
err := context.Cause(assertion.ctx)
if err != nil && err != context.Canceled {
fail(fmt.Sprintf("Context was cancelled (cause: %s)", err))
} else {
fail("Context was cancelled")
}
return false
case <-timeout:
if assertion.asyncType == AsyncAssertionTypeEventually {
fail("Timed out")
return false
} else {
if isTryAgainAfterError {
fail("Timed out while waiting on TryAgainAfter")
return false
}
return true
}
}
}
}
| go | Apache-2.0 | b3b4703e958c25d54c4d48138d9e80ae32fadac3 | 2026-01-07T09:44:30.792320Z | false |
kubev2v/forklift | https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/github.com/onsi/gomega/internal/assertion.go | vendor/github.com/onsi/gomega/internal/assertion.go | package internal
import (
"fmt"
"reflect"
"github.com/onsi/gomega/format"
"github.com/onsi/gomega/types"
)
type Assertion struct {
actuals []interface{} // actual value plus all extra values
actualIndex int // value to pass to the matcher
vet vetinari // the vet to call before calling Gomega matcher
offset int
g *Gomega
}
// ...obligatory discworld reference, as "vetineer" doesn't sound ... quite right.
type vetinari func(assertion *Assertion, optionalDescription ...interface{}) bool
func NewAssertion(actualInput interface{}, g *Gomega, offset int, extra ...interface{}) *Assertion {
return &Assertion{
actuals: append([]interface{}{actualInput}, extra...),
actualIndex: 0,
vet: (*Assertion).vetActuals,
offset: offset,
g: g,
}
}
func (assertion *Assertion) WithOffset(offset int) types.Assertion {
assertion.offset = offset
return assertion
}
func (assertion *Assertion) Error() types.Assertion {
return &Assertion{
actuals: assertion.actuals,
actualIndex: len(assertion.actuals) - 1,
vet: (*Assertion).vetError,
offset: assertion.offset,
g: assertion.g,
}
}
func (assertion *Assertion) Should(matcher types.GomegaMatcher, optionalDescription ...interface{}) bool {
assertion.g.THelper()
vetOptionalDescription("Assertion", optionalDescription...)
return assertion.vet(assertion, optionalDescription...) && assertion.match(matcher, true, optionalDescription...)
}
func (assertion *Assertion) ShouldNot(matcher types.GomegaMatcher, optionalDescription ...interface{}) bool {
assertion.g.THelper()
vetOptionalDescription("Assertion", optionalDescription...)
return assertion.vet(assertion, optionalDescription...) && assertion.match(matcher, false, optionalDescription...)
}
func (assertion *Assertion) To(matcher types.GomegaMatcher, optionalDescription ...interface{}) bool {
assertion.g.THelper()
vetOptionalDescription("Assertion", optionalDescription...)
return assertion.vet(assertion, optionalDescription...) && assertion.match(matcher, true, optionalDescription...)
}
func (assertion *Assertion) ToNot(matcher types.GomegaMatcher, optionalDescription ...interface{}) bool {
assertion.g.THelper()
vetOptionalDescription("Assertion", optionalDescription...)
return assertion.vet(assertion, optionalDescription...) && assertion.match(matcher, false, optionalDescription...)
}
func (assertion *Assertion) NotTo(matcher types.GomegaMatcher, optionalDescription ...interface{}) bool {
assertion.g.THelper()
vetOptionalDescription("Assertion", optionalDescription...)
return assertion.vet(assertion, optionalDescription...) && assertion.match(matcher, false, optionalDescription...)
}
func (assertion *Assertion) buildDescription(optionalDescription ...interface{}) string {
switch len(optionalDescription) {
case 0:
return ""
case 1:
if describe, ok := optionalDescription[0].(func() string); ok {
return describe() + "\n"
}
}
return fmt.Sprintf(optionalDescription[0].(string), optionalDescription[1:]...) + "\n"
}
func (assertion *Assertion) match(matcher types.GomegaMatcher, desiredMatch bool, optionalDescription ...interface{}) bool {
actualInput := assertion.actuals[assertion.actualIndex]
matches, err := matcher.Match(actualInput)
assertion.g.THelper()
if err != nil {
description := assertion.buildDescription(optionalDescription...)
assertion.g.Fail(description+err.Error(), 2+assertion.offset)
return false
}
if matches != desiredMatch {
var message string
if desiredMatch {
message = matcher.FailureMessage(actualInput)
} else {
message = matcher.NegatedFailureMessage(actualInput)
}
description := assertion.buildDescription(optionalDescription...)
assertion.g.Fail(description+message, 2+assertion.offset)
return false
}
return true
}
// vetActuals vets the actual values, with the (optional) exception of a
// specific value, such as the first value in case non-error assertions, or the
// last value in case of Error()-based assertions.
func (assertion *Assertion) vetActuals(optionalDescription ...interface{}) bool {
success, message := vetActuals(assertion.actuals, assertion.actualIndex)
if success {
return true
}
description := assertion.buildDescription(optionalDescription...)
assertion.g.THelper()
assertion.g.Fail(description+message, 2+assertion.offset)
return false
}
// vetError vets the actual values, except for the final error value, in case
// the final error value is non-zero. Otherwise, it doesn't vet the actual
// values, as these are allowed to take on any values unless there is a non-zero
// error value.
func (assertion *Assertion) vetError(optionalDescription ...interface{}) bool {
if err := assertion.actuals[assertion.actualIndex]; err != nil {
// Go error result idiom: all other actual values must be zero values.
return assertion.vetActuals(optionalDescription...)
}
return true
}
// vetActuals vets a slice of actual values, optionally skipping a particular
// value slice element, such as the first or last value slice element.
func vetActuals(actuals []interface{}, skipIndex int) (bool, string) {
for i, actual := range actuals {
if i == skipIndex {
continue
}
if actual != nil {
zeroValue := reflect.Zero(reflect.TypeOf(actual)).Interface()
if !reflect.DeepEqual(zeroValue, actual) {
var message string
if err, ok := actual.(error); ok {
message = fmt.Sprintf("Unexpected error: %s\n%s", err, format.Object(err, 1))
} else {
message = fmt.Sprintf("Unexpected non-nil/non-zero argument at index %d:\n\t<%T>: %#v", i, actual, actual)
}
return false, message
}
}
}
return true, ""
}
| go | Apache-2.0 | b3b4703e958c25d54c4d48138d9e80ae32fadac3 | 2026-01-07T09:44:30.792320Z | false |
kubev2v/forklift | https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/github.com/onsi/gomega/internal/vetoptdesc.go | vendor/github.com/onsi/gomega/internal/vetoptdesc.go | package internal
import (
"fmt"
"github.com/onsi/gomega/types"
)
// vetOptionalDescription vets the optional description args: if it finds any
// Gomega matcher at the beginning it panics. This allows for rendering Gomega
// matchers as part of an optional Description, as long as they're not in the
// first slot.
func vetOptionalDescription(assertion string, optionalDescription ...interface{}) {
if len(optionalDescription) == 0 {
return
}
if _, isGomegaMatcher := optionalDescription[0].(types.GomegaMatcher); isGomegaMatcher {
panic(fmt.Sprintf("%s has a GomegaMatcher as the first element of optionalDescription.\n\t"+
"Do you mean to use And/Or/SatisfyAll/SatisfyAny to combine multiple matchers?",
assertion))
}
}
| go | Apache-2.0 | b3b4703e958c25d54c4d48138d9e80ae32fadac3 | 2026-01-07T09:44:30.792320Z | false |
kubev2v/forklift | https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/github.com/onsi/gomega/internal/gutil/post_ioutil.go | vendor/github.com/onsi/gomega/internal/gutil/post_ioutil.go | //go:build go1.16
// +build go1.16
// Package gutil is a replacement for ioutil, which should not be used in new
// code as of Go 1.16. With Go 1.16 and higher, this implementation
// uses the ioutil replacement functions in "io" and "os" with some
// Gomega specifics. This means that we should not get deprecation warnings
// for ioutil when they are added.
package gutil
import (
"io"
"os"
)
func NopCloser(r io.Reader) io.ReadCloser {
return io.NopCloser(r)
}
func ReadAll(r io.Reader) ([]byte, error) {
return io.ReadAll(r)
}
func ReadDir(dirname string) ([]string, error) {
entries, err := os.ReadDir(dirname)
if err != nil {
return nil, err
}
var names []string
for _, entry := range entries {
names = append(names, entry.Name())
}
return names, nil
}
func ReadFile(filename string) ([]byte, error) {
return os.ReadFile(filename)
}
func MkdirTemp(dir, pattern string) (string, error) {
return os.MkdirTemp(dir, pattern)
}
func WriteFile(filename string, data []byte) error {
return os.WriteFile(filename, data, 0644)
}
| go | Apache-2.0 | b3b4703e958c25d54c4d48138d9e80ae32fadac3 | 2026-01-07T09:44:30.792320Z | false |
kubev2v/forklift | https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/github.com/onsi/gomega/internal/gutil/using_ioutil.go | vendor/github.com/onsi/gomega/internal/gutil/using_ioutil.go | //go:build !go1.16
// +build !go1.16
// Package gutil is a replacement for ioutil, which should not be used in new
// code as of Go 1.16. With Go 1.15 and lower, this implementation
// uses the ioutil functions, meaning that although Gomega is not officially
// supported on these versions, it is still likely to work.
package gutil
import (
"io"
"io/ioutil"
)
func NopCloser(r io.Reader) io.ReadCloser {
return ioutil.NopCloser(r)
}
func ReadAll(r io.Reader) ([]byte, error) {
return ioutil.ReadAll(r)
}
func ReadDir(dirname string) ([]string, error) {
files, err := ioutil.ReadDir(dirname)
if err != nil {
return nil, err
}
var names []string
for _, file := range files {
names = append(names, file.Name())
}
return names, nil
}
func ReadFile(filename string) ([]byte, error) {
return ioutil.ReadFile(filename)
}
func MkdirTemp(dir, pattern string) (string, error) {
return ioutil.TempDir(dir, pattern)
}
func WriteFile(filename string, data []byte) error {
return ioutil.WriteFile(filename, data, 0644)
}
| go | Apache-2.0 | b3b4703e958c25d54c4d48138d9e80ae32fadac3 | 2026-01-07T09:44:30.792320Z | false |
kubev2v/forklift | https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/github.com/onsi/gomega/matchers/be_nil_matcher.go | vendor/github.com/onsi/gomega/matchers/be_nil_matcher.go | // untested sections: 2
package matchers
import "github.com/onsi/gomega/format"
type BeNilMatcher struct {
}
func (matcher *BeNilMatcher) Match(actual interface{}) (success bool, err error) {
return isNil(actual), nil
}
func (matcher *BeNilMatcher) FailureMessage(actual interface{}) (message string) {
return format.Message(actual, "to be nil")
}
func (matcher *BeNilMatcher) NegatedFailureMessage(actual interface{}) (message string) {
return format.Message(actual, "not to be nil")
}
| go | Apache-2.0 | b3b4703e958c25d54c4d48138d9e80ae32fadac3 | 2026-01-07T09:44:30.792320Z | false |
kubev2v/forklift | https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/github.com/onsi/gomega/matchers/be_false_matcher.go | vendor/github.com/onsi/gomega/matchers/be_false_matcher.go | // untested sections: 2
package matchers
import (
"fmt"
"github.com/onsi/gomega/format"
)
type BeFalseMatcher struct {
Reason string
}
func (matcher *BeFalseMatcher) Match(actual interface{}) (success bool, err error) {
if !isBool(actual) {
return false, fmt.Errorf("Expected a boolean. Got:\n%s", format.Object(actual, 1))
}
return actual == false, nil
}
func (matcher *BeFalseMatcher) FailureMessage(actual interface{}) (message string) {
if matcher.Reason == "" {
return format.Message(actual, "to be false")
} else {
return matcher.Reason
}
}
func (matcher *BeFalseMatcher) NegatedFailureMessage(actual interface{}) (message string) {
if matcher.Reason == "" {
return format.Message(actual, "not to be false")
} else {
return fmt.Sprintf(`Expected not false but got false\nNegation of "%s" failed`, matcher.Reason)
}
}
| go | Apache-2.0 | b3b4703e958c25d54c4d48138d9e80ae32fadac3 | 2026-01-07T09:44:30.792320Z | false |
kubev2v/forklift | https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/github.com/onsi/gomega/matchers/and.go | vendor/github.com/onsi/gomega/matchers/and.go | package matchers
import (
"fmt"
"github.com/onsi/gomega/format"
"github.com/onsi/gomega/types"
)
type AndMatcher struct {
Matchers []types.GomegaMatcher
// state
firstFailedMatcher types.GomegaMatcher
}
func (m *AndMatcher) Match(actual interface{}) (success bool, err error) {
m.firstFailedMatcher = nil
for _, matcher := range m.Matchers {
success, err := matcher.Match(actual)
if !success || err != nil {
m.firstFailedMatcher = matcher
return false, err
}
}
return true, nil
}
func (m *AndMatcher) FailureMessage(actual interface{}) (message string) {
return m.firstFailedMatcher.FailureMessage(actual)
}
func (m *AndMatcher) NegatedFailureMessage(actual interface{}) (message string) {
// not the most beautiful list of matchers, but not bad either...
return format.Message(actual, fmt.Sprintf("To not satisfy all of these matchers: %s", m.Matchers))
}
func (m *AndMatcher) MatchMayChangeInTheFuture(actual interface{}) bool {
/*
Example with 3 matchers: A, B, C
Match evaluates them: T, F, <?> => F
So match is currently F, what should MatchMayChangeInTheFuture() return?
Seems like it only depends on B, since currently B MUST change to allow the result to become T
Match eval: T, T, T => T
So match is currently T, what should MatchMayChangeInTheFuture() return?
Seems to depend on ANY of them being able to change to F.
*/
if m.firstFailedMatcher == nil {
// so all matchers succeeded.. Any one of them changing would change the result.
for _, matcher := range m.Matchers {
if types.MatchMayChangeInTheFuture(matcher, actual) {
return true
}
}
return false // none of were going to change
}
// one of the matchers failed.. it must be able to change in order to affect the result
return types.MatchMayChangeInTheFuture(m.firstFailedMatcher, actual)
}
| go | Apache-2.0 | b3b4703e958c25d54c4d48138d9e80ae32fadac3 | 2026-01-07T09:44:30.792320Z | false |
kubev2v/forklift | https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/github.com/onsi/gomega/matchers/be_temporally_matcher.go | vendor/github.com/onsi/gomega/matchers/be_temporally_matcher.go | // untested sections: 3
package matchers
import (
"fmt"
"time"
"github.com/onsi/gomega/format"
)
type BeTemporallyMatcher struct {
Comparator string
CompareTo time.Time
Threshold []time.Duration
}
func (matcher *BeTemporallyMatcher) FailureMessage(actual interface{}) (message string) {
return format.Message(actual, fmt.Sprintf("to be %s", matcher.Comparator), matcher.CompareTo)
}
func (matcher *BeTemporallyMatcher) NegatedFailureMessage(actual interface{}) (message string) {
return format.Message(actual, fmt.Sprintf("not to be %s", matcher.Comparator), matcher.CompareTo)
}
func (matcher *BeTemporallyMatcher) Match(actual interface{}) (bool, error) {
// predicate to test for time.Time type
isTime := func(t interface{}) bool {
_, ok := t.(time.Time)
return ok
}
if !isTime(actual) {
return false, fmt.Errorf("Expected a time.Time. Got:\n%s", format.Object(actual, 1))
}
switch matcher.Comparator {
case "==", "~", ">", ">=", "<", "<=":
default:
return false, fmt.Errorf("Unknown comparator: %s", matcher.Comparator)
}
var threshold = time.Millisecond
if len(matcher.Threshold) == 1 {
threshold = matcher.Threshold[0]
}
return matcher.matchTimes(actual.(time.Time), matcher.CompareTo, threshold), nil
}
func (matcher *BeTemporallyMatcher) matchTimes(actual, compareTo time.Time, threshold time.Duration) (success bool) {
switch matcher.Comparator {
case "==":
return actual.Equal(compareTo)
case "~":
diff := actual.Sub(compareTo)
return -threshold <= diff && diff <= threshold
case ">":
return actual.After(compareTo)
case ">=":
return !actual.Before(compareTo)
case "<":
return actual.Before(compareTo)
case "<=":
return !actual.After(compareTo)
}
return false
}
| go | Apache-2.0 | b3b4703e958c25d54c4d48138d9e80ae32fadac3 | 2026-01-07T09:44:30.792320Z | false |
kubev2v/forklift | https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/github.com/onsi/gomega/matchers/match_xml_matcher.go | vendor/github.com/onsi/gomega/matchers/match_xml_matcher.go | package matchers
import (
"bytes"
"encoding/xml"
"errors"
"fmt"
"io"
"reflect"
"sort"
"strings"
"github.com/onsi/gomega/format"
"golang.org/x/net/html/charset"
)
type MatchXMLMatcher struct {
XMLToMatch interface{}
}
func (matcher *MatchXMLMatcher) Match(actual interface{}) (success bool, err error) {
actualString, expectedString, err := matcher.formattedPrint(actual)
if err != nil {
return false, err
}
aval, err := parseXmlContent(actualString)
if err != nil {
return false, fmt.Errorf("Actual '%s' should be valid XML, but it is not.\nUnderlying error:%s", actualString, err)
}
eval, err := parseXmlContent(expectedString)
if err != nil {
return false, fmt.Errorf("Expected '%s' should be valid XML, but it is not.\nUnderlying error:%s", expectedString, err)
}
return reflect.DeepEqual(aval, eval), nil
}
func (matcher *MatchXMLMatcher) FailureMessage(actual interface{}) (message string) {
actualString, expectedString, _ := matcher.formattedPrint(actual)
return fmt.Sprintf("Expected\n%s\nto match XML of\n%s", actualString, expectedString)
}
func (matcher *MatchXMLMatcher) NegatedFailureMessage(actual interface{}) (message string) {
actualString, expectedString, _ := matcher.formattedPrint(actual)
return fmt.Sprintf("Expected\n%s\nnot to match XML of\n%s", actualString, expectedString)
}
func (matcher *MatchXMLMatcher) formattedPrint(actual interface{}) (actualString, expectedString string, err error) {
var ok bool
actualString, ok = toString(actual)
if !ok {
return "", "", fmt.Errorf("MatchXMLMatcher matcher requires a string, stringer, or []byte. Got actual:\n%s", format.Object(actual, 1))
}
expectedString, ok = toString(matcher.XMLToMatch)
if !ok {
return "", "", fmt.Errorf("MatchXMLMatcher matcher requires a string, stringer, or []byte. Got expected:\n%s", format.Object(matcher.XMLToMatch, 1))
}
return actualString, expectedString, nil
}
func parseXmlContent(content string) (*xmlNode, error) {
allNodes := []*xmlNode{}
dec := newXmlDecoder(strings.NewReader(content))
for {
tok, err := dec.Token()
if err != nil {
if err == io.EOF {
break
}
return nil, fmt.Errorf("failed to decode next token: %v", err) // untested section
}
lastNodeIndex := len(allNodes) - 1
var lastNode *xmlNode
if len(allNodes) > 0 {
lastNode = allNodes[lastNodeIndex]
} else {
lastNode = &xmlNode{}
}
switch tok := tok.(type) {
case xml.StartElement:
attrs := attributesSlice(tok.Attr)
sort.Sort(attrs)
allNodes = append(allNodes, &xmlNode{XMLName: tok.Name, XMLAttr: tok.Attr})
case xml.EndElement:
if len(allNodes) > 1 {
allNodes[lastNodeIndex-1].Nodes = append(allNodes[lastNodeIndex-1].Nodes, lastNode)
allNodes = allNodes[:lastNodeIndex]
}
case xml.CharData:
lastNode.Content = append(lastNode.Content, tok.Copy()...)
case xml.Comment:
lastNode.Comments = append(lastNode.Comments, tok.Copy()) // untested section
case xml.ProcInst:
lastNode.ProcInsts = append(lastNode.ProcInsts, tok.Copy())
}
}
if len(allNodes) == 0 {
return nil, errors.New("found no nodes")
}
firstNode := allNodes[0]
trimParentNodesContentSpaces(firstNode)
return firstNode, nil
}
func newXmlDecoder(reader io.Reader) *xml.Decoder {
dec := xml.NewDecoder(reader)
dec.CharsetReader = charset.NewReaderLabel
return dec
}
func trimParentNodesContentSpaces(node *xmlNode) {
if len(node.Nodes) > 0 {
node.Content = bytes.TrimSpace(node.Content)
for _, childNode := range node.Nodes {
trimParentNodesContentSpaces(childNode)
}
}
}
type xmlNode struct {
XMLName xml.Name
Comments []xml.Comment
ProcInsts []xml.ProcInst
XMLAttr []xml.Attr
Content []byte
Nodes []*xmlNode
}
| go | Apache-2.0 | b3b4703e958c25d54c4d48138d9e80ae32fadac3 | 2026-01-07T09:44:30.792320Z | false |
kubev2v/forklift | https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/github.com/onsi/gomega/matchers/be_sent_matcher.go | vendor/github.com/onsi/gomega/matchers/be_sent_matcher.go | // untested sections: 3
package matchers
import (
"fmt"
"reflect"
"github.com/onsi/gomega/format"
)
type BeSentMatcher struct {
Arg interface{}
channelClosed bool
}
func (matcher *BeSentMatcher) Match(actual interface{}) (success bool, err error) {
if !isChan(actual) {
return false, fmt.Errorf("BeSent expects a channel. Got:\n%s", format.Object(actual, 1))
}
channelType := reflect.TypeOf(actual)
channelValue := reflect.ValueOf(actual)
if channelType.ChanDir() == reflect.RecvDir {
return false, fmt.Errorf("BeSent matcher cannot be passed a receive-only channel. Got:\n%s", format.Object(actual, 1))
}
argType := reflect.TypeOf(matcher.Arg)
assignable := argType.AssignableTo(channelType.Elem())
if !assignable {
return false, fmt.Errorf("Cannot pass:\n%s to the channel:\n%s\nThe types don't match.", format.Object(matcher.Arg, 1), format.Object(actual, 1))
}
argValue := reflect.ValueOf(matcher.Arg)
defer func() {
if e := recover(); e != nil {
success = false
err = fmt.Errorf("Cannot send to a closed channel")
matcher.channelClosed = true
}
}()
winnerIndex, _, _ := reflect.Select([]reflect.SelectCase{
{Dir: reflect.SelectSend, Chan: channelValue, Send: argValue},
{Dir: reflect.SelectDefault},
})
var didSend bool
if winnerIndex == 0 {
didSend = true
}
return didSend, nil
}
func (matcher *BeSentMatcher) FailureMessage(actual interface{}) (message string) {
return format.Message(actual, "to send:", matcher.Arg)
}
func (matcher *BeSentMatcher) NegatedFailureMessage(actual interface{}) (message string) {
return format.Message(actual, "not to send:", matcher.Arg)
}
func (matcher *BeSentMatcher) MatchMayChangeInTheFuture(actual interface{}) bool {
if !isChan(actual) {
return false
}
return !matcher.channelClosed
}
| go | Apache-2.0 | b3b4703e958c25d54c4d48138d9e80ae32fadac3 | 2026-01-07T09:44:30.792320Z | false |
kubev2v/forklift | https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/github.com/onsi/gomega/matchers/with_transform.go | vendor/github.com/onsi/gomega/matchers/with_transform.go | package matchers
import (
"fmt"
"reflect"
"github.com/onsi/gomega/types"
)
type WithTransformMatcher struct {
// input
Transform interface{} // must be a function of one parameter that returns one value and an optional error
Matcher types.GomegaMatcher
// cached value
transformArgType reflect.Type
// state
transformedValue interface{}
}
// reflect.Type for error
var errorT = reflect.TypeOf((*error)(nil)).Elem()
func NewWithTransformMatcher(transform interface{}, matcher types.GomegaMatcher) *WithTransformMatcher {
if transform == nil {
panic("transform function cannot be nil")
}
txType := reflect.TypeOf(transform)
if txType.NumIn() != 1 {
panic("transform function must have 1 argument")
}
if numout := txType.NumOut(); numout != 1 {
if numout != 2 || !txType.Out(1).AssignableTo(errorT) {
panic("transform function must either have 1 return value, or 1 return value plus 1 error value")
}
}
return &WithTransformMatcher{
Transform: transform,
Matcher: matcher,
transformArgType: reflect.TypeOf(transform).In(0),
}
}
func (m *WithTransformMatcher) Match(actual interface{}) (bool, error) {
// prepare a parameter to pass to the Transform function
var param reflect.Value
if actual != nil && reflect.TypeOf(actual).AssignableTo(m.transformArgType) {
// The dynamic type of actual is compatible with the transform argument.
param = reflect.ValueOf(actual)
} else if actual == nil && m.transformArgType.Kind() == reflect.Interface {
// The dynamic type of actual is unknown, so there's no way to make its
// reflect.Value. Create a nil of the transform argument, which is known.
param = reflect.Zero(m.transformArgType)
} else {
return false, fmt.Errorf("Transform function expects '%s' but we have '%T'", m.transformArgType, actual)
}
// call the Transform function with `actual`
fn := reflect.ValueOf(m.Transform)
result := fn.Call([]reflect.Value{param})
if len(result) == 2 {
if !result[1].IsNil() {
return false, fmt.Errorf("Transform function failed: %s", result[1].Interface().(error).Error())
}
}
m.transformedValue = result[0].Interface() // expect exactly one value
return m.Matcher.Match(m.transformedValue)
}
func (m *WithTransformMatcher) FailureMessage(_ interface{}) (message string) {
return m.Matcher.FailureMessage(m.transformedValue)
}
func (m *WithTransformMatcher) NegatedFailureMessage(_ interface{}) (message string) {
return m.Matcher.NegatedFailureMessage(m.transformedValue)
}
func (m *WithTransformMatcher) MatchMayChangeInTheFuture(_ interface{}) bool {
// TODO: Maybe this should always just return true? (Only an issue for non-deterministic transformers.)
//
// Querying the next matcher is fine if the transformer always will return the same value.
// But if the transformer is non-deterministic and returns a different value each time, then there
// is no point in querying the next matcher, since it can only comment on the last transformed value.
return types.MatchMayChangeInTheFuture(m.Matcher, m.transformedValue)
}
| go | Apache-2.0 | b3b4703e958c25d54c4d48138d9e80ae32fadac3 | 2026-01-07T09:44:30.792320Z | false |
kubev2v/forklift | https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/github.com/onsi/gomega/matchers/contain_substring_matcher.go | vendor/github.com/onsi/gomega/matchers/contain_substring_matcher.go | // untested sections: 2
package matchers
import (
"fmt"
"strings"
"github.com/onsi/gomega/format"
)
type ContainSubstringMatcher struct {
Substr string
Args []interface{}
}
func (matcher *ContainSubstringMatcher) Match(actual interface{}) (success bool, err error) {
actualString, ok := toString(actual)
if !ok {
return false, fmt.Errorf("ContainSubstring matcher requires a string or stringer. Got:\n%s", format.Object(actual, 1))
}
return strings.Contains(actualString, matcher.stringToMatch()), nil
}
func (matcher *ContainSubstringMatcher) stringToMatch() string {
stringToMatch := matcher.Substr
if len(matcher.Args) > 0 {
stringToMatch = fmt.Sprintf(matcher.Substr, matcher.Args...)
}
return stringToMatch
}
func (matcher *ContainSubstringMatcher) FailureMessage(actual interface{}) (message string) {
return format.Message(actual, "to contain substring", matcher.stringToMatch())
}
func (matcher *ContainSubstringMatcher) NegatedFailureMessage(actual interface{}) (message string) {
return format.Message(actual, "not to contain substring", matcher.stringToMatch())
}
| go | Apache-2.0 | b3b4703e958c25d54c4d48138d9e80ae32fadac3 | 2026-01-07T09:44:30.792320Z | false |
kubev2v/forklift | https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/github.com/onsi/gomega/matchers/type_support.go | vendor/github.com/onsi/gomega/matchers/type_support.go | /*
Gomega matchers
This package implements the Gomega matchers and does not typically need to be imported.
See the docs for Gomega for documentation on the matchers
http://onsi.github.io/gomega/
*/
// untested sections: 11
package matchers
import (
"encoding/json"
"fmt"
"reflect"
"github.com/onsi/gomega/matchers/internal/miter"
)
type omegaMatcher interface {
Match(actual interface{}) (success bool, err error)
FailureMessage(actual interface{}) (message string)
NegatedFailureMessage(actual interface{}) (message string)
}
func isBool(a interface{}) bool {
return reflect.TypeOf(a).Kind() == reflect.Bool
}
func isNumber(a interface{}) bool {
if a == nil {
return false
}
kind := reflect.TypeOf(a).Kind()
return reflect.Int <= kind && kind <= reflect.Float64
}
func isInteger(a interface{}) bool {
kind := reflect.TypeOf(a).Kind()
return reflect.Int <= kind && kind <= reflect.Int64
}
func isUnsignedInteger(a interface{}) bool {
kind := reflect.TypeOf(a).Kind()
return reflect.Uint <= kind && kind <= reflect.Uint64
}
func isFloat(a interface{}) bool {
kind := reflect.TypeOf(a).Kind()
return reflect.Float32 <= kind && kind <= reflect.Float64
}
func toInteger(a interface{}) int64 {
if isInteger(a) {
return reflect.ValueOf(a).Int()
} else if isUnsignedInteger(a) {
return int64(reflect.ValueOf(a).Uint())
} else if isFloat(a) {
return int64(reflect.ValueOf(a).Float())
}
panic(fmt.Sprintf("Expected a number! Got <%T> %#v", a, a))
}
func toUnsignedInteger(a interface{}) uint64 {
if isInteger(a) {
return uint64(reflect.ValueOf(a).Int())
} else if isUnsignedInteger(a) {
return reflect.ValueOf(a).Uint()
} else if isFloat(a) {
return uint64(reflect.ValueOf(a).Float())
}
panic(fmt.Sprintf("Expected a number! Got <%T> %#v", a, a))
}
func toFloat(a interface{}) float64 {
if isInteger(a) {
return float64(reflect.ValueOf(a).Int())
} else if isUnsignedInteger(a) {
return float64(reflect.ValueOf(a).Uint())
} else if isFloat(a) {
return reflect.ValueOf(a).Float()
}
panic(fmt.Sprintf("Expected a number! Got <%T> %#v", a, a))
}
func isError(a interface{}) bool {
_, ok := a.(error)
return ok
}
func isChan(a interface{}) bool {
if isNil(a) {
return false
}
return reflect.TypeOf(a).Kind() == reflect.Chan
}
func isMap(a interface{}) bool {
if a == nil {
return false
}
return reflect.TypeOf(a).Kind() == reflect.Map
}
func isArrayOrSlice(a interface{}) bool {
if a == nil {
return false
}
switch reflect.TypeOf(a).Kind() {
case reflect.Array, reflect.Slice:
return true
default:
return false
}
}
func isString(a interface{}) bool {
if a == nil {
return false
}
return reflect.TypeOf(a).Kind() == reflect.String
}
func toString(a interface{}) (string, bool) {
aString, isString := a.(string)
if isString {
return aString, true
}
aBytes, isBytes := a.([]byte)
if isBytes {
return string(aBytes), true
}
aStringer, isStringer := a.(fmt.Stringer)
if isStringer {
return aStringer.String(), true
}
aJSONRawMessage, isJSONRawMessage := a.(json.RawMessage)
if isJSONRawMessage {
return string(aJSONRawMessage), true
}
return "", false
}
func lengthOf(a interface{}) (int, bool) {
if a == nil {
return 0, false
}
switch reflect.TypeOf(a).Kind() {
case reflect.Map, reflect.Array, reflect.String, reflect.Chan, reflect.Slice:
return reflect.ValueOf(a).Len(), true
case reflect.Func:
if !miter.IsIter(a) {
return 0, false
}
var l int
if miter.IsSeq2(a) {
miter.IterateKV(a, func(k, v reflect.Value) bool { l++; return true })
} else {
miter.IterateV(a, func(v reflect.Value) bool { l++; return true })
}
return l, true
default:
return 0, false
}
}
func capOf(a interface{}) (int, bool) {
if a == nil {
return 0, false
}
switch reflect.TypeOf(a).Kind() {
case reflect.Array, reflect.Chan, reflect.Slice:
return reflect.ValueOf(a).Cap(), true
default:
return 0, false
}
}
func isNil(a interface{}) bool {
if a == nil {
return true
}
switch reflect.TypeOf(a).Kind() {
case reflect.Chan, reflect.Func, reflect.Interface, reflect.Map, reflect.Ptr, reflect.Slice:
return reflect.ValueOf(a).IsNil()
}
return false
}
| go | Apache-2.0 | b3b4703e958c25d54c4d48138d9e80ae32fadac3 | 2026-01-07T09:44:30.792320Z | false |
kubev2v/forklift | https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/github.com/onsi/gomega/matchers/succeed_matcher.go | vendor/github.com/onsi/gomega/matchers/succeed_matcher.go | package matchers
import (
"errors"
"fmt"
"github.com/onsi/gomega/format"
)
type formattedGomegaError interface {
FormattedGomegaError() string
}
type SucceedMatcher struct {
}
func (matcher *SucceedMatcher) Match(actual interface{}) (success bool, err error) {
// is purely nil?
if actual == nil {
return true, nil
}
// must be an 'error' type
if !isError(actual) {
return false, fmt.Errorf("Expected an error-type. Got:\n%s", format.Object(actual, 1))
}
// must be nil (or a pointer to a nil)
return isNil(actual), nil
}
func (matcher *SucceedMatcher) FailureMessage(actual interface{}) (message string) {
var fgErr formattedGomegaError
if errors.As(actual.(error), &fgErr) {
return fgErr.FormattedGomegaError()
}
return fmt.Sprintf("Expected success, but got an error:\n%s", format.Object(actual, 1))
}
func (matcher *SucceedMatcher) NegatedFailureMessage(actual interface{}) (message string) {
return "Expected failure, but got no error."
}
| go | Apache-2.0 | b3b4703e958c25d54c4d48138d9e80ae32fadac3 | 2026-01-07T09:44:30.792320Z | false |
kubev2v/forklift | https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/github.com/onsi/gomega/matchers/be_zero_matcher.go | vendor/github.com/onsi/gomega/matchers/be_zero_matcher.go | package matchers
import (
"reflect"
"github.com/onsi/gomega/format"
)
type BeZeroMatcher struct {
}
func (matcher *BeZeroMatcher) Match(actual interface{}) (success bool, err error) {
if actual == nil {
return true, nil
}
zeroValue := reflect.Zero(reflect.TypeOf(actual)).Interface()
return reflect.DeepEqual(zeroValue, actual), nil
}
func (matcher *BeZeroMatcher) FailureMessage(actual interface{}) (message string) {
return format.Message(actual, "to be zero-valued")
}
func (matcher *BeZeroMatcher) NegatedFailureMessage(actual interface{}) (message string) {
return format.Message(actual, "not to be zero-valued")
}
| go | Apache-2.0 | b3b4703e958c25d54c4d48138d9e80ae32fadac3 | 2026-01-07T09:44:30.792320Z | false |
kubev2v/forklift | https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/github.com/onsi/gomega/matchers/consist_of.go | vendor/github.com/onsi/gomega/matchers/consist_of.go | // untested sections: 3
package matchers
import (
"fmt"
"reflect"
"github.com/onsi/gomega/format"
"github.com/onsi/gomega/matchers/internal/miter"
"github.com/onsi/gomega/matchers/support/goraph/bipartitegraph"
)
type ConsistOfMatcher struct {
Elements []interface{}
missingElements []interface{}
extraElements []interface{}
}
func (matcher *ConsistOfMatcher) Match(actual interface{}) (success bool, err error) {
if !isArrayOrSlice(actual) && !isMap(actual) && !miter.IsIter(actual) {
return false, fmt.Errorf("ConsistOf matcher expects an array/slice/map/iter.Seq/iter.Seq2. Got:\n%s", format.Object(actual, 1))
}
matchers := matchers(matcher.Elements)
values := valuesOf(actual)
bipartiteGraph, err := bipartitegraph.NewBipartiteGraph(values, matchers, neighbours)
if err != nil {
return false, err
}
edges := bipartiteGraph.LargestMatching()
if len(edges) == len(values) && len(edges) == len(matchers) {
return true, nil
}
var missingMatchers []interface{}
matcher.extraElements, missingMatchers = bipartiteGraph.FreeLeftRight(edges)
matcher.missingElements = equalMatchersToElements(missingMatchers)
return false, nil
}
func neighbours(value, matcher interface{}) (bool, error) {
match, err := matcher.(omegaMatcher).Match(value)
return match && err == nil, nil
}
func equalMatchersToElements(matchers []interface{}) (elements []interface{}) {
for _, matcher := range matchers {
if equalMatcher, ok := matcher.(*EqualMatcher); ok {
elements = append(elements, equalMatcher.Expected)
} else if _, ok := matcher.(*BeNilMatcher); ok {
elements = append(elements, nil)
} else {
elements = append(elements, matcher)
}
}
return
}
func flatten(elems []interface{}) []interface{} {
if len(elems) != 1 ||
!(isArrayOrSlice(elems[0]) ||
(miter.IsIter(elems[0]) && !miter.IsSeq2(elems[0]))) {
return elems
}
if miter.IsIter(elems[0]) {
flattened := []any{}
miter.IterateV(elems[0], func(v reflect.Value) bool {
flattened = append(flattened, v.Interface())
return true
})
return flattened
}
value := reflect.ValueOf(elems[0])
flattened := make([]interface{}, value.Len())
for i := 0; i < value.Len(); i++ {
flattened[i] = value.Index(i).Interface()
}
return flattened
}
func matchers(expectedElems []interface{}) (matchers []interface{}) {
for _, e := range flatten(expectedElems) {
if e == nil {
matchers = append(matchers, &BeNilMatcher{})
} else if matcher, isMatcher := e.(omegaMatcher); isMatcher {
matchers = append(matchers, matcher)
} else {
matchers = append(matchers, &EqualMatcher{Expected: e})
}
}
return
}
func presentable(elems []interface{}) interface{} {
elems = flatten(elems)
if len(elems) == 0 {
return []interface{}{}
}
sv := reflect.ValueOf(elems)
firstEl := sv.Index(0)
if firstEl.IsNil() {
return elems
}
tt := firstEl.Elem().Type()
for i := 1; i < sv.Len(); i++ {
el := sv.Index(i)
if el.IsNil() || (sv.Index(i).Elem().Type() != tt) {
return elems
}
}
ss := reflect.MakeSlice(reflect.SliceOf(tt), sv.Len(), sv.Len())
for i := 0; i < sv.Len(); i++ {
ss.Index(i).Set(sv.Index(i).Elem())
}
return ss.Interface()
}
func valuesOf(actual interface{}) []interface{} {
value := reflect.ValueOf(actual)
values := []interface{}{}
if miter.IsIter(actual) {
if miter.IsSeq2(actual) {
miter.IterateKV(actual, func(k, v reflect.Value) bool {
values = append(values, v.Interface())
return true
})
} else {
miter.IterateV(actual, func(v reflect.Value) bool {
values = append(values, v.Interface())
return true
})
}
} else if isMap(actual) {
keys := value.MapKeys()
for i := 0; i < value.Len(); i++ {
values = append(values, value.MapIndex(keys[i]).Interface())
}
} else {
for i := 0; i < value.Len(); i++ {
values = append(values, value.Index(i).Interface())
}
}
return values
}
func (matcher *ConsistOfMatcher) FailureMessage(actual interface{}) (message string) {
message = format.Message(actual, "to consist of", presentable(matcher.Elements))
message = appendMissingElements(message, matcher.missingElements)
if len(matcher.extraElements) > 0 {
message = fmt.Sprintf("%s\nthe extra elements were\n%s", message,
format.Object(presentable(matcher.extraElements), 1))
}
return
}
func appendMissingElements(message string, missingElements []interface{}) string {
if len(missingElements) == 0 {
return message
}
return fmt.Sprintf("%s\nthe missing elements were\n%s", message,
format.Object(presentable(missingElements), 1))
}
func (matcher *ConsistOfMatcher) NegatedFailureMessage(actual interface{}) (message string) {
return format.Message(actual, "not to consist of", presentable(matcher.Elements))
}
| go | Apache-2.0 | b3b4703e958c25d54c4d48138d9e80ae32fadac3 | 2026-01-07T09:44:30.792320Z | false |
kubev2v/forklift | https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/github.com/onsi/gomega/matchers/match_error_matcher.go | vendor/github.com/onsi/gomega/matchers/match_error_matcher.go | package matchers
import (
"errors"
"fmt"
"reflect"
"github.com/onsi/gomega/format"
)
type MatchErrorMatcher struct {
Expected any
FuncErrDescription []any
isFunc bool
}
func (matcher *MatchErrorMatcher) Match(actual any) (success bool, err error) {
matcher.isFunc = false
if isNil(actual) {
return false, fmt.Errorf("Expected an error, got nil")
}
if !isError(actual) {
return false, fmt.Errorf("Expected an error. Got:\n%s", format.Object(actual, 1))
}
actualErr := actual.(error)
expected := matcher.Expected
if isError(expected) {
// first try the built-in errors.Is
if errors.Is(actualErr, expected.(error)) {
return true, nil
}
// if not, try DeepEqual along the error chain
for unwrapped := actualErr; unwrapped != nil; unwrapped = errors.Unwrap(unwrapped) {
if reflect.DeepEqual(unwrapped, expected) {
return true, nil
}
}
return false, nil
}
if isString(expected) {
return actualErr.Error() == expected, nil
}
v := reflect.ValueOf(expected)
t := v.Type()
errorInterface := reflect.TypeOf((*error)(nil)).Elem()
if t.Kind() == reflect.Func && t.NumIn() == 1 && t.In(0).Implements(errorInterface) && t.NumOut() == 1 && t.Out(0).Kind() == reflect.Bool {
if len(matcher.FuncErrDescription) == 0 {
return false, fmt.Errorf("MatchError requires an additional description when passed a function")
}
matcher.isFunc = true
return v.Call([]reflect.Value{reflect.ValueOf(actualErr)})[0].Bool(), nil
}
var subMatcher omegaMatcher
var hasSubMatcher bool
if expected != nil {
subMatcher, hasSubMatcher = (expected).(omegaMatcher)
if hasSubMatcher {
return subMatcher.Match(actualErr.Error())
}
}
return false, fmt.Errorf(
"MatchError must be passed an error, a string, or a Matcher that can match on strings. Got:\n%s",
format.Object(expected, 1))
}
func (matcher *MatchErrorMatcher) FailureMessage(actual interface{}) (message string) {
if matcher.isFunc {
return format.Message(actual, fmt.Sprintf("to match error function %s", matcher.FuncErrDescription[0]))
}
return format.Message(actual, "to match error", matcher.Expected)
}
func (matcher *MatchErrorMatcher) NegatedFailureMessage(actual interface{}) (message string) {
if matcher.isFunc {
return format.Message(actual, fmt.Sprintf("not to match error function %s", matcher.FuncErrDescription[0]))
}
return format.Message(actual, "not to match error", matcher.Expected)
}
| go | Apache-2.0 | b3b4703e958c25d54c4d48138d9e80ae32fadac3 | 2026-01-07T09:44:30.792320Z | false |
kubev2v/forklift | https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/github.com/onsi/gomega/matchers/be_element_of_matcher.go | vendor/github.com/onsi/gomega/matchers/be_element_of_matcher.go | // untested sections: 1
package matchers
import (
"fmt"
"reflect"
"github.com/onsi/gomega/format"
)
type BeElementOfMatcher struct {
Elements []interface{}
}
func (matcher *BeElementOfMatcher) Match(actual interface{}) (success bool, err error) {
if reflect.TypeOf(actual) == nil {
return false, fmt.Errorf("BeElement matcher expects actual to be typed")
}
var lastError error
for _, m := range flatten(matcher.Elements) {
matcher := &EqualMatcher{Expected: m}
success, err := matcher.Match(actual)
if err != nil {
lastError = err
continue
}
if success {
return true, nil
}
}
return false, lastError
}
func (matcher *BeElementOfMatcher) FailureMessage(actual interface{}) (message string) {
return format.Message(actual, "to be an element of", presentable(matcher.Elements))
}
func (matcher *BeElementOfMatcher) NegatedFailureMessage(actual interface{}) (message string) {
return format.Message(actual, "not to be an element of", presentable(matcher.Elements))
}
| go | Apache-2.0 | b3b4703e958c25d54c4d48138d9e80ae32fadac3 | 2026-01-07T09:44:30.792320Z | false |
kubev2v/forklift | https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/github.com/onsi/gomega/matchers/contain_element_matcher.go | vendor/github.com/onsi/gomega/matchers/contain_element_matcher.go | // untested sections: 2
package matchers
import (
"errors"
"fmt"
"reflect"
"github.com/onsi/gomega/format"
"github.com/onsi/gomega/matchers/internal/miter"
)
type ContainElementMatcher struct {
Element interface{}
Result []interface{}
}
func (matcher *ContainElementMatcher) Match(actual interface{}) (success bool, err error) {
if !isArrayOrSlice(actual) && !isMap(actual) && !miter.IsIter(actual) {
return false, fmt.Errorf("ContainElement matcher expects an array/slice/map/iterator. Got:\n%s", format.Object(actual, 1))
}
var actualT reflect.Type
var result reflect.Value
switch numResultArgs := len(matcher.Result); {
case numResultArgs > 1:
return false, errors.New("ContainElement matcher expects at most a single optional pointer to store its findings at")
case numResultArgs == 1:
// Check the optional result arg to point to a single value/array/slice/map
// of a type compatible with the actual value.
if reflect.ValueOf(matcher.Result[0]).Kind() != reflect.Ptr {
return false, fmt.Errorf("ContainElement matcher expects a non-nil pointer to store its findings at. Got\n%s",
format.Object(matcher.Result[0], 1))
}
actualT = reflect.TypeOf(actual)
resultReference := matcher.Result[0]
result = reflect.ValueOf(resultReference).Elem() // what ResultReference points to, to stash away our findings
switch result.Kind() {
case reflect.Array: // result arrays are not supported, as they cannot be dynamically sized.
if miter.IsIter(actual) {
_, actualvT := miter.IterKVTypes(actual)
return false, fmt.Errorf("ContainElement cannot return findings. Need *%s, got *%s",
reflect.SliceOf(actualvT), result.Type().String())
}
return false, fmt.Errorf("ContainElement cannot return findings. Need *%s, got *%s",
reflect.SliceOf(actualT.Elem()).String(), result.Type().String())
case reflect.Slice: // result slice
// can we assign elements in actual to elements in what the result
// arg points to?
// - ✔ actual is an array or slice
// - ✔ actual is an iter.Seq producing "v" elements
// - ✔ actual is an iter.Seq2 producing "v" elements, ignoring
// the "k" elements.
switch {
case isArrayOrSlice(actual):
if !actualT.Elem().AssignableTo(result.Type().Elem()) {
return false, fmt.Errorf("ContainElement cannot return findings. Need *%s, got *%s",
actualT.String(), result.Type().String())
}
case miter.IsIter(actual):
_, actualvT := miter.IterKVTypes(actual)
if !actualvT.AssignableTo(result.Type().Elem()) {
return false, fmt.Errorf("ContainElement cannot return findings. Need *%s, got *%s",
actualvT.String(), result.Type().String())
}
default: // incompatible result reference
return false, fmt.Errorf("ContainElement cannot return findings. Need *%s, got *%s",
reflect.MapOf(actualT.Key(), actualT.Elem()).String(), result.Type().String())
}
case reflect.Map: // result map
// can we assign elements in actual to elements in what the result
// arg points to?
// - ✔ actual is a map
// - ✔ actual is an iter.Seq2 (iter.Seq doesn't fit though)
switch {
case isMap(actual):
if !actualT.AssignableTo(result.Type()) {
return false, fmt.Errorf("ContainElement cannot return findings. Need *%s, got *%s",
actualT.String(), result.Type().String())
}
case miter.IsIter(actual):
actualkT, actualvT := miter.IterKVTypes(actual)
if actualkT == nil {
return false, fmt.Errorf("ContainElement cannot return findings. Need *%s, got *%s",
reflect.SliceOf(actualvT).String(), result.Type().String())
}
if !reflect.MapOf(actualkT, actualvT).AssignableTo(result.Type()) {
return false, fmt.Errorf("ContainElement cannot return findings. Need *%s, got *%s",
reflect.MapOf(actualkT, actualvT), result.Type().String())
}
default: // incompatible result reference
return false, fmt.Errorf("ContainElement cannot return findings. Need *%s, got *%s",
actualT.String(), result.Type().String())
}
default:
// can we assign a (single) element in actual to what the result arg
// points to?
switch {
case miter.IsIter(actual):
_, actualvT := miter.IterKVTypes(actual)
if !actualvT.AssignableTo(result.Type()) {
return false, fmt.Errorf("ContainElement cannot return findings. Need *%s, got *%s",
actualvT.String(), result.Type().String())
}
default:
if !actualT.Elem().AssignableTo(result.Type()) {
return false, fmt.Errorf("ContainElement cannot return findings. Need *%s, got *%s",
actualT.Elem().String(), result.Type().String())
}
}
}
}
// If the supplied matcher isn't an Omega matcher, default to the Equal
// matcher.
elemMatcher, elementIsMatcher := matcher.Element.(omegaMatcher)
if !elementIsMatcher {
elemMatcher = &EqualMatcher{Expected: matcher.Element}
}
value := reflect.ValueOf(actual)
var getFindings func() reflect.Value // abstracts how the findings are collected and stored
var lastError error
if !miter.IsIter(actual) {
var valueAt func(int) interface{}
var foundAt func(int)
// We're dealing with an array/slice/map, so in all cases we can iterate
// over the elements in actual using indices (that can be considered
// keys in case of maps).
if isMap(actual) {
keys := value.MapKeys()
valueAt = func(i int) interface{} {
return value.MapIndex(keys[i]).Interface()
}
if result.Kind() != reflect.Invalid {
fm := reflect.MakeMap(actualT)
getFindings = func() reflect.Value { return fm }
foundAt = func(i int) {
fm.SetMapIndex(keys[i], value.MapIndex(keys[i]))
}
}
} else {
valueAt = func(i int) interface{} {
return value.Index(i).Interface()
}
if result.Kind() != reflect.Invalid {
var fsl reflect.Value
if result.Kind() == reflect.Slice {
fsl = reflect.MakeSlice(result.Type(), 0, 0)
} else {
fsl = reflect.MakeSlice(reflect.SliceOf(result.Type()), 0, 0)
}
getFindings = func() reflect.Value { return fsl }
foundAt = func(i int) {
fsl = reflect.Append(fsl, value.Index(i))
}
}
}
for i := 0; i < value.Len(); i++ {
elem := valueAt(i)
success, err := elemMatcher.Match(elem)
if err != nil {
lastError = err
continue
}
if success {
if result.Kind() == reflect.Invalid {
return true, nil
}
foundAt(i)
}
}
} else {
// We're dealing with an iterator as a first-class construct, so things
// are slightly different: there is no index defined as in case of
// arrays/slices/maps, just "ooooorder"
var found func(k, v reflect.Value)
if result.Kind() != reflect.Invalid {
if result.Kind() == reflect.Map {
fm := reflect.MakeMap(result.Type())
getFindings = func() reflect.Value { return fm }
found = func(k, v reflect.Value) { fm.SetMapIndex(k, v) }
} else {
var fsl reflect.Value
if result.Kind() == reflect.Slice {
fsl = reflect.MakeSlice(result.Type(), 0, 0)
} else {
fsl = reflect.MakeSlice(reflect.SliceOf(result.Type()), 0, 0)
}
getFindings = func() reflect.Value { return fsl }
found = func(_, v reflect.Value) { fsl = reflect.Append(fsl, v) }
}
}
success := false
actualkT, _ := miter.IterKVTypes(actual)
if actualkT == nil {
miter.IterateV(actual, func(v reflect.Value) bool {
var err error
success, err = elemMatcher.Match(v.Interface())
if err != nil {
lastError = err
return true // iterate on...
}
if success {
if result.Kind() == reflect.Invalid {
return false // a match and no result needed, so we're done
}
found(reflect.Value{}, v)
}
return true // iterate on...
})
} else {
miter.IterateKV(actual, func(k, v reflect.Value) bool {
var err error
success, err = elemMatcher.Match(v.Interface())
if err != nil {
lastError = err
return true // iterate on...
}
if success {
if result.Kind() == reflect.Invalid {
return false // a match and no result needed, so we're done
}
found(k, v)
}
return true // iterate on...
})
}
if success && result.Kind() == reflect.Invalid {
return true, nil
}
}
// when the expectation isn't interested in the findings except for success
// or non-success, then we're done here and return the last matcher error
// seen, if any, as well as non-success.
if result.Kind() == reflect.Invalid {
return false, lastError
}
// pick up any findings the test is interested in as it specified a non-nil
// result reference. However, the expection always is that there are at
// least one or multiple findings. So, if a result is expected, but we had
// no findings, then this is an error.
findings := getFindings()
if findings.Len() == 0 {
return false, lastError
}
// there's just a single finding and the result is neither a slice nor a map
// (so it's a scalar): pick the one and only finding and return it in the
// place the reference points to.
if findings.Len() == 1 && !isArrayOrSlice(result.Interface()) && !isMap(result.Interface()) {
if isMap(actual) {
miter := findings.MapRange()
miter.Next()
result.Set(miter.Value())
} else {
result.Set(findings.Index(0))
}
return true, nil
}
// at least one or even multiple findings and a the result references a
// slice or a map, so all we need to do is to store our findings where the
// reference points to.
if !findings.Type().AssignableTo(result.Type()) {
return false, fmt.Errorf("ContainElement cannot return multiple findings. Need *%s, got *%s",
findings.Type().String(), result.Type().String())
}
result.Set(findings)
return true, nil
}
func (matcher *ContainElementMatcher) FailureMessage(actual interface{}) (message string) {
return format.Message(actual, "to contain element matching", matcher.Element)
}
func (matcher *ContainElementMatcher) NegatedFailureMessage(actual interface{}) (message string) {
return format.Message(actual, "not to contain element matching", matcher.Element)
}
| go | Apache-2.0 | b3b4703e958c25d54c4d48138d9e80ae32fadac3 | 2026-01-07T09:44:30.792320Z | false |
kubev2v/forklift | https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/github.com/onsi/gomega/matchers/have_cap_matcher.go | vendor/github.com/onsi/gomega/matchers/have_cap_matcher.go | // untested sections: 2
package matchers
import (
"fmt"
"github.com/onsi/gomega/format"
)
type HaveCapMatcher struct {
Count int
}
func (matcher *HaveCapMatcher) Match(actual interface{}) (success bool, err error) {
length, ok := capOf(actual)
if !ok {
return false, fmt.Errorf("HaveCap matcher expects a array/channel/slice. Got:\n%s", format.Object(actual, 1))
}
return length == matcher.Count, nil
}
func (matcher *HaveCapMatcher) FailureMessage(actual interface{}) (message string) {
return fmt.Sprintf("Expected\n%s\nto have capacity %d", format.Object(actual, 1), matcher.Count)
}
func (matcher *HaveCapMatcher) NegatedFailureMessage(actual interface{}) (message string) {
return fmt.Sprintf("Expected\n%s\nnot to have capacity %d", format.Object(actual, 1), matcher.Count)
}
| go | Apache-2.0 | b3b4703e958c25d54c4d48138d9e80ae32fadac3 | 2026-01-07T09:44:30.792320Z | false |
kubev2v/forklift | https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/github.com/onsi/gomega/matchers/have_prefix_matcher.go | vendor/github.com/onsi/gomega/matchers/have_prefix_matcher.go | package matchers
import (
"fmt"
"github.com/onsi/gomega/format"
)
type HavePrefixMatcher struct {
Prefix string
Args []interface{}
}
func (matcher *HavePrefixMatcher) Match(actual interface{}) (success bool, err error) {
actualString, ok := toString(actual)
if !ok {
return false, fmt.Errorf("HavePrefix matcher requires a string or stringer. Got:\n%s", format.Object(actual, 1))
}
prefix := matcher.prefix()
return len(actualString) >= len(prefix) && actualString[0:len(prefix)] == prefix, nil
}
func (matcher *HavePrefixMatcher) prefix() string {
if len(matcher.Args) > 0 {
return fmt.Sprintf(matcher.Prefix, matcher.Args...)
}
return matcher.Prefix
}
func (matcher *HavePrefixMatcher) FailureMessage(actual interface{}) (message string) {
return format.Message(actual, "to have prefix", matcher.prefix())
}
func (matcher *HavePrefixMatcher) NegatedFailureMessage(actual interface{}) (message string) {
return format.Message(actual, "not to have prefix", matcher.prefix())
}
| go | Apache-2.0 | b3b4703e958c25d54c4d48138d9e80ae32fadac3 | 2026-01-07T09:44:30.792320Z | false |
kubev2v/forklift | https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/github.com/onsi/gomega/matchers/be_numerically_matcher.go | vendor/github.com/onsi/gomega/matchers/be_numerically_matcher.go | // untested sections: 4
package matchers
import (
"fmt"
"math"
"github.com/onsi/gomega/format"
)
type BeNumericallyMatcher struct {
Comparator string
CompareTo []interface{}
}
func (matcher *BeNumericallyMatcher) FailureMessage(actual interface{}) (message string) {
return matcher.FormatFailureMessage(actual, false)
}
func (matcher *BeNumericallyMatcher) NegatedFailureMessage(actual interface{}) (message string) {
return matcher.FormatFailureMessage(actual, true)
}
func (matcher *BeNumericallyMatcher) FormatFailureMessage(actual interface{}, negated bool) (message string) {
if len(matcher.CompareTo) == 1 {
message = fmt.Sprintf("to be %s", matcher.Comparator)
} else {
message = fmt.Sprintf("to be within %v of %s", matcher.CompareTo[1], matcher.Comparator)
}
if negated {
message = "not " + message
}
return format.Message(actual, message, matcher.CompareTo[0])
}
func (matcher *BeNumericallyMatcher) Match(actual interface{}) (success bool, err error) {
if len(matcher.CompareTo) == 0 || len(matcher.CompareTo) > 2 {
return false, fmt.Errorf("BeNumerically requires 1 or 2 CompareTo arguments. Got:\n%s", format.Object(matcher.CompareTo, 1))
}
if !isNumber(actual) {
return false, fmt.Errorf("Expected a number. Got:\n%s", format.Object(actual, 1))
}
if !isNumber(matcher.CompareTo[0]) {
return false, fmt.Errorf("Expected a number. Got:\n%s", format.Object(matcher.CompareTo[0], 1))
}
if len(matcher.CompareTo) == 2 && !isNumber(matcher.CompareTo[1]) {
return false, fmt.Errorf("Expected a number. Got:\n%s", format.Object(matcher.CompareTo[1], 1))
}
switch matcher.Comparator {
case "==", "~", ">", ">=", "<", "<=":
default:
return false, fmt.Errorf("Unknown comparator: %s", matcher.Comparator)
}
if isFloat(actual) || isFloat(matcher.CompareTo[0]) {
var secondOperand float64 = 1e-8
if len(matcher.CompareTo) == 2 {
secondOperand = toFloat(matcher.CompareTo[1])
}
success = matcher.matchFloats(toFloat(actual), toFloat(matcher.CompareTo[0]), secondOperand)
} else if isInteger(actual) {
var secondOperand int64 = 0
if len(matcher.CompareTo) == 2 {
secondOperand = toInteger(matcher.CompareTo[1])
}
success = matcher.matchIntegers(toInteger(actual), toInteger(matcher.CompareTo[0]), secondOperand)
} else if isUnsignedInteger(actual) {
var secondOperand uint64 = 0
if len(matcher.CompareTo) == 2 {
secondOperand = toUnsignedInteger(matcher.CompareTo[1])
}
success = matcher.matchUnsignedIntegers(toUnsignedInteger(actual), toUnsignedInteger(matcher.CompareTo[0]), secondOperand)
} else {
return false, fmt.Errorf("Failed to compare:\n%s\n%s:\n%s", format.Object(actual, 1), matcher.Comparator, format.Object(matcher.CompareTo[0], 1))
}
return success, nil
}
func (matcher *BeNumericallyMatcher) matchIntegers(actual, compareTo, threshold int64) (success bool) {
switch matcher.Comparator {
case "==", "~":
diff := actual - compareTo
return -threshold <= diff && diff <= threshold
case ">":
return (actual > compareTo)
case ">=":
return (actual >= compareTo)
case "<":
return (actual < compareTo)
case "<=":
return (actual <= compareTo)
}
return false
}
func (matcher *BeNumericallyMatcher) matchUnsignedIntegers(actual, compareTo, threshold uint64) (success bool) {
switch matcher.Comparator {
case "==", "~":
if actual < compareTo {
actual, compareTo = compareTo, actual
}
return actual-compareTo <= threshold
case ">":
return (actual > compareTo)
case ">=":
return (actual >= compareTo)
case "<":
return (actual < compareTo)
case "<=":
return (actual <= compareTo)
}
return false
}
func (matcher *BeNumericallyMatcher) matchFloats(actual, compareTo, threshold float64) (success bool) {
switch matcher.Comparator {
case "~":
return math.Abs(actual-compareTo) <= threshold
case "==":
return (actual == compareTo)
case ">":
return (actual > compareTo)
case ">=":
return (actual >= compareTo)
case "<":
return (actual < compareTo)
case "<=":
return (actual <= compareTo)
}
return false
}
| go | Apache-2.0 | b3b4703e958c25d54c4d48138d9e80ae32fadac3 | 2026-01-07T09:44:30.792320Z | false |
kubev2v/forklift | https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/github.com/onsi/gomega/matchers/not.go | vendor/github.com/onsi/gomega/matchers/not.go | package matchers
import (
"github.com/onsi/gomega/types"
)
type NotMatcher struct {
Matcher types.GomegaMatcher
}
func (m *NotMatcher) Match(actual interface{}) (bool, error) {
success, err := m.Matcher.Match(actual)
if err != nil {
return false, err
}
return !success, nil
}
func (m *NotMatcher) FailureMessage(actual interface{}) (message string) {
return m.Matcher.NegatedFailureMessage(actual) // works beautifully
}
func (m *NotMatcher) NegatedFailureMessage(actual interface{}) (message string) {
return m.Matcher.FailureMessage(actual) // works beautifully
}
func (m *NotMatcher) MatchMayChangeInTheFuture(actual interface{}) bool {
return types.MatchMayChangeInTheFuture(m.Matcher, actual) // just return m.Matcher's value
}
| go | Apache-2.0 | b3b4703e958c25d54c4d48138d9e80ae32fadac3 | 2026-01-07T09:44:30.792320Z | false |
kubev2v/forklift | https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/github.com/onsi/gomega/matchers/semi_structured_data_support.go | vendor/github.com/onsi/gomega/matchers/semi_structured_data_support.go | // untested sections: 5
package matchers
import (
"fmt"
"reflect"
"strings"
)
func formattedMessage(comparisonMessage string, failurePath []interface{}) string {
var diffMessage string
if len(failurePath) == 0 {
diffMessage = ""
} else {
diffMessage = fmt.Sprintf("\n\nfirst mismatched key: %s", formattedFailurePath(failurePath))
}
return fmt.Sprintf("%s%s", comparisonMessage, diffMessage)
}
func formattedFailurePath(failurePath []interface{}) string {
formattedPaths := []string{}
for i := len(failurePath) - 1; i >= 0; i-- {
switch p := failurePath[i].(type) {
case int:
formattedPaths = append(formattedPaths, fmt.Sprintf(`[%d]`, p))
default:
if i != len(failurePath)-1 {
formattedPaths = append(formattedPaths, ".")
}
formattedPaths = append(formattedPaths, fmt.Sprintf(`"%s"`, p))
}
}
return strings.Join(formattedPaths, "")
}
func deepEqual(a interface{}, b interface{}) (bool, []interface{}) {
var errorPath []interface{}
if reflect.TypeOf(a) != reflect.TypeOf(b) {
return false, errorPath
}
switch a.(type) {
case []interface{}:
if len(a.([]interface{})) != len(b.([]interface{})) {
return false, errorPath
}
for i, v := range a.([]interface{}) {
elementEqual, keyPath := deepEqual(v, b.([]interface{})[i])
if !elementEqual {
return false, append(keyPath, i)
}
}
return true, errorPath
case map[interface{}]interface{}:
if len(a.(map[interface{}]interface{})) != len(b.(map[interface{}]interface{})) {
return false, errorPath
}
for k, v1 := range a.(map[interface{}]interface{}) {
v2, ok := b.(map[interface{}]interface{})[k]
if !ok {
return false, errorPath
}
elementEqual, keyPath := deepEqual(v1, v2)
if !elementEqual {
return false, append(keyPath, k)
}
}
return true, errorPath
case map[string]interface{}:
if len(a.(map[string]interface{})) != len(b.(map[string]interface{})) {
return false, errorPath
}
for k, v1 := range a.(map[string]interface{}) {
v2, ok := b.(map[string]interface{})[k]
if !ok {
return false, errorPath
}
elementEqual, keyPath := deepEqual(v1, v2)
if !elementEqual {
return false, append(keyPath, k)
}
}
return true, errorPath
default:
return a == b, errorPath
}
}
| go | Apache-2.0 | b3b4703e958c25d54c4d48138d9e80ae32fadac3 | 2026-01-07T09:44:30.792320Z | false |
kubev2v/forklift | https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/github.com/onsi/gomega/matchers/be_true_matcher.go | vendor/github.com/onsi/gomega/matchers/be_true_matcher.go | // untested sections: 2
package matchers
import (
"fmt"
"github.com/onsi/gomega/format"
)
type BeTrueMatcher struct {
Reason string
}
func (matcher *BeTrueMatcher) Match(actual interface{}) (success bool, err error) {
if !isBool(actual) {
return false, fmt.Errorf("Expected a boolean. Got:\n%s", format.Object(actual, 1))
}
return actual.(bool), nil
}
func (matcher *BeTrueMatcher) FailureMessage(actual interface{}) (message string) {
if matcher.Reason == "" {
return format.Message(actual, "to be true")
} else {
return matcher.Reason
}
}
func (matcher *BeTrueMatcher) NegatedFailureMessage(actual interface{}) (message string) {
if matcher.Reason == "" {
return format.Message(actual, "not to be true")
} else {
return fmt.Sprintf(`Expected not true but got true\nNegation of "%s" failed`, matcher.Reason)
}
}
| go | Apache-2.0 | b3b4703e958c25d54c4d48138d9e80ae32fadac3 | 2026-01-07T09:44:30.792320Z | false |
kubev2v/forklift | https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/github.com/onsi/gomega/matchers/be_a_directory.go | vendor/github.com/onsi/gomega/matchers/be_a_directory.go | // untested sections: 5
package matchers
import (
"fmt"
"os"
"github.com/onsi/gomega/format"
)
type notADirectoryError struct {
os.FileInfo
}
func (t notADirectoryError) Error() string {
fileInfo := os.FileInfo(t)
switch {
case fileInfo.Mode().IsRegular():
return "file is a regular file"
default:
return fmt.Sprintf("file mode is: %s", fileInfo.Mode().String())
}
}
type BeADirectoryMatcher struct {
expected interface{}
err error
}
func (matcher *BeADirectoryMatcher) Match(actual interface{}) (success bool, err error) {
actualFilename, ok := actual.(string)
if !ok {
return false, fmt.Errorf("BeADirectoryMatcher matcher expects a file path")
}
fileInfo, err := os.Stat(actualFilename)
if err != nil {
matcher.err = err
return false, nil
}
if !fileInfo.Mode().IsDir() {
matcher.err = notADirectoryError{fileInfo}
return false, nil
}
return true, nil
}
func (matcher *BeADirectoryMatcher) FailureMessage(actual interface{}) (message string) {
return format.Message(actual, fmt.Sprintf("to be a directory: %s", matcher.err))
}
func (matcher *BeADirectoryMatcher) NegatedFailureMessage(actual interface{}) (message string) {
return format.Message(actual, "not be a directory")
}
| go | Apache-2.0 | b3b4703e958c25d54c4d48138d9e80ae32fadac3 | 2026-01-07T09:44:30.792320Z | false |
kubev2v/forklift | https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/github.com/onsi/gomega/matchers/contain_elements_matcher.go | vendor/github.com/onsi/gomega/matchers/contain_elements_matcher.go | package matchers
import (
"fmt"
"github.com/onsi/gomega/format"
"github.com/onsi/gomega/matchers/internal/miter"
"github.com/onsi/gomega/matchers/support/goraph/bipartitegraph"
)
type ContainElementsMatcher struct {
Elements []interface{}
missingElements []interface{}
}
func (matcher *ContainElementsMatcher) Match(actual interface{}) (success bool, err error) {
if !isArrayOrSlice(actual) && !isMap(actual) && !miter.IsIter(actual) {
return false, fmt.Errorf("ContainElements matcher expects an array/slice/map/iter.Seq/iter.Seq2. Got:\n%s", format.Object(actual, 1))
}
matchers := matchers(matcher.Elements)
bipartiteGraph, err := bipartitegraph.NewBipartiteGraph(valuesOf(actual), matchers, neighbours)
if err != nil {
return false, err
}
edges := bipartiteGraph.LargestMatching()
if len(edges) == len(matchers) {
return true, nil
}
_, missingMatchers := bipartiteGraph.FreeLeftRight(edges)
matcher.missingElements = equalMatchersToElements(missingMatchers)
return false, nil
}
func (matcher *ContainElementsMatcher) FailureMessage(actual interface{}) (message string) {
message = format.Message(actual, "to contain elements", presentable(matcher.Elements))
return appendMissingElements(message, matcher.missingElements)
}
func (matcher *ContainElementsMatcher) NegatedFailureMessage(actual interface{}) (message string) {
return format.Message(actual, "not to contain elements", presentable(matcher.Elements))
}
| go | Apache-2.0 | b3b4703e958c25d54c4d48138d9e80ae32fadac3 | 2026-01-07T09:44:30.792320Z | false |
kubev2v/forklift | https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/github.com/onsi/gomega/matchers/match_yaml_matcher.go | vendor/github.com/onsi/gomega/matchers/match_yaml_matcher.go | package matchers
import (
"fmt"
"strings"
"github.com/onsi/gomega/format"
"gopkg.in/yaml.v3"
)
type MatchYAMLMatcher struct {
YAMLToMatch interface{}
firstFailurePath []interface{}
}
func (matcher *MatchYAMLMatcher) Match(actual interface{}) (success bool, err error) {
actualString, expectedString, err := matcher.toStrings(actual)
if err != nil {
return false, err
}
var aval interface{}
var eval interface{}
if err := yaml.Unmarshal([]byte(actualString), &aval); err != nil {
return false, fmt.Errorf("Actual '%s' should be valid YAML, but it is not.\nUnderlying error:%s", actualString, err)
}
if err := yaml.Unmarshal([]byte(expectedString), &eval); err != nil {
return false, fmt.Errorf("Expected '%s' should be valid YAML, but it is not.\nUnderlying error:%s", expectedString, err)
}
var equal bool
equal, matcher.firstFailurePath = deepEqual(aval, eval)
return equal, nil
}
func (matcher *MatchYAMLMatcher) FailureMessage(actual interface{}) (message string) {
actualString, expectedString, _ := matcher.toNormalisedStrings(actual)
return formattedMessage(format.Message(actualString, "to match YAML of", expectedString), matcher.firstFailurePath)
}
func (matcher *MatchYAMLMatcher) NegatedFailureMessage(actual interface{}) (message string) {
actualString, expectedString, _ := matcher.toNormalisedStrings(actual)
return formattedMessage(format.Message(actualString, "not to match YAML of", expectedString), matcher.firstFailurePath)
}
func (matcher *MatchYAMLMatcher) toNormalisedStrings(actual interface{}) (actualFormatted, expectedFormatted string, err error) {
actualString, expectedString, err := matcher.toStrings(actual)
return normalise(actualString), normalise(expectedString), err
}
func normalise(input string) string {
var val interface{}
err := yaml.Unmarshal([]byte(input), &val)
if err != nil {
panic(err) // unreachable since Match already calls Unmarshal
}
output, err := yaml.Marshal(val)
if err != nil {
panic(err) // untested section, unreachable since we Unmarshal above
}
return strings.TrimSpace(string(output))
}
func (matcher *MatchYAMLMatcher) toStrings(actual interface{}) (actualFormatted, expectedFormatted string, err error) {
actualString, ok := toString(actual)
if !ok {
return "", "", fmt.Errorf("MatchYAMLMatcher matcher requires a string, stringer, or []byte. Got actual:\n%s", format.Object(actual, 1))
}
expectedString, ok := toString(matcher.YAMLToMatch)
if !ok {
return "", "", fmt.Errorf("MatchYAMLMatcher matcher requires a string, stringer, or []byte. Got expected:\n%s", format.Object(matcher.YAMLToMatch, 1))
}
return actualString, expectedString, nil
}
| go | Apache-2.0 | b3b4703e958c25d54c4d48138d9e80ae32fadac3 | 2026-01-07T09:44:30.792320Z | false |
kubev2v/forklift | https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/github.com/onsi/gomega/matchers/have_exact_elements.go | vendor/github.com/onsi/gomega/matchers/have_exact_elements.go | package matchers
import (
"fmt"
"reflect"
"github.com/onsi/gomega/format"
"github.com/onsi/gomega/matchers/internal/miter"
)
type mismatchFailure struct {
failure string
index int
}
type HaveExactElementsMatcher struct {
Elements []interface{}
mismatchFailures []mismatchFailure
missingIndex int
extraIndex int
}
func (matcher *HaveExactElementsMatcher) Match(actual interface{}) (success bool, err error) {
matcher.resetState()
if isMap(actual) || miter.IsSeq2(actual) {
return false, fmt.Errorf("HaveExactElements matcher doesn't work on map or iter.Seq2. Got:\n%s", format.Object(actual, 1))
}
matchers := matchers(matcher.Elements)
lenMatchers := len(matchers)
success = true
if miter.IsIter(actual) {
// In the worst case, we need to see everything before we can give our
// verdict. The only exception is fast fail.
i := 0
miter.IterateV(actual, func(v reflect.Value) bool {
if i >= lenMatchers {
// the iterator produces more values than we got matchers: this
// is not good.
matcher.extraIndex = i
success = false
return false
}
elemMatcher := matchers[i].(omegaMatcher)
match, err := elemMatcher.Match(v.Interface())
if err != nil {
matcher.mismatchFailures = append(matcher.mismatchFailures, mismatchFailure{
index: i,
failure: err.Error(),
})
success = false
} else if !match {
matcher.mismatchFailures = append(matcher.mismatchFailures, mismatchFailure{
index: i,
failure: elemMatcher.FailureMessage(v.Interface()),
})
success = false
}
i++
return true
})
if i < len(matchers) {
// the iterator produced less values than we got matchers: this is
// no good, no no no.
matcher.missingIndex = i
success = false
}
return success, nil
}
values := valuesOf(actual)
lenValues := len(values)
for i := 0; i < lenMatchers || i < lenValues; i++ {
if i >= lenMatchers {
matcher.extraIndex = i
success = false
continue
}
if i >= lenValues {
matcher.missingIndex = i
success = false
return
}
elemMatcher := matchers[i].(omegaMatcher)
match, err := elemMatcher.Match(values[i])
if err != nil {
matcher.mismatchFailures = append(matcher.mismatchFailures, mismatchFailure{
index: i,
failure: err.Error(),
})
success = false
} else if !match {
matcher.mismatchFailures = append(matcher.mismatchFailures, mismatchFailure{
index: i,
failure: elemMatcher.FailureMessage(values[i]),
})
success = false
}
}
return success, nil
}
func (matcher *HaveExactElementsMatcher) FailureMessage(actual interface{}) (message string) {
message = format.Message(actual, "to have exact elements with", presentable(matcher.Elements))
if matcher.missingIndex > 0 {
message = fmt.Sprintf("%s\nthe missing elements start from index %d", message, matcher.missingIndex)
}
if matcher.extraIndex > 0 {
message = fmt.Sprintf("%s\nthe extra elements start from index %d", message, matcher.extraIndex)
}
if len(matcher.mismatchFailures) != 0 {
message = fmt.Sprintf("%s\nthe mismatch indexes were:", message)
}
for _, mismatch := range matcher.mismatchFailures {
message = fmt.Sprintf("%s\n%d: %s", message, mismatch.index, mismatch.failure)
}
return
}
func (matcher *HaveExactElementsMatcher) NegatedFailureMessage(actual interface{}) (message string) {
return format.Message(actual, "not to contain elements", presentable(matcher.Elements))
}
func (matcher *HaveExactElementsMatcher) resetState() {
matcher.mismatchFailures = nil
matcher.missingIndex = 0
matcher.extraIndex = 0
}
| go | Apache-2.0 | b3b4703e958c25d54c4d48138d9e80ae32fadac3 | 2026-01-07T09:44:30.792320Z | false |
kubev2v/forklift | https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/github.com/onsi/gomega/matchers/have_existing_field_matcher.go | vendor/github.com/onsi/gomega/matchers/have_existing_field_matcher.go | package matchers
import (
"errors"
"fmt"
"github.com/onsi/gomega/format"
)
type HaveExistingFieldMatcher struct {
Field string
}
func (matcher *HaveExistingFieldMatcher) Match(actual interface{}) (success bool, err error) {
// we don't care about the field's actual value, just about any error in
// trying to find the field (or method).
_, err = extractField(actual, matcher.Field, "HaveExistingField")
if err == nil {
return true, nil
}
var mferr missingFieldError
if errors.As(err, &mferr) {
// missing field errors aren't errors in this context, but instead
// unsuccessful matches.
return false, nil
}
return false, err
}
func (matcher *HaveExistingFieldMatcher) FailureMessage(actual interface{}) (message string) {
return fmt.Sprintf("Expected\n%s\nto have field '%s'", format.Object(actual, 1), matcher.Field)
}
func (matcher *HaveExistingFieldMatcher) NegatedFailureMessage(actual interface{}) (message string) {
return fmt.Sprintf("Expected\n%s\nnot to have field '%s'", format.Object(actual, 1), matcher.Field)
}
| go | Apache-2.0 | b3b4703e958c25d54c4d48138d9e80ae32fadac3 | 2026-01-07T09:44:30.792320Z | false |
kubev2v/forklift | https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/github.com/onsi/gomega/matchers/be_equivalent_to_matcher.go | vendor/github.com/onsi/gomega/matchers/be_equivalent_to_matcher.go | // untested sections: 2
package matchers
import (
"fmt"
"reflect"
"github.com/onsi/gomega/format"
)
type BeEquivalentToMatcher struct {
Expected interface{}
}
func (matcher *BeEquivalentToMatcher) Match(actual interface{}) (success bool, err error) {
if actual == nil && matcher.Expected == nil {
return false, fmt.Errorf("Both actual and expected must not be nil.")
}
convertedActual := actual
if actual != nil && matcher.Expected != nil && reflect.TypeOf(actual).ConvertibleTo(reflect.TypeOf(matcher.Expected)) {
convertedActual = reflect.ValueOf(actual).Convert(reflect.TypeOf(matcher.Expected)).Interface()
}
return reflect.DeepEqual(convertedActual, matcher.Expected), nil
}
func (matcher *BeEquivalentToMatcher) FailureMessage(actual interface{}) (message string) {
return format.Message(actual, "to be equivalent to", matcher.Expected)
}
func (matcher *BeEquivalentToMatcher) NegatedFailureMessage(actual interface{}) (message string) {
return format.Message(actual, "not to be equivalent to", matcher.Expected)
}
| go | Apache-2.0 | b3b4703e958c25d54c4d48138d9e80ae32fadac3 | 2026-01-07T09:44:30.792320Z | false |
kubev2v/forklift | https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/github.com/onsi/gomega/matchers/panic_matcher.go | vendor/github.com/onsi/gomega/matchers/panic_matcher.go | package matchers
import (
"fmt"
"reflect"
"github.com/onsi/gomega/format"
)
type PanicMatcher struct {
Expected interface{}
object interface{}
}
func (matcher *PanicMatcher) Match(actual interface{}) (success bool, err error) {
if actual == nil {
return false, fmt.Errorf("PanicMatcher expects a non-nil actual.")
}
actualType := reflect.TypeOf(actual)
if actualType.Kind() != reflect.Func {
return false, fmt.Errorf("PanicMatcher expects a function. Got:\n%s", format.Object(actual, 1))
}
if !(actualType.NumIn() == 0 && actualType.NumOut() == 0) {
return false, fmt.Errorf("PanicMatcher expects a function with no arguments and no return value. Got:\n%s", format.Object(actual, 1))
}
success = false
defer func() {
if e := recover(); e != nil {
matcher.object = e
if matcher.Expected == nil {
success = true
return
}
valueMatcher, valueIsMatcher := matcher.Expected.(omegaMatcher)
if !valueIsMatcher {
valueMatcher = &EqualMatcher{Expected: matcher.Expected}
}
success, err = valueMatcher.Match(e)
if err != nil {
err = fmt.Errorf("PanicMatcher's value matcher failed with:\n%s%s", format.Indent, err.Error())
}
}
}()
reflect.ValueOf(actual).Call([]reflect.Value{})
return
}
func (matcher *PanicMatcher) FailureMessage(actual interface{}) (message string) {
if matcher.Expected == nil {
// We wanted any panic to occur, but none did.
return format.Message(actual, "to panic")
}
if matcher.object == nil {
// We wanted a panic with a specific value to occur, but none did.
switch matcher.Expected.(type) {
case omegaMatcher:
return format.Message(actual, "to panic with a value matching", matcher.Expected)
default:
return format.Message(actual, "to panic with", matcher.Expected)
}
}
// We got a panic, but the value isn't what we expected.
switch matcher.Expected.(type) {
case omegaMatcher:
return format.Message(
actual,
fmt.Sprintf(
"to panic with a value matching\n%s\nbut panicked with\n%s",
format.Object(matcher.Expected, 1),
format.Object(matcher.object, 1),
),
)
default:
return format.Message(
actual,
fmt.Sprintf(
"to panic with\n%s\nbut panicked with\n%s",
format.Object(matcher.Expected, 1),
format.Object(matcher.object, 1),
),
)
}
}
func (matcher *PanicMatcher) NegatedFailureMessage(actual interface{}) (message string) {
if matcher.Expected == nil {
// We didn't want any panic to occur, but one did.
return format.Message(actual, fmt.Sprintf("not to panic, but panicked with\n%s", format.Object(matcher.object, 1)))
}
// We wanted a to ensure a panic with a specific value did not occur, but it did.
switch matcher.Expected.(type) {
case omegaMatcher:
return format.Message(
actual,
fmt.Sprintf(
"not to panic with a value matching\n%s\nbut panicked with\n%s",
format.Object(matcher.Expected, 1),
format.Object(matcher.object, 1),
),
)
default:
return format.Message(actual, "not to panic with", matcher.Expected)
}
}
| go | Apache-2.0 | b3b4703e958c25d54c4d48138d9e80ae32fadac3 | 2026-01-07T09:44:30.792320Z | false |
kubev2v/forklift | https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/github.com/onsi/gomega/matchers/be_identical_to.go | vendor/github.com/onsi/gomega/matchers/be_identical_to.go | // untested sections: 2
package matchers
import (
"fmt"
"runtime"
"github.com/onsi/gomega/format"
)
type BeIdenticalToMatcher struct {
Expected interface{}
}
func (matcher *BeIdenticalToMatcher) Match(actual interface{}) (success bool, matchErr error) {
if actual == nil && matcher.Expected == nil {
return false, fmt.Errorf("Refusing to compare <nil> to <nil>.\nBe explicit and use BeNil() instead. This is to avoid mistakes where both sides of an assertion are erroneously uninitialized.")
}
defer func() {
if r := recover(); r != nil {
if _, ok := r.(runtime.Error); ok {
success = false
matchErr = nil
}
}
}()
return actual == matcher.Expected, nil
}
func (matcher *BeIdenticalToMatcher) FailureMessage(actual interface{}) string {
return format.Message(actual, "to be identical to", matcher.Expected)
}
func (matcher *BeIdenticalToMatcher) NegatedFailureMessage(actual interface{}) string {
return format.Message(actual, "not to be identical to", matcher.Expected)
}
| go | Apache-2.0 | b3b4703e958c25d54c4d48138d9e80ae32fadac3 | 2026-01-07T09:44:30.792320Z | false |
kubev2v/forklift | https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/github.com/onsi/gomega/matchers/have_suffix_matcher.go | vendor/github.com/onsi/gomega/matchers/have_suffix_matcher.go | package matchers
import (
"fmt"
"github.com/onsi/gomega/format"
)
type HaveSuffixMatcher struct {
Suffix string
Args []interface{}
}
func (matcher *HaveSuffixMatcher) Match(actual interface{}) (success bool, err error) {
actualString, ok := toString(actual)
if !ok {
return false, fmt.Errorf("HaveSuffix matcher requires a string or stringer. Got:\n%s", format.Object(actual, 1))
}
suffix := matcher.suffix()
return len(actualString) >= len(suffix) && actualString[len(actualString)-len(suffix):] == suffix, nil
}
func (matcher *HaveSuffixMatcher) suffix() string {
if len(matcher.Args) > 0 {
return fmt.Sprintf(matcher.Suffix, matcher.Args...)
}
return matcher.Suffix
}
func (matcher *HaveSuffixMatcher) FailureMessage(actual interface{}) (message string) {
return format.Message(actual, "to have suffix", matcher.suffix())
}
func (matcher *HaveSuffixMatcher) NegatedFailureMessage(actual interface{}) (message string) {
return format.Message(actual, "not to have suffix", matcher.suffix())
}
| go | Apache-2.0 | b3b4703e958c25d54c4d48138d9e80ae32fadac3 | 2026-01-07T09:44:30.792320Z | false |
kubev2v/forklift | https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/github.com/onsi/gomega/matchers/match_json_matcher.go | vendor/github.com/onsi/gomega/matchers/match_json_matcher.go | package matchers
import (
"bytes"
"encoding/json"
"fmt"
"github.com/onsi/gomega/format"
)
type MatchJSONMatcher struct {
JSONToMatch interface{}
firstFailurePath []interface{}
}
func (matcher *MatchJSONMatcher) Match(actual interface{}) (success bool, err error) {
actualString, expectedString, err := matcher.prettyPrint(actual)
if err != nil {
return false, err
}
var aval interface{}
var eval interface{}
// this is guarded by prettyPrint
json.Unmarshal([]byte(actualString), &aval)
json.Unmarshal([]byte(expectedString), &eval)
var equal bool
equal, matcher.firstFailurePath = deepEqual(aval, eval)
return equal, nil
}
func (matcher *MatchJSONMatcher) FailureMessage(actual interface{}) (message string) {
actualString, expectedString, _ := matcher.prettyPrint(actual)
return formattedMessage(format.Message(actualString, "to match JSON of", expectedString), matcher.firstFailurePath)
}
func (matcher *MatchJSONMatcher) NegatedFailureMessage(actual interface{}) (message string) {
actualString, expectedString, _ := matcher.prettyPrint(actual)
return formattedMessage(format.Message(actualString, "not to match JSON of", expectedString), matcher.firstFailurePath)
}
func (matcher *MatchJSONMatcher) prettyPrint(actual interface{}) (actualFormatted, expectedFormatted string, err error) {
actualString, ok := toString(actual)
if !ok {
return "", "", fmt.Errorf("MatchJSONMatcher matcher requires a string, stringer, or []byte. Got actual:\n%s", format.Object(actual, 1))
}
expectedString, ok := toString(matcher.JSONToMatch)
if !ok {
return "", "", fmt.Errorf("MatchJSONMatcher matcher requires a string, stringer, or []byte. Got expected:\n%s", format.Object(matcher.JSONToMatch, 1))
}
abuf := new(bytes.Buffer)
ebuf := new(bytes.Buffer)
if err := json.Indent(abuf, []byte(actualString), "", " "); err != nil {
return "", "", fmt.Errorf("Actual '%s' should be valid JSON, but it is not.\nUnderlying error:%s", actualString, err)
}
if err := json.Indent(ebuf, []byte(expectedString), "", " "); err != nil {
return "", "", fmt.Errorf("Expected '%s' should be valid JSON, but it is not.\nUnderlying error:%s", expectedString, err)
}
return abuf.String(), ebuf.String(), nil
}
| go | Apache-2.0 | b3b4703e958c25d54c4d48138d9e80ae32fadac3 | 2026-01-07T09:44:30.792320Z | false |
kubev2v/forklift | https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/github.com/onsi/gomega/matchers/be_a_regular_file.go | vendor/github.com/onsi/gomega/matchers/be_a_regular_file.go | // untested sections: 5
package matchers
import (
"fmt"
"os"
"github.com/onsi/gomega/format"
)
type notARegularFileError struct {
os.FileInfo
}
func (t notARegularFileError) Error() string {
fileInfo := os.FileInfo(t)
switch {
case fileInfo.IsDir():
return "file is a directory"
default:
return fmt.Sprintf("file mode is: %s", fileInfo.Mode().String())
}
}
type BeARegularFileMatcher struct {
expected interface{}
err error
}
func (matcher *BeARegularFileMatcher) Match(actual interface{}) (success bool, err error) {
actualFilename, ok := actual.(string)
if !ok {
return false, fmt.Errorf("BeARegularFileMatcher matcher expects a file path")
}
fileInfo, err := os.Stat(actualFilename)
if err != nil {
matcher.err = err
return false, nil
}
if !fileInfo.Mode().IsRegular() {
matcher.err = notARegularFileError{fileInfo}
return false, nil
}
return true, nil
}
func (matcher *BeARegularFileMatcher) FailureMessage(actual interface{}) (message string) {
return format.Message(actual, fmt.Sprintf("to be a regular file: %s", matcher.err))
}
func (matcher *BeARegularFileMatcher) NegatedFailureMessage(actual interface{}) (message string) {
return format.Message(actual, "not be a regular file")
}
| go | Apache-2.0 | b3b4703e958c25d54c4d48138d9e80ae32fadac3 | 2026-01-07T09:44:30.792320Z | false |
kubev2v/forklift | https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/github.com/onsi/gomega/matchers/satisfy_matcher.go | vendor/github.com/onsi/gomega/matchers/satisfy_matcher.go | package matchers
import (
"fmt"
"reflect"
"github.com/onsi/gomega/format"
)
type SatisfyMatcher struct {
Predicate interface{}
// cached type
predicateArgType reflect.Type
}
func NewSatisfyMatcher(predicate interface{}) *SatisfyMatcher {
if predicate == nil {
panic("predicate cannot be nil")
}
predicateType := reflect.TypeOf(predicate)
if predicateType.Kind() != reflect.Func {
panic("predicate must be a function")
}
if predicateType.NumIn() != 1 {
panic("predicate must have 1 argument")
}
if predicateType.NumOut() != 1 || predicateType.Out(0).Kind() != reflect.Bool {
panic("predicate must return bool")
}
return &SatisfyMatcher{
Predicate: predicate,
predicateArgType: predicateType.In(0),
}
}
func (m *SatisfyMatcher) Match(actual interface{}) (success bool, err error) {
// prepare a parameter to pass to the predicate
var param reflect.Value
if actual != nil && reflect.TypeOf(actual).AssignableTo(m.predicateArgType) {
// The dynamic type of actual is compatible with the predicate argument.
param = reflect.ValueOf(actual)
} else if actual == nil && m.predicateArgType.Kind() == reflect.Interface {
// The dynamic type of actual is unknown, so there's no way to make its
// reflect.Value. Create a nil of the predicate argument, which is known.
param = reflect.Zero(m.predicateArgType)
} else {
return false, fmt.Errorf("predicate expects '%s' but we have '%T'", m.predicateArgType, actual)
}
// call the predicate with `actual`
fn := reflect.ValueOf(m.Predicate)
result := fn.Call([]reflect.Value{param})
return result[0].Bool(), nil
}
func (m *SatisfyMatcher) FailureMessage(actual interface{}) (message string) {
return format.Message(actual, "to satisfy predicate", m.Predicate)
}
func (m *SatisfyMatcher) NegatedFailureMessage(actual interface{}) (message string) {
return format.Message(actual, "to not satisfy predicate", m.Predicate)
}
| go | Apache-2.0 | b3b4703e958c25d54c4d48138d9e80ae32fadac3 | 2026-01-07T09:44:30.792320Z | false |
kubev2v/forklift | https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/github.com/onsi/gomega/matchers/have_http_header_with_value_matcher.go | vendor/github.com/onsi/gomega/matchers/have_http_header_with_value_matcher.go | package matchers
import (
"fmt"
"net/http"
"net/http/httptest"
"github.com/onsi/gomega/format"
"github.com/onsi/gomega/types"
)
type HaveHTTPHeaderWithValueMatcher struct {
Header string
Value interface{}
}
func (matcher *HaveHTTPHeaderWithValueMatcher) Match(actual interface{}) (success bool, err error) {
headerValue, err := matcher.extractHeader(actual)
if err != nil {
return false, err
}
headerMatcher, err := matcher.getSubMatcher()
if err != nil {
return false, err
}
return headerMatcher.Match(headerValue)
}
func (matcher *HaveHTTPHeaderWithValueMatcher) FailureMessage(actual interface{}) string {
headerValue, err := matcher.extractHeader(actual)
if err != nil {
panic(err) // protected by Match()
}
headerMatcher, err := matcher.getSubMatcher()
if err != nil {
panic(err) // protected by Match()
}
diff := format.IndentString(headerMatcher.FailureMessage(headerValue), 1)
return fmt.Sprintf("HTTP header %q:\n%s", matcher.Header, diff)
}
func (matcher *HaveHTTPHeaderWithValueMatcher) NegatedFailureMessage(actual interface{}) (message string) {
headerValue, err := matcher.extractHeader(actual)
if err != nil {
panic(err) // protected by Match()
}
headerMatcher, err := matcher.getSubMatcher()
if err != nil {
panic(err) // protected by Match()
}
diff := format.IndentString(headerMatcher.NegatedFailureMessage(headerValue), 1)
return fmt.Sprintf("HTTP header %q:\n%s", matcher.Header, diff)
}
func (matcher *HaveHTTPHeaderWithValueMatcher) getSubMatcher() (types.GomegaMatcher, error) {
switch m := matcher.Value.(type) {
case string:
return &EqualMatcher{Expected: matcher.Value}, nil
case types.GomegaMatcher:
return m, nil
default:
return nil, fmt.Errorf("HaveHTTPHeaderWithValue matcher must be passed a string or a GomegaMatcher. Got:\n%s", format.Object(matcher.Value, 1))
}
}
func (matcher *HaveHTTPHeaderWithValueMatcher) extractHeader(actual interface{}) (string, error) {
switch r := actual.(type) {
case *http.Response:
return r.Header.Get(matcher.Header), nil
case *httptest.ResponseRecorder:
return r.Result().Header.Get(matcher.Header), nil
default:
return "", fmt.Errorf("HaveHTTPHeaderWithValue matcher expects *http.Response or *httptest.ResponseRecorder. Got:\n%s", format.Object(actual, 1))
}
}
| go | Apache-2.0 | b3b4703e958c25d54c4d48138d9e80ae32fadac3 | 2026-01-07T09:44:30.792320Z | false |
kubev2v/forklift | https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/github.com/onsi/gomega/matchers/attributes_slice.go | vendor/github.com/onsi/gomega/matchers/attributes_slice.go | package matchers
import (
"encoding/xml"
"strings"
)
type attributesSlice []xml.Attr
func (attrs attributesSlice) Len() int { return len(attrs) }
func (attrs attributesSlice) Less(i, j int) bool {
return strings.Compare(attrs[i].Name.Local, attrs[j].Name.Local) == -1
}
func (attrs attributesSlice) Swap(i, j int) { attrs[i], attrs[j] = attrs[j], attrs[i] }
| go | Apache-2.0 | b3b4703e958c25d54c4d48138d9e80ae32fadac3 | 2026-01-07T09:44:30.792320Z | false |
kubev2v/forklift | https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/github.com/onsi/gomega/matchers/have_occurred_matcher.go | vendor/github.com/onsi/gomega/matchers/have_occurred_matcher.go | // untested sections: 2
package matchers
import (
"fmt"
"github.com/onsi/gomega/format"
)
type HaveOccurredMatcher struct {
}
func (matcher *HaveOccurredMatcher) Match(actual interface{}) (success bool, err error) {
// is purely nil?
if actual == nil {
return false, nil
}
// must be an 'error' type
if !isError(actual) {
return false, fmt.Errorf("Expected an error-type. Got:\n%s", format.Object(actual, 1))
}
// must be non-nil (or a pointer to a non-nil)
return !isNil(actual), nil
}
func (matcher *HaveOccurredMatcher) FailureMessage(actual interface{}) (message string) {
return fmt.Sprintf("Expected an error to have occurred. Got:\n%s", format.Object(actual, 1))
}
func (matcher *HaveOccurredMatcher) NegatedFailureMessage(actual interface{}) (message string) {
return fmt.Sprintf("Unexpected error:\n%s\n%s", format.Object(actual, 1), "occurred")
}
| go | Apache-2.0 | b3b4703e958c25d54c4d48138d9e80ae32fadac3 | 2026-01-07T09:44:30.792320Z | false |
kubev2v/forklift | https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/github.com/onsi/gomega/matchers/be_an_existing_file.go | vendor/github.com/onsi/gomega/matchers/be_an_existing_file.go | // untested sections: 3
package matchers
import (
"fmt"
"os"
"github.com/onsi/gomega/format"
)
type BeAnExistingFileMatcher struct {
expected interface{}
}
func (matcher *BeAnExistingFileMatcher) Match(actual interface{}) (success bool, err error) {
actualFilename, ok := actual.(string)
if !ok {
return false, fmt.Errorf("BeAnExistingFileMatcher matcher expects a file path")
}
if _, err = os.Stat(actualFilename); err != nil {
switch {
case os.IsNotExist(err):
return false, nil
default:
return false, err
}
}
return true, nil
}
func (matcher *BeAnExistingFileMatcher) FailureMessage(actual interface{}) (message string) {
return format.Message(actual, "to exist")
}
func (matcher *BeAnExistingFileMatcher) NegatedFailureMessage(actual interface{}) (message string) {
return format.Message(actual, "not to exist")
}
| go | Apache-2.0 | b3b4703e958c25d54c4d48138d9e80ae32fadac3 | 2026-01-07T09:44:30.792320Z | false |
kubev2v/forklift | https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/github.com/onsi/gomega/matchers/have_http_body_matcher.go | vendor/github.com/onsi/gomega/matchers/have_http_body_matcher.go | package matchers
import (
"fmt"
"net/http"
"net/http/httptest"
"github.com/onsi/gomega/format"
"github.com/onsi/gomega/internal/gutil"
"github.com/onsi/gomega/types"
)
type HaveHTTPBodyMatcher struct {
Expected interface{}
cachedResponse interface{}
cachedBody []byte
}
func (matcher *HaveHTTPBodyMatcher) Match(actual interface{}) (bool, error) {
body, err := matcher.body(actual)
if err != nil {
return false, err
}
switch e := matcher.Expected.(type) {
case string:
return (&EqualMatcher{Expected: e}).Match(string(body))
case []byte:
return (&EqualMatcher{Expected: e}).Match(body)
case types.GomegaMatcher:
return e.Match(body)
default:
return false, fmt.Errorf("HaveHTTPBody matcher expects string, []byte, or GomegaMatcher. Got:\n%s", format.Object(matcher.Expected, 1))
}
}
func (matcher *HaveHTTPBodyMatcher) FailureMessage(actual interface{}) (message string) {
body, err := matcher.body(actual)
if err != nil {
return fmt.Sprintf("failed to read body: %s", err)
}
switch e := matcher.Expected.(type) {
case string:
return (&EqualMatcher{Expected: e}).FailureMessage(string(body))
case []byte:
return (&EqualMatcher{Expected: e}).FailureMessage(body)
case types.GomegaMatcher:
return e.FailureMessage(body)
default:
return fmt.Sprintf("HaveHTTPBody matcher expects string, []byte, or GomegaMatcher. Got:\n%s", format.Object(matcher.Expected, 1))
}
}
func (matcher *HaveHTTPBodyMatcher) NegatedFailureMessage(actual interface{}) (message string) {
body, err := matcher.body(actual)
if err != nil {
return fmt.Sprintf("failed to read body: %s", err)
}
switch e := matcher.Expected.(type) {
case string:
return (&EqualMatcher{Expected: e}).NegatedFailureMessage(string(body))
case []byte:
return (&EqualMatcher{Expected: e}).NegatedFailureMessage(body)
case types.GomegaMatcher:
return e.NegatedFailureMessage(body)
default:
return fmt.Sprintf("HaveHTTPBody matcher expects string, []byte, or GomegaMatcher. Got:\n%s", format.Object(matcher.Expected, 1))
}
}
// body returns the body. It is cached because once we read it in Match()
// the Reader is closed and it is not readable again in FailureMessage()
// or NegatedFailureMessage()
func (matcher *HaveHTTPBodyMatcher) body(actual interface{}) ([]byte, error) {
if matcher.cachedResponse == actual && matcher.cachedBody != nil {
return matcher.cachedBody, nil
}
body := func(a *http.Response) ([]byte, error) {
if a.Body != nil {
defer a.Body.Close()
var err error
matcher.cachedBody, err = gutil.ReadAll(a.Body)
if err != nil {
return nil, fmt.Errorf("error reading response body: %w", err)
}
}
return matcher.cachedBody, nil
}
switch a := actual.(type) {
case *http.Response:
matcher.cachedResponse = a
return body(a)
case *httptest.ResponseRecorder:
matcher.cachedResponse = a
return body(a.Result())
default:
return nil, fmt.Errorf("HaveHTTPBody matcher expects *http.Response or *httptest.ResponseRecorder. Got:\n%s", format.Object(actual, 1))
}
}
| go | Apache-2.0 | b3b4703e958c25d54c4d48138d9e80ae32fadac3 | 2026-01-07T09:44:30.792320Z | false |
kubev2v/forklift | https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/github.com/onsi/gomega/matchers/match_regexp_matcher.go | vendor/github.com/onsi/gomega/matchers/match_regexp_matcher.go | package matchers
import (
"fmt"
"regexp"
"github.com/onsi/gomega/format"
)
type MatchRegexpMatcher struct {
Regexp string
Args []interface{}
}
func (matcher *MatchRegexpMatcher) Match(actual interface{}) (success bool, err error) {
actualString, ok := toString(actual)
if !ok {
return false, fmt.Errorf("RegExp matcher requires a string or stringer.\nGot:%s", format.Object(actual, 1))
}
match, err := regexp.Match(matcher.regexp(), []byte(actualString))
if err != nil {
return false, fmt.Errorf("RegExp match failed to compile with error:\n\t%s", err.Error())
}
return match, nil
}
func (matcher *MatchRegexpMatcher) FailureMessage(actual interface{}) (message string) {
return format.Message(actual, "to match regular expression", matcher.regexp())
}
func (matcher *MatchRegexpMatcher) NegatedFailureMessage(actual interface{}) (message string) {
return format.Message(actual, "not to match regular expression", matcher.regexp())
}
func (matcher *MatchRegexpMatcher) regexp() string {
re := matcher.Regexp
if len(matcher.Args) > 0 {
re = fmt.Sprintf(matcher.Regexp, matcher.Args...)
}
return re
}
| go | Apache-2.0 | b3b4703e958c25d54c4d48138d9e80ae32fadac3 | 2026-01-07T09:44:30.792320Z | false |
kubev2v/forklift | https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/github.com/onsi/gomega/matchers/assignable_to_type_of_matcher.go | vendor/github.com/onsi/gomega/matchers/assignable_to_type_of_matcher.go | // untested sections: 2
package matchers
import (
"fmt"
"reflect"
"github.com/onsi/gomega/format"
)
type AssignableToTypeOfMatcher struct {
Expected interface{}
}
func (matcher *AssignableToTypeOfMatcher) Match(actual interface{}) (success bool, err error) {
if actual == nil && matcher.Expected == nil {
return false, fmt.Errorf("Refusing to compare <nil> to <nil>.\nBe explicit and use BeNil() instead. This is to avoid mistakes where both sides of an assertion are erroneously uninitialized.")
} else if matcher.Expected == nil {
return false, fmt.Errorf("Refusing to compare type to <nil>.\nBe explicit and use BeNil() instead. This is to avoid mistakes where both sides of an assertion are erroneously uninitialized.")
} else if actual == nil {
return false, nil
}
actualType := reflect.TypeOf(actual)
expectedType := reflect.TypeOf(matcher.Expected)
return actualType.AssignableTo(expectedType), nil
}
func (matcher *AssignableToTypeOfMatcher) FailureMessage(actual interface{}) string {
return format.Message(actual, fmt.Sprintf("to be assignable to the type: %T", matcher.Expected))
}
func (matcher *AssignableToTypeOfMatcher) NegatedFailureMessage(actual interface{}) string {
return format.Message(actual, fmt.Sprintf("not to be assignable to the type: %T", matcher.Expected))
}
| go | Apache-2.0 | b3b4703e958c25d54c4d48138d9e80ae32fadac3 | 2026-01-07T09:44:30.792320Z | false |
kubev2v/forklift | https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/github.com/onsi/gomega/matchers/equal_matcher.go | vendor/github.com/onsi/gomega/matchers/equal_matcher.go | package matchers
import (
"bytes"
"fmt"
"reflect"
"github.com/onsi/gomega/format"
)
type EqualMatcher struct {
Expected interface{}
}
func (matcher *EqualMatcher) Match(actual interface{}) (success bool, err error) {
if actual == nil && matcher.Expected == nil {
return false, fmt.Errorf("Refusing to compare <nil> to <nil>.\nBe explicit and use BeNil() instead. This is to avoid mistakes where both sides of an assertion are erroneously uninitialized.")
}
// Shortcut for byte slices.
// Comparing long byte slices with reflect.DeepEqual is very slow,
// so use bytes.Equal if actual and expected are both byte slices.
if actualByteSlice, ok := actual.([]byte); ok {
if expectedByteSlice, ok := matcher.Expected.([]byte); ok {
return bytes.Equal(actualByteSlice, expectedByteSlice), nil
}
}
return reflect.DeepEqual(actual, matcher.Expected), nil
}
func (matcher *EqualMatcher) FailureMessage(actual interface{}) (message string) {
actualString, actualOK := actual.(string)
expectedString, expectedOK := matcher.Expected.(string)
if actualOK && expectedOK {
return format.MessageWithDiff(actualString, "to equal", expectedString)
}
return format.Message(actual, "to equal", matcher.Expected)
}
func (matcher *EqualMatcher) NegatedFailureMessage(actual interface{}) (message string) {
return format.Message(actual, "not to equal", matcher.Expected)
}
| go | Apache-2.0 | b3b4703e958c25d54c4d48138d9e80ae32fadac3 | 2026-01-07T09:44:30.792320Z | false |
kubev2v/forklift | https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/github.com/onsi/gomega/matchers/have_key_with_value_matcher.go | vendor/github.com/onsi/gomega/matchers/have_key_with_value_matcher.go | // untested sections:10
package matchers
import (
"fmt"
"reflect"
"github.com/onsi/gomega/format"
"github.com/onsi/gomega/matchers/internal/miter"
)
type HaveKeyWithValueMatcher struct {
Key interface{}
Value interface{}
}
func (matcher *HaveKeyWithValueMatcher) Match(actual interface{}) (success bool, err error) {
if !isMap(actual) && !miter.IsSeq2(actual) {
return false, fmt.Errorf("HaveKeyWithValue matcher expects a map/iter.Seq2. Got:%s", format.Object(actual, 1))
}
keyMatcher, keyIsMatcher := matcher.Key.(omegaMatcher)
if !keyIsMatcher {
keyMatcher = &EqualMatcher{Expected: matcher.Key}
}
valueMatcher, valueIsMatcher := matcher.Value.(omegaMatcher)
if !valueIsMatcher {
valueMatcher = &EqualMatcher{Expected: matcher.Value}
}
if miter.IsSeq2(actual) {
var success bool
var err error
miter.IterateKV(actual, func(k, v reflect.Value) bool {
success, err = keyMatcher.Match(k.Interface())
if err != nil {
err = fmt.Errorf("HaveKey's key matcher failed with:\n%s%s", format.Indent, err.Error())
return false
}
if success {
success, err = valueMatcher.Match(v.Interface())
if err != nil {
err = fmt.Errorf("HaveKeyWithValue's value matcher failed with:\n%s%s", format.Indent, err.Error())
return false
}
}
return !success
})
return success, err
}
keys := reflect.ValueOf(actual).MapKeys()
for i := 0; i < len(keys); i++ {
success, err := keyMatcher.Match(keys[i].Interface())
if err != nil {
return false, fmt.Errorf("HaveKeyWithValue's key matcher failed with:\n%s%s", format.Indent, err.Error())
}
if success {
actualValue := reflect.ValueOf(actual).MapIndex(keys[i])
success, err := valueMatcher.Match(actualValue.Interface())
if err != nil {
return false, fmt.Errorf("HaveKeyWithValue's value matcher failed with:\n%s%s", format.Indent, err.Error())
}
return success, nil
}
}
return false, nil
}
func (matcher *HaveKeyWithValueMatcher) FailureMessage(actual interface{}) (message string) {
str := "to have {key: value}"
if _, ok := matcher.Key.(omegaMatcher); ok {
str += " matching"
} else if _, ok := matcher.Value.(omegaMatcher); ok {
str += " matching"
}
expect := make(map[interface{}]interface{}, 1)
expect[matcher.Key] = matcher.Value
return format.Message(actual, str, expect)
}
func (matcher *HaveKeyWithValueMatcher) NegatedFailureMessage(actual interface{}) (message string) {
kStr := "not to have key"
if _, ok := matcher.Key.(omegaMatcher); ok {
kStr = "not to have key matching"
}
vStr := "or that key's value not be"
if _, ok := matcher.Value.(omegaMatcher); ok {
vStr = "or to have that key's value not matching"
}
return format.Message(actual, kStr, matcher.Key, vStr, matcher.Value)
}
| go | Apache-2.0 | b3b4703e958c25d54c4d48138d9e80ae32fadac3 | 2026-01-07T09:44:30.792320Z | false |
kubev2v/forklift | https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/github.com/onsi/gomega/matchers/be_comparable_to_matcher.go | vendor/github.com/onsi/gomega/matchers/be_comparable_to_matcher.go | package matchers
import (
"bytes"
"fmt"
"github.com/google/go-cmp/cmp"
"github.com/onsi/gomega/format"
)
type BeComparableToMatcher struct {
Expected interface{}
Options cmp.Options
}
func (matcher *BeComparableToMatcher) Match(actual interface{}) (success bool, matchErr error) {
if actual == nil && matcher.Expected == nil {
return false, fmt.Errorf("Refusing to compare <nil> to <nil>.\nBe explicit and use BeNil() instead. This is to avoid mistakes where both sides of an assertion are erroneously uninitialized.")
}
// Shortcut for byte slices.
// Comparing long byte slices with reflect.DeepEqual is very slow,
// so use bytes.Equal if actual and expected are both byte slices.
if actualByteSlice, ok := actual.([]byte); ok {
if expectedByteSlice, ok := matcher.Expected.([]byte); ok {
return bytes.Equal(actualByteSlice, expectedByteSlice), nil
}
}
defer func() {
if r := recover(); r != nil {
success = false
if err, ok := r.(error); ok {
matchErr = err
} else if errMsg, ok := r.(string); ok {
matchErr = fmt.Errorf(errMsg)
}
}
}()
return cmp.Equal(actual, matcher.Expected, matcher.Options...), nil
}
func (matcher *BeComparableToMatcher) FailureMessage(actual interface{}) (message string) {
return fmt.Sprint("Expected object to be comparable, diff: ", cmp.Diff(actual, matcher.Expected, matcher.Options...))
}
func (matcher *BeComparableToMatcher) NegatedFailureMessage(actual interface{}) (message string) {
return format.Message(actual, "not to be comparable to", matcher.Expected)
}
| go | Apache-2.0 | b3b4703e958c25d54c4d48138d9e80ae32fadac3 | 2026-01-07T09:44:30.792320Z | false |
kubev2v/forklift | https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/github.com/onsi/gomega/matchers/receive_matcher.go | vendor/github.com/onsi/gomega/matchers/receive_matcher.go | // untested sections: 3
package matchers
import (
"errors"
"fmt"
"reflect"
"github.com/onsi/gomega/format"
)
type ReceiveMatcher struct {
Args []interface{}
receivedValue reflect.Value
channelClosed bool
}
func (matcher *ReceiveMatcher) Match(actual interface{}) (success bool, err error) {
if !isChan(actual) {
return false, fmt.Errorf("ReceiveMatcher expects a channel. Got:\n%s", format.Object(actual, 1))
}
channelType := reflect.TypeOf(actual)
channelValue := reflect.ValueOf(actual)
if channelType.ChanDir() == reflect.SendDir {
return false, fmt.Errorf("ReceiveMatcher matcher cannot be passed a send-only channel. Got:\n%s", format.Object(actual, 1))
}
var subMatcher omegaMatcher
var hasSubMatcher bool
var resultReference interface{}
// Valid arg formats are as follows, always with optional POINTER before
// optional MATCHER:
// - Receive()
// - Receive(POINTER)
// - Receive(MATCHER)
// - Receive(POINTER, MATCHER)
args := matcher.Args
if len(args) > 0 {
arg := args[0]
_, isSubMatcher := arg.(omegaMatcher)
if !isSubMatcher && reflect.ValueOf(arg).Kind() == reflect.Ptr {
// Consume optional POINTER arg first, if it ain't no matcher ;)
resultReference = arg
args = args[1:]
}
}
if len(args) > 0 {
arg := args[0]
subMatcher, hasSubMatcher = arg.(omegaMatcher)
if !hasSubMatcher {
// At this point we assume the dev user wanted to assign a received
// value, so [POINTER,]MATCHER.
return false, fmt.Errorf("Cannot assign a value from the channel:\n%s\nTo:\n%s\nYou need to pass a pointer!", format.Object(actual, 1), format.Object(arg, 1))
}
// Consume optional MATCHER arg.
args = args[1:]
}
if len(args) > 0 {
// If there are still args present, reject all.
return false, errors.New("Receive matcher expects at most an optional pointer and/or an optional matcher")
}
winnerIndex, value, open := reflect.Select([]reflect.SelectCase{
{Dir: reflect.SelectRecv, Chan: channelValue},
{Dir: reflect.SelectDefault},
})
var closed bool
var didReceive bool
if winnerIndex == 0 {
closed = !open
didReceive = open
}
matcher.channelClosed = closed
if closed {
return false, nil
}
if hasSubMatcher {
if !didReceive {
return false, nil
}
matcher.receivedValue = value
if match, err := subMatcher.Match(matcher.receivedValue.Interface()); err != nil || !match {
return match, err
}
// if we received a match, then fall through in order to handle an
// optional assignment of the received value to the specified reference.
}
if didReceive {
if resultReference != nil {
outValue := reflect.ValueOf(resultReference)
if value.Type().AssignableTo(outValue.Elem().Type()) {
outValue.Elem().Set(value)
return true, nil
}
if value.Type().Kind() == reflect.Interface && value.Elem().Type().AssignableTo(outValue.Elem().Type()) {
outValue.Elem().Set(value.Elem())
return true, nil
} else {
return false, fmt.Errorf("Cannot assign a value from the channel:\n%s\nType:\n%s\nTo:\n%s", format.Object(actual, 1), format.Object(value.Interface(), 1), format.Object(resultReference, 1))
}
}
return true, nil
}
return false, nil
}
func (matcher *ReceiveMatcher) FailureMessage(actual interface{}) (message string) {
var matcherArg interface{}
if len(matcher.Args) > 0 {
matcherArg = matcher.Args[len(matcher.Args)-1]
}
subMatcher, hasSubMatcher := (matcherArg).(omegaMatcher)
closedAddendum := ""
if matcher.channelClosed {
closedAddendum = " The channel is closed."
}
if hasSubMatcher {
if matcher.receivedValue.IsValid() {
return subMatcher.FailureMessage(matcher.receivedValue.Interface())
}
return "When passed a matcher, ReceiveMatcher's channel *must* receive something."
}
return format.Message(actual, "to receive something."+closedAddendum)
}
func (matcher *ReceiveMatcher) NegatedFailureMessage(actual interface{}) (message string) {
var matcherArg interface{}
if len(matcher.Args) > 0 {
matcherArg = matcher.Args[len(matcher.Args)-1]
}
subMatcher, hasSubMatcher := (matcherArg).(omegaMatcher)
closedAddendum := ""
if matcher.channelClosed {
closedAddendum = " The channel is closed."
}
if hasSubMatcher {
if matcher.receivedValue.IsValid() {
return subMatcher.NegatedFailureMessage(matcher.receivedValue.Interface())
}
return "When passed a matcher, ReceiveMatcher's channel *must* receive something."
}
return format.Message(actual, "not to receive anything."+closedAddendum)
}
func (matcher *ReceiveMatcher) MatchMayChangeInTheFuture(actual interface{}) bool {
if !isChan(actual) {
return false
}
return !matcher.channelClosed
}
| go | Apache-2.0 | b3b4703e958c25d54c4d48138d9e80ae32fadac3 | 2026-01-07T09:44:30.792320Z | false |
kubev2v/forklift | https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/github.com/onsi/gomega/matchers/have_each_matcher.go | vendor/github.com/onsi/gomega/matchers/have_each_matcher.go | package matchers
import (
"fmt"
"reflect"
"github.com/onsi/gomega/format"
"github.com/onsi/gomega/matchers/internal/miter"
)
type HaveEachMatcher struct {
Element interface{}
}
func (matcher *HaveEachMatcher) Match(actual interface{}) (success bool, err error) {
if !isArrayOrSlice(actual) && !isMap(actual) && !miter.IsIter(actual) {
return false, fmt.Errorf("HaveEach matcher expects an array/slice/map/iter.Seq/iter.Seq2. Got:\n%s",
format.Object(actual, 1))
}
elemMatcher, elementIsMatcher := matcher.Element.(omegaMatcher)
if !elementIsMatcher {
elemMatcher = &EqualMatcher{Expected: matcher.Element}
}
if miter.IsIter(actual) {
// rejecting the non-elements case works different for iterators as we
// don't want to fetch all elements into a slice first.
count := 0
var success bool
var err error
if miter.IsSeq2(actual) {
miter.IterateKV(actual, func(k, v reflect.Value) bool {
count++
success, err = elemMatcher.Match(v.Interface())
if err != nil {
return false
}
return success
})
} else {
miter.IterateV(actual, func(v reflect.Value) bool {
count++
success, err = elemMatcher.Match(v.Interface())
if err != nil {
return false
}
return success
})
}
if count == 0 {
return false, fmt.Errorf("HaveEach matcher expects a non-empty iter.Seq/iter.Seq2. Got:\n%s",
format.Object(actual, 1))
}
return success, err
}
value := reflect.ValueOf(actual)
if value.Len() == 0 {
return false, fmt.Errorf("HaveEach matcher expects a non-empty array/slice/map. Got:\n%s",
format.Object(actual, 1))
}
var valueAt func(int) interface{}
if isMap(actual) {
keys := value.MapKeys()
valueAt = func(i int) interface{} {
return value.MapIndex(keys[i]).Interface()
}
} else {
valueAt = func(i int) interface{} {
return value.Index(i).Interface()
}
}
// if we never failed then we succeed; the empty/nil cases have already been
// rejected above.
for i := 0; i < value.Len(); i++ {
success, err := elemMatcher.Match(valueAt(i))
if err != nil {
return false, err
}
if !success {
return false, nil
}
}
return true, nil
}
// FailureMessage returns a suitable failure message.
func (matcher *HaveEachMatcher) FailureMessage(actual interface{}) (message string) {
return format.Message(actual, "to contain element matching", matcher.Element)
}
// NegatedFailureMessage returns a suitable negated failure message.
func (matcher *HaveEachMatcher) NegatedFailureMessage(actual interface{}) (message string) {
return format.Message(actual, "not to contain element matching", matcher.Element)
}
| go | Apache-2.0 | b3b4703e958c25d54c4d48138d9e80ae32fadac3 | 2026-01-07T09:44:30.792320Z | false |
kubev2v/forklift | https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/github.com/onsi/gomega/matchers/have_value.go | vendor/github.com/onsi/gomega/matchers/have_value.go | package matchers
import (
"errors"
"reflect"
"github.com/onsi/gomega/format"
"github.com/onsi/gomega/types"
)
const maxIndirections = 31
type HaveValueMatcher struct {
Matcher types.GomegaMatcher // the matcher to apply to the "resolved" actual value.
resolvedActual interface{} // the ("resolved") value.
}
func (m *HaveValueMatcher) Match(actual interface{}) (bool, error) {
val := reflect.ValueOf(actual)
for allowedIndirs := maxIndirections; allowedIndirs > 0; allowedIndirs-- {
// return an error if value isn't valid. Please note that we cannot
// check for nil here, as we might not deal with a pointer or interface
// at this point.
if !val.IsValid() {
return false, errors.New(format.Message(
actual, "not to be <nil>"))
}
switch val.Kind() {
case reflect.Ptr, reflect.Interface:
// resolve pointers and interfaces to their values, then rinse and
// repeat.
if val.IsNil() {
return false, errors.New(format.Message(
actual, "not to be <nil>"))
}
val = val.Elem()
continue
default:
// forward the final value to the specified matcher.
m.resolvedActual = val.Interface()
return m.Matcher.Match(m.resolvedActual)
}
}
// too many indirections: extreme star gazing, indeed...?
return false, errors.New(format.Message(actual, "too many indirections"))
}
func (m *HaveValueMatcher) FailureMessage(_ interface{}) (message string) {
return m.Matcher.FailureMessage(m.resolvedActual)
}
func (m *HaveValueMatcher) NegatedFailureMessage(_ interface{}) (message string) {
return m.Matcher.NegatedFailureMessage(m.resolvedActual)
}
| go | Apache-2.0 | b3b4703e958c25d54c4d48138d9e80ae32fadac3 | 2026-01-07T09:44:30.792320Z | false |
kubev2v/forklift | https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/github.com/onsi/gomega/matchers/or.go | vendor/github.com/onsi/gomega/matchers/or.go | package matchers
import (
"fmt"
"github.com/onsi/gomega/format"
"github.com/onsi/gomega/types"
)
type OrMatcher struct {
Matchers []types.GomegaMatcher
// state
firstSuccessfulMatcher types.GomegaMatcher
}
func (m *OrMatcher) Match(actual interface{}) (success bool, err error) {
m.firstSuccessfulMatcher = nil
for _, matcher := range m.Matchers {
success, err := matcher.Match(actual)
if err != nil {
return false, err
}
if success {
m.firstSuccessfulMatcher = matcher
return true, nil
}
}
return false, nil
}
func (m *OrMatcher) FailureMessage(actual interface{}) (message string) {
// not the most beautiful list of matchers, but not bad either...
return format.Message(actual, fmt.Sprintf("To satisfy at least one of these matchers: %s", m.Matchers))
}
func (m *OrMatcher) NegatedFailureMessage(actual interface{}) (message string) {
return m.firstSuccessfulMatcher.NegatedFailureMessage(actual)
}
func (m *OrMatcher) MatchMayChangeInTheFuture(actual interface{}) bool {
/*
Example with 3 matchers: A, B, C
Match evaluates them: F, T, <?> => T
So match is currently T, what should MatchMayChangeInTheFuture() return?
Seems like it only depends on B, since currently B MUST change to allow the result to become F
Match eval: F, F, F => F
So match is currently F, what should MatchMayChangeInTheFuture() return?
Seems to depend on ANY of them being able to change to T.
*/
if m.firstSuccessfulMatcher != nil {
// one of the matchers succeeded.. it must be able to change in order to affect the result
return types.MatchMayChangeInTheFuture(m.firstSuccessfulMatcher, actual)
} else {
// so all matchers failed.. Any one of them changing would change the result.
for _, matcher := range m.Matchers {
if types.MatchMayChangeInTheFuture(matcher, actual) {
return true
}
}
return false // none of were going to change
}
}
| go | Apache-2.0 | b3b4703e958c25d54c4d48138d9e80ae32fadac3 | 2026-01-07T09:44:30.792320Z | false |
kubev2v/forklift | https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/github.com/onsi/gomega/matchers/be_closed_matcher.go | vendor/github.com/onsi/gomega/matchers/be_closed_matcher.go | // untested sections: 2
package matchers
import (
"fmt"
"reflect"
"github.com/onsi/gomega/format"
)
type BeClosedMatcher struct {
}
func (matcher *BeClosedMatcher) Match(actual interface{}) (success bool, err error) {
if !isChan(actual) {
return false, fmt.Errorf("BeClosed matcher expects a channel. Got:\n%s", format.Object(actual, 1))
}
channelType := reflect.TypeOf(actual)
channelValue := reflect.ValueOf(actual)
if channelType.ChanDir() == reflect.SendDir {
return false, fmt.Errorf("BeClosed matcher cannot determine if a send-only channel is closed or open. Got:\n%s", format.Object(actual, 1))
}
winnerIndex, _, open := reflect.Select([]reflect.SelectCase{
{Dir: reflect.SelectRecv, Chan: channelValue},
{Dir: reflect.SelectDefault},
})
var closed bool
if winnerIndex == 0 {
closed = !open
} else if winnerIndex == 1 {
closed = false
}
return closed, nil
}
func (matcher *BeClosedMatcher) FailureMessage(actual interface{}) (message string) {
return format.Message(actual, "to be closed")
}
func (matcher *BeClosedMatcher) NegatedFailureMessage(actual interface{}) (message string) {
return format.Message(actual, "to be open")
}
| go | Apache-2.0 | b3b4703e958c25d54c4d48138d9e80ae32fadac3 | 2026-01-07T09:44:30.792320Z | false |
kubev2v/forklift | https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/github.com/onsi/gomega/matchers/have_field.go | vendor/github.com/onsi/gomega/matchers/have_field.go | package matchers
import (
"fmt"
"reflect"
"strings"
"github.com/onsi/gomega/format"
)
// missingFieldError represents a missing field extraction error that
// HaveExistingFieldMatcher can ignore, as opposed to other, sever field
// extraction errors, such as nil pointers, et cetera.
type missingFieldError string
func (e missingFieldError) Error() string {
return string(e)
}
func extractField(actual interface{}, field string, matchername string) (any, error) {
fields := strings.SplitN(field, ".", 2)
actualValue := reflect.ValueOf(actual)
if actualValue.Kind() == reflect.Ptr {
actualValue = actualValue.Elem()
}
if actualValue == (reflect.Value{}) {
return nil, fmt.Errorf("%s encountered nil while dereferencing a pointer of type %T.", matchername, actual)
}
if actualValue.Kind() != reflect.Struct {
return nil, fmt.Errorf("%s encountered:\n%s\nWhich is not a struct.", matchername, format.Object(actual, 1))
}
var extractedValue reflect.Value
if strings.HasSuffix(fields[0], "()") {
extractedValue = actualValue.MethodByName(strings.TrimSuffix(fields[0], "()"))
if extractedValue == (reflect.Value{}) && actualValue.CanAddr() {
extractedValue = actualValue.Addr().MethodByName(strings.TrimSuffix(fields[0], "()"))
}
if extractedValue == (reflect.Value{}) {
ptr := reflect.New(actualValue.Type())
ptr.Elem().Set(actualValue)
extractedValue = ptr.MethodByName(strings.TrimSuffix(fields[0], "()"))
if extractedValue == (reflect.Value{}) {
return nil, missingFieldError(fmt.Sprintf("%s could not find method named '%s' in struct of type %T.", matchername, fields[0], actual))
}
}
t := extractedValue.Type()
if t.NumIn() != 0 || t.NumOut() != 1 {
return nil, fmt.Errorf("%s found an invalid method named '%s' in struct of type %T.\nMethods must take no arguments and return exactly one value.", matchername, fields[0], actual)
}
extractedValue = extractedValue.Call([]reflect.Value{})[0]
} else {
extractedValue = actualValue.FieldByName(fields[0])
if extractedValue == (reflect.Value{}) {
return nil, missingFieldError(fmt.Sprintf("%s could not find field named '%s' in struct:\n%s", matchername, fields[0], format.Object(actual, 1)))
}
}
if len(fields) == 1 {
return extractedValue.Interface(), nil
} else {
return extractField(extractedValue.Interface(), fields[1], matchername)
}
}
type HaveFieldMatcher struct {
Field string
Expected interface{}
}
func (matcher *HaveFieldMatcher) expectedMatcher() omegaMatcher {
var isMatcher bool
expectedMatcher, isMatcher := matcher.Expected.(omegaMatcher)
if !isMatcher {
expectedMatcher = &EqualMatcher{Expected: matcher.Expected}
}
return expectedMatcher
}
func (matcher *HaveFieldMatcher) Match(actual interface{}) (success bool, err error) {
extractedField, err := extractField(actual, matcher.Field, "HaveField")
if err != nil {
return false, err
}
return matcher.expectedMatcher().Match(extractedField)
}
func (matcher *HaveFieldMatcher) FailureMessage(actual interface{}) (message string) {
extractedField, err := extractField(actual, matcher.Field, "HaveField")
if err != nil {
// this really shouldn't happen
return fmt.Sprintf("Failed to extract field '%s': %s", matcher.Field, err)
}
message = fmt.Sprintf("Value for field '%s' failed to satisfy matcher.\n", matcher.Field)
message += matcher.expectedMatcher().FailureMessage(extractedField)
return message
}
func (matcher *HaveFieldMatcher) NegatedFailureMessage(actual interface{}) (message string) {
extractedField, err := extractField(actual, matcher.Field, "HaveField")
if err != nil {
// this really shouldn't happen
return fmt.Sprintf("Failed to extract field '%s': %s", matcher.Field, err)
}
message = fmt.Sprintf("Value for field '%s' satisfied matcher, but should not have.\n", matcher.Field)
message += matcher.expectedMatcher().NegatedFailureMessage(extractedField)
return message
}
| go | Apache-2.0 | b3b4703e958c25d54c4d48138d9e80ae32fadac3 | 2026-01-07T09:44:30.792320Z | false |
kubev2v/forklift | https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/github.com/onsi/gomega/matchers/be_empty_matcher.go | vendor/github.com/onsi/gomega/matchers/be_empty_matcher.go | // untested sections: 2
package matchers
import (
"fmt"
"reflect"
"github.com/onsi/gomega/format"
"github.com/onsi/gomega/matchers/internal/miter"
)
type BeEmptyMatcher struct {
}
func (matcher *BeEmptyMatcher) Match(actual interface{}) (success bool, err error) {
// short-circuit the iterator case, as we only need to see the first
// element, if any.
if miter.IsIter(actual) {
var length int
if miter.IsSeq2(actual) {
miter.IterateKV(actual, func(k, v reflect.Value) bool { length++; return false })
} else {
miter.IterateV(actual, func(v reflect.Value) bool { length++; return false })
}
return length == 0, nil
}
length, ok := lengthOf(actual)
if !ok {
return false, fmt.Errorf("BeEmpty matcher expects a string/array/map/channel/slice/iterator. Got:\n%s", format.Object(actual, 1))
}
return length == 0, nil
}
func (matcher *BeEmptyMatcher) FailureMessage(actual interface{}) (message string) {
return format.Message(actual, "to be empty")
}
func (matcher *BeEmptyMatcher) NegatedFailureMessage(actual interface{}) (message string) {
return format.Message(actual, "not to be empty")
}
| go | Apache-2.0 | b3b4703e958c25d54c4d48138d9e80ae32fadac3 | 2026-01-07T09:44:30.792320Z | false |
kubev2v/forklift | https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/github.com/onsi/gomega/matchers/have_http_status_matcher.go | vendor/github.com/onsi/gomega/matchers/have_http_status_matcher.go | package matchers
import (
"fmt"
"net/http"
"net/http/httptest"
"reflect"
"strings"
"github.com/onsi/gomega/format"
"github.com/onsi/gomega/internal/gutil"
)
type HaveHTTPStatusMatcher struct {
Expected []interface{}
}
func (matcher *HaveHTTPStatusMatcher) Match(actual interface{}) (success bool, err error) {
var resp *http.Response
switch a := actual.(type) {
case *http.Response:
resp = a
case *httptest.ResponseRecorder:
resp = a.Result()
default:
return false, fmt.Errorf("HaveHTTPStatus matcher expects *http.Response or *httptest.ResponseRecorder. Got:\n%s", format.Object(actual, 1))
}
if len(matcher.Expected) == 0 {
return false, fmt.Errorf("HaveHTTPStatus matcher must be passed an int or a string. Got nothing")
}
for _, expected := range matcher.Expected {
switch e := expected.(type) {
case int:
if resp.StatusCode == e {
return true, nil
}
case string:
if resp.Status == e {
return true, nil
}
default:
return false, fmt.Errorf("HaveHTTPStatus matcher must be passed int or string types. Got:\n%s", format.Object(expected, 1))
}
}
return false, nil
}
func (matcher *HaveHTTPStatusMatcher) FailureMessage(actual interface{}) (message string) {
return fmt.Sprintf("Expected\n%s\n%s\n%s", formatHttpResponse(actual), "to have HTTP status", matcher.expectedString())
}
func (matcher *HaveHTTPStatusMatcher) NegatedFailureMessage(actual interface{}) (message string) {
return fmt.Sprintf("Expected\n%s\n%s\n%s", formatHttpResponse(actual), "not to have HTTP status", matcher.expectedString())
}
func (matcher *HaveHTTPStatusMatcher) expectedString() string {
var lines []string
for _, expected := range matcher.Expected {
lines = append(lines, format.Object(expected, 1))
}
return strings.Join(lines, "\n")
}
func formatHttpResponse(input interface{}) string {
var resp *http.Response
switch r := input.(type) {
case *http.Response:
resp = r
case *httptest.ResponseRecorder:
resp = r.Result()
default:
return "cannot format invalid HTTP response"
}
body := "<nil>"
if resp.Body != nil {
defer resp.Body.Close()
data, err := gutil.ReadAll(resp.Body)
if err != nil {
data = []byte("<error reading body>")
}
body = format.Object(string(data), 0)
}
var s strings.Builder
s.WriteString(fmt.Sprintf("%s<%s>: {\n", format.Indent, reflect.TypeOf(input)))
s.WriteString(fmt.Sprintf("%s%sStatus: %s\n", format.Indent, format.Indent, format.Object(resp.Status, 0)))
s.WriteString(fmt.Sprintf("%s%sStatusCode: %s\n", format.Indent, format.Indent, format.Object(resp.StatusCode, 0)))
s.WriteString(fmt.Sprintf("%s%sBody: %s\n", format.Indent, format.Indent, body))
s.WriteString(fmt.Sprintf("%s}", format.Indent))
return s.String()
}
| go | Apache-2.0 | b3b4703e958c25d54c4d48138d9e80ae32fadac3 | 2026-01-07T09:44:30.792320Z | false |
kubev2v/forklift | https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/github.com/onsi/gomega/matchers/have_len_matcher.go | vendor/github.com/onsi/gomega/matchers/have_len_matcher.go | package matchers
import (
"fmt"
"github.com/onsi/gomega/format"
)
type HaveLenMatcher struct {
Count int
}
func (matcher *HaveLenMatcher) Match(actual interface{}) (success bool, err error) {
length, ok := lengthOf(actual)
if !ok {
return false, fmt.Errorf("HaveLen matcher expects a string/array/map/channel/slice/iterator. Got:\n%s", format.Object(actual, 1))
}
return length == matcher.Count, nil
}
func (matcher *HaveLenMatcher) FailureMessage(actual interface{}) (message string) {
return fmt.Sprintf("Expected\n%s\nto have length %d", format.Object(actual, 1), matcher.Count)
}
func (matcher *HaveLenMatcher) NegatedFailureMessage(actual interface{}) (message string) {
return fmt.Sprintf("Expected\n%s\nnot to have length %d", format.Object(actual, 1), matcher.Count)
}
| go | Apache-2.0 | b3b4703e958c25d54c4d48138d9e80ae32fadac3 | 2026-01-07T09:44:30.792320Z | false |
kubev2v/forklift | https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/github.com/onsi/gomega/matchers/be_key_of_matcher.go | vendor/github.com/onsi/gomega/matchers/be_key_of_matcher.go | package matchers
import (
"fmt"
"reflect"
"github.com/onsi/gomega/format"
)
type BeKeyOfMatcher struct {
Map interface{}
}
func (matcher *BeKeyOfMatcher) Match(actual interface{}) (success bool, err error) {
if !isMap(matcher.Map) {
return false, fmt.Errorf("BeKeyOf matcher needs expected to be a map type")
}
if reflect.TypeOf(actual) == nil {
return false, fmt.Errorf("BeKeyOf matcher expects actual to be typed")
}
var lastError error
for _, key := range reflect.ValueOf(matcher.Map).MapKeys() {
matcher := &EqualMatcher{Expected: key.Interface()}
success, err := matcher.Match(actual)
if err != nil {
lastError = err
continue
}
if success {
return true, nil
}
}
return false, lastError
}
func (matcher *BeKeyOfMatcher) FailureMessage(actual interface{}) (message string) {
return format.Message(actual, "to be a key of", presentable(valuesOf(matcher.Map)))
}
func (matcher *BeKeyOfMatcher) NegatedFailureMessage(actual interface{}) (message string) {
return format.Message(actual, "not to be a key of", presentable(valuesOf(matcher.Map)))
}
| go | Apache-2.0 | b3b4703e958c25d54c4d48138d9e80ae32fadac3 | 2026-01-07T09:44:30.792320Z | false |
kubev2v/forklift | https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/github.com/onsi/gomega/matchers/have_key_matcher.go | vendor/github.com/onsi/gomega/matchers/have_key_matcher.go | // untested sections: 6
package matchers
import (
"fmt"
"reflect"
"github.com/onsi/gomega/format"
"github.com/onsi/gomega/matchers/internal/miter"
)
type HaveKeyMatcher struct {
Key interface{}
}
func (matcher *HaveKeyMatcher) Match(actual interface{}) (success bool, err error) {
if !isMap(actual) && !miter.IsSeq2(actual) {
return false, fmt.Errorf("HaveKey matcher expects a map/iter.Seq2. Got:%s", format.Object(actual, 1))
}
keyMatcher, keyIsMatcher := matcher.Key.(omegaMatcher)
if !keyIsMatcher {
keyMatcher = &EqualMatcher{Expected: matcher.Key}
}
if miter.IsSeq2(actual) {
var success bool
var err error
miter.IterateKV(actual, func(k, v reflect.Value) bool {
success, err = keyMatcher.Match(k.Interface())
if err != nil {
err = fmt.Errorf("HaveKey's key matcher failed with:\n%s%s", format.Indent, err.Error())
return false
}
return !success
})
return success, err
}
keys := reflect.ValueOf(actual).MapKeys()
for i := 0; i < len(keys); i++ {
success, err := keyMatcher.Match(keys[i].Interface())
if err != nil {
return false, fmt.Errorf("HaveKey's key matcher failed with:\n%s%s", format.Indent, err.Error())
}
if success {
return true, nil
}
}
return false, nil
}
func (matcher *HaveKeyMatcher) FailureMessage(actual interface{}) (message string) {
switch matcher.Key.(type) {
case omegaMatcher:
return format.Message(actual, "to have key matching", matcher.Key)
default:
return format.Message(actual, "to have key", matcher.Key)
}
}
func (matcher *HaveKeyMatcher) NegatedFailureMessage(actual interface{}) (message string) {
switch matcher.Key.(type) {
case omegaMatcher:
return format.Message(actual, "not to have key matching", matcher.Key)
default:
return format.Message(actual, "not to have key", matcher.Key)
}
}
| go | Apache-2.0 | b3b4703e958c25d54c4d48138d9e80ae32fadac3 | 2026-01-07T09:44:30.792320Z | false |
kubev2v/forklift | https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/github.com/onsi/gomega/matchers/support/goraph/util/util.go | vendor/github.com/onsi/gomega/matchers/support/goraph/util/util.go | package util
import "math"
func Odd(n int) bool {
return math.Mod(float64(n), 2.0) == 1.0
}
| go | Apache-2.0 | b3b4703e958c25d54c4d48138d9e80ae32fadac3 | 2026-01-07T09:44:30.792320Z | false |
kubev2v/forklift | https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/github.com/onsi/gomega/matchers/support/goraph/node/node.go | vendor/github.com/onsi/gomega/matchers/support/goraph/node/node.go | package node
type Node struct {
ID int
Value interface{}
}
type NodeOrderedSet []Node
| go | Apache-2.0 | b3b4703e958c25d54c4d48138d9e80ae32fadac3 | 2026-01-07T09:44:30.792320Z | false |
kubev2v/forklift | https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/github.com/onsi/gomega/matchers/support/goraph/bipartitegraph/bipartitegraphmatching.go | vendor/github.com/onsi/gomega/matchers/support/goraph/bipartitegraph/bipartitegraphmatching.go | package bipartitegraph
import (
"slices"
. "github.com/onsi/gomega/matchers/support/goraph/edge"
. "github.com/onsi/gomega/matchers/support/goraph/node"
"github.com/onsi/gomega/matchers/support/goraph/util"
)
// LargestMatching implements the Hopcroft–Karp algorithm taking as input a bipartite graph
// and outputting a maximum cardinality matching, i.e. a set of as many edges as possible
// with the property that no two edges share an endpoint.
func (bg *BipartiteGraph) LargestMatching() (matching EdgeSet) {
paths := bg.maximalDisjointSLAPCollection(matching)
for len(paths) > 0 {
for _, path := range paths {
matching = matching.SymmetricDifference(path)
}
paths = bg.maximalDisjointSLAPCollection(matching)
}
return
}
func (bg *BipartiteGraph) maximalDisjointSLAPCollection(matching EdgeSet) (result []EdgeSet) {
guideLayers := bg.createSLAPGuideLayers(matching)
if len(guideLayers) == 0 {
return
}
used := make(map[int]bool)
for _, u := range guideLayers[len(guideLayers)-1] {
slap, found := bg.findDisjointSLAP(u, matching, guideLayers, used)
if found {
for _, edge := range slap {
used[edge.Node1] = true
used[edge.Node2] = true
}
result = append(result, slap)
}
}
return
}
func (bg *BipartiteGraph) findDisjointSLAP(
start Node,
matching EdgeSet,
guideLayers []NodeOrderedSet,
used map[int]bool,
) ([]Edge, bool) {
return bg.findDisjointSLAPHelper(start, EdgeSet{}, len(guideLayers)-1, matching, guideLayers, used)
}
func (bg *BipartiteGraph) findDisjointSLAPHelper(
currentNode Node,
currentSLAP EdgeSet,
currentLevel int,
matching EdgeSet,
guideLayers []NodeOrderedSet,
used map[int]bool,
) (EdgeSet, bool) {
used[currentNode.ID] = true
if currentLevel == 0 {
return currentSLAP, true
}
for _, nextNode := range guideLayers[currentLevel-1] {
if used[nextNode.ID] {
continue
}
edge, found := bg.Edges.FindByNodes(currentNode, nextNode)
if !found {
continue
}
if matching.Contains(edge) == util.Odd(currentLevel) {
continue
}
currentSLAP = append(currentSLAP, edge)
slap, found := bg.findDisjointSLAPHelper(nextNode, currentSLAP, currentLevel-1, matching, guideLayers, used)
if found {
return slap, true
}
currentSLAP = currentSLAP[:len(currentSLAP)-1]
}
used[currentNode.ID] = false
return nil, false
}
func (bg *BipartiteGraph) createSLAPGuideLayers(matching EdgeSet) (guideLayers []NodeOrderedSet) {
used := make(map[int]bool)
currentLayer := NodeOrderedSet{}
for _, node := range bg.Left {
if matching.Free(node) {
used[node.ID] = true
currentLayer = append(currentLayer, node)
}
}
if len(currentLayer) == 0 {
return []NodeOrderedSet{}
}
guideLayers = append(guideLayers, currentLayer)
done := false
for !done {
lastLayer := currentLayer
currentLayer = NodeOrderedSet{}
if util.Odd(len(guideLayers)) {
for _, leftNode := range lastLayer {
for _, rightNode := range bg.Right {
if used[rightNode.ID] {
continue
}
edge, found := bg.Edges.FindByNodes(leftNode, rightNode)
if !found || matching.Contains(edge) {
continue
}
currentLayer = append(currentLayer, rightNode)
used[rightNode.ID] = true
if matching.Free(rightNode) {
done = true
}
}
}
} else {
for _, rightNode := range lastLayer {
for _, leftNode := range bg.Left {
if used[leftNode.ID] {
continue
}
edge, found := bg.Edges.FindByNodes(leftNode, rightNode)
if !found || !matching.Contains(edge) {
continue
}
currentLayer = append(currentLayer, leftNode)
used[leftNode.ID] = true
}
}
}
if len(currentLayer) == 0 {
return []NodeOrderedSet{}
}
if done { // if last layer - into last layer must be only 'free' nodes
currentLayer = slices.DeleteFunc(currentLayer, func(in Node) bool {
return !matching.Free(in)
})
}
guideLayers = append(guideLayers, currentLayer)
}
return
}
| go | Apache-2.0 | b3b4703e958c25d54c4d48138d9e80ae32fadac3 | 2026-01-07T09:44:30.792320Z | false |
kubev2v/forklift | https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/github.com/onsi/gomega/matchers/support/goraph/bipartitegraph/bipartitegraph.go | vendor/github.com/onsi/gomega/matchers/support/goraph/bipartitegraph/bipartitegraph.go | package bipartitegraph
import "fmt"
import . "github.com/onsi/gomega/matchers/support/goraph/node"
import . "github.com/onsi/gomega/matchers/support/goraph/edge"
type BipartiteGraph struct {
Left NodeOrderedSet
Right NodeOrderedSet
Edges EdgeSet
}
func NewBipartiteGraph(leftValues, rightValues []interface{}, neighbours func(interface{}, interface{}) (bool, error)) (*BipartiteGraph, error) {
left := NodeOrderedSet{}
for i, v := range leftValues {
left = append(left, Node{ID: i, Value: v})
}
right := NodeOrderedSet{}
for j, v := range rightValues {
right = append(right, Node{ID: j + len(left), Value: v})
}
edges := EdgeSet{}
for i, leftValue := range leftValues {
for j, rightValue := range rightValues {
neighbours, err := neighbours(leftValue, rightValue)
if err != nil {
return nil, fmt.Errorf("error determining adjacency for %v and %v: %s", leftValue, rightValue, err.Error())
}
if neighbours {
edges = append(edges, Edge{Node1: left[i].ID, Node2: right[j].ID})
}
}
}
return &BipartiteGraph{left, right, edges}, nil
}
// FreeLeftRight returns left node values and right node values
// of the BipartiteGraph's nodes which are not part of the given edges.
func (bg *BipartiteGraph) FreeLeftRight(edges EdgeSet) (leftValues, rightValues []interface{}) {
for _, node := range bg.Left {
if edges.Free(node) {
leftValues = append(leftValues, node.Value)
}
}
for _, node := range bg.Right {
if edges.Free(node) {
rightValues = append(rightValues, node.Value)
}
}
return
}
| go | Apache-2.0 | b3b4703e958c25d54c4d48138d9e80ae32fadac3 | 2026-01-07T09:44:30.792320Z | false |
kubev2v/forklift | https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/github.com/onsi/gomega/matchers/support/goraph/edge/edge.go | vendor/github.com/onsi/gomega/matchers/support/goraph/edge/edge.go | package edge
import . "github.com/onsi/gomega/matchers/support/goraph/node"
type Edge struct {
Node1 int
Node2 int
}
type EdgeSet []Edge
func (ec EdgeSet) Free(node Node) bool {
for _, e := range ec {
if e.Node1 == node.ID || e.Node2 == node.ID {
return false
}
}
return true
}
func (ec EdgeSet) Contains(edge Edge) bool {
for _, e := range ec {
if e == edge {
return true
}
}
return false
}
func (ec EdgeSet) FindByNodes(node1, node2 Node) (Edge, bool) {
for _, e := range ec {
if (e.Node1 == node1.ID && e.Node2 == node2.ID) || (e.Node1 == node2.ID && e.Node2 == node1.ID) {
return e, true
}
}
return Edge{}, false
}
func (ec EdgeSet) SymmetricDifference(ec2 EdgeSet) EdgeSet {
edgesToInclude := make(map[Edge]bool)
for _, e := range ec {
edgesToInclude[e] = true
}
for _, e := range ec2 {
edgesToInclude[e] = !edgesToInclude[e]
}
result := EdgeSet{}
for e, include := range edgesToInclude {
if include {
result = append(result, e)
}
}
return result
}
| go | Apache-2.0 | b3b4703e958c25d54c4d48138d9e80ae32fadac3 | 2026-01-07T09:44:30.792320Z | false |
kubev2v/forklift | https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/github.com/onsi/gomega/matchers/internal/miter/type_support_noiter.go | vendor/github.com/onsi/gomega/matchers/internal/miter/type_support_noiter.go | //go:build !go1.23
/*
Gomega matchers
This package implements the Gomega matchers and does not typically need to be imported.
See the docs for Gomega for documentation on the matchers
http://onsi.github.io/gomega/
*/
package miter
import "reflect"
// HasIterators always returns false for Go versions before 1.23.
func HasIterators() bool { return false }
// IsIter always returns false for Go versions before 1.23 as there is no
// iterator (function) pattern defined yet; see also:
// https://tip.golang.org/blog/range-functions.
func IsIter(i any) bool { return false }
// IsSeq2 always returns false for Go versions before 1.23 as there is no
// iterator (function) pattern defined yet; see also:
// https://tip.golang.org/blog/range-functions.
func IsSeq2(it any) bool { return false }
// IterKVTypes always returns nil reflection types for Go versions before 1.23
// as there is no iterator (function) pattern defined yet; see also:
// https://tip.golang.org/blog/range-functions.
func IterKVTypes(i any) (k, v reflect.Type) {
return
}
// IterateV never loops over what has been passed to it as an iterator for Go
// versions before 1.23 as there is no iterator (function) pattern defined yet;
// see also: https://tip.golang.org/blog/range-functions.
func IterateV(it any, yield func(v reflect.Value) bool) {}
// IterateKV never loops over what has been passed to it as an iterator for Go
// versions before 1.23 as there is no iterator (function) pattern defined yet;
// see also: https://tip.golang.org/blog/range-functions.
func IterateKV(it any, yield func(k, v reflect.Value) bool) {}
| go | Apache-2.0 | b3b4703e958c25d54c4d48138d9e80ae32fadac3 | 2026-01-07T09:44:30.792320Z | false |
kubev2v/forklift | https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/github.com/onsi/gomega/matchers/internal/miter/type_support_iter.go | vendor/github.com/onsi/gomega/matchers/internal/miter/type_support_iter.go | //go:build go1.23
package miter
import (
"reflect"
)
// HasIterators always returns false for Go versions before 1.23.
func HasIterators() bool { return true }
// IsIter returns true if the specified value is a function type that can be
// range-d over, otherwise false.
//
// We don't use reflect's CanSeq and CanSeq2 directly, as these would return
// true also for other value types that are range-able, such as integers,
// slices, et cetera. Here, we aim only at range-able (iterator) functions.
func IsIter(it any) bool {
if it == nil { // on purpose we only test for untyped nil.
return false
}
// reject all non-iterator-func values, even if they're range-able.
t := reflect.TypeOf(it)
if t.Kind() != reflect.Func {
return false
}
return t.CanSeq() || t.CanSeq2()
}
// IterKVTypes returns the reflection types of an iterator's yield function's K
// and optional V arguments, otherwise nil K and V reflection types.
func IterKVTypes(it any) (k, v reflect.Type) {
if it == nil {
return
}
// reject all non-iterator-func values, even if they're range-able.
t := reflect.TypeOf(it)
if t.Kind() != reflect.Func {
return
}
// get the reflection types for V, and where applicable, K.
switch {
case t.CanSeq():
v = t. /*iterator fn*/ In(0). /*yield fn*/ In(0)
case t.CanSeq2():
yieldfn := t. /*iterator fn*/ In(0)
k = yieldfn.In(0)
v = yieldfn.In(1)
}
return
}
// IsSeq2 returns true if the passed iterator function is compatible with
// iter.Seq2, otherwise false.
//
// IsSeq2 hides the Go 1.23+ specific reflect.Type.CanSeq2 behind a facade which
// is empty for Go versions before 1.23.
func IsSeq2(it any) bool {
if it == nil {
return false
}
t := reflect.TypeOf(it)
return t.Kind() == reflect.Func && t.CanSeq2()
}
// isNilly returns true if v is either an untyped nil, or is a nil function (not
// necessarily an iterator function).
func isNilly(v any) bool {
if v == nil {
return true
}
rv := reflect.ValueOf(v)
return rv.Kind() == reflect.Func && rv.IsNil()
}
// IterateV loops over the elements produced by an iterator function, passing
// the elements to the specified yield function individually and stopping only
// when either the iterator function runs out of elements or the yield function
// tell us to stop it.
//
// IterateV works very much like reflect.Value.Seq but hides the Go 1.23+
// specific parts behind a facade which is empty for Go versions before 1.23, in
// order to simplify code maintenance for matchers when using older Go versions.
func IterateV(it any, yield func(v reflect.Value) bool) {
if isNilly(it) {
return
}
// reject all non-iterator-func values, even if they're range-able.
t := reflect.TypeOf(it)
if t.Kind() != reflect.Func || !t.CanSeq() {
return
}
// Call the specified iterator function, handing it our adaptor to call the
// specified generic reflection yield function.
reflectedYield := reflect.MakeFunc(
t. /*iterator fn*/ In(0),
func(args []reflect.Value) []reflect.Value {
return []reflect.Value{reflect.ValueOf(yield(args[0]))}
})
reflect.ValueOf(it).Call([]reflect.Value{reflectedYield})
}
// IterateKV loops over the key-value elements produced by an iterator function,
// passing the elements to the specified yield function individually and
// stopping only when either the iterator function runs out of elements or the
// yield function tell us to stop it.
//
// IterateKV works very much like reflect.Value.Seq2 but hides the Go 1.23+
// specific parts behind a facade which is empty for Go versions before 1.23, in
// order to simplify code maintenance for matchers when using older Go versions.
func IterateKV(it any, yield func(k, v reflect.Value) bool) {
if isNilly(it) {
return
}
// reject all non-iterator-func values, even if they're range-able.
t := reflect.TypeOf(it)
if t.Kind() != reflect.Func || !t.CanSeq2() {
return
}
// Call the specified iterator function, handing it our adaptor to call the
// specified generic reflection yield function.
reflectedYield := reflect.MakeFunc(
t. /*iterator fn*/ In(0),
func(args []reflect.Value) []reflect.Value {
return []reflect.Value{reflect.ValueOf(yield(args[0], args[1]))}
})
reflect.ValueOf(it).Call([]reflect.Value{reflectedYield})
}
| go | Apache-2.0 | b3b4703e958c25d54c4d48138d9e80ae32fadac3 | 2026-01-07T09:44:30.792320Z | false |
kubev2v/forklift | https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/github.com/onsi/gomega/format/format.go | vendor/github.com/onsi/gomega/format/format.go | /*
Gomega's format package pretty-prints objects. It explores input objects recursively and generates formatted, indented output with type information.
*/
// untested sections: 4
package format
import (
"context"
"fmt"
"reflect"
"strconv"
"strings"
"time"
)
// Use MaxDepth to set the maximum recursion depth when printing deeply nested objects
var MaxDepth = uint(10)
// MaxLength of the string representation of an object.
// If MaxLength is set to 0, the Object will not be truncated.
var MaxLength = 4000
/*
By default, all objects (even those that implement fmt.Stringer and fmt.GoStringer) are recursively inspected to generate output.
Set UseStringerRepresentation = true to use GoString (for fmt.GoStringers) or String (for fmt.Stringer) instead.
Note that GoString and String don't always have all the information you need to understand why a test failed!
*/
var UseStringerRepresentation = false
/*
Print the content of context objects. By default it will be suppressed.
Set PrintContextObjects = true to enable printing of the context internals.
*/
var PrintContextObjects = false
// TruncatedDiff choose if we should display a truncated pretty diff or not
var TruncatedDiff = true
// TruncateThreshold (default 50) specifies the maximum length string to print in string comparison assertion error
// messages.
var TruncateThreshold uint = 50
// CharactersAroundMismatchToInclude (default 5) specifies how many contextual characters should be printed before and
// after the first diff location in a truncated string assertion error message.
var CharactersAroundMismatchToInclude uint = 5
var contextType = reflect.TypeOf((*context.Context)(nil)).Elem()
var timeType = reflect.TypeOf(time.Time{})
// The default indentation string emitted by the format package
var Indent = " "
var longFormThreshold = 20
// GomegaStringer allows for custom formating of objects for gomega.
type GomegaStringer interface {
// GomegaString will be used to custom format an object.
// It does not follow UseStringerRepresentation value and will always be called regardless.
// It also ignores the MaxLength value.
GomegaString() string
}
/*
CustomFormatters can be registered with Gomega via RegisterCustomFormatter()
Any value to be rendered by Gomega is passed to each registered CustomFormatters.
The CustomFormatter signals that it will handle formatting the value by returning (formatted-string, true)
If the CustomFormatter does not want to handle the object it should return ("", false)
Strings returned by CustomFormatters are not truncated
*/
type CustomFormatter func(value interface{}) (string, bool)
type CustomFormatterKey uint
var customFormatterKey CustomFormatterKey = 1
type customFormatterKeyPair struct {
CustomFormatter
CustomFormatterKey
}
/*
RegisterCustomFormatter registers a CustomFormatter and returns a CustomFormatterKey
You can call UnregisterCustomFormatter with the returned key to unregister the associated CustomFormatter
*/
func RegisterCustomFormatter(customFormatter CustomFormatter) CustomFormatterKey {
key := customFormatterKey
customFormatterKey += 1
customFormatters = append(customFormatters, customFormatterKeyPair{customFormatter, key})
return key
}
/*
UnregisterCustomFormatter unregisters a previously registered CustomFormatter. You should pass in the key returned by RegisterCustomFormatter
*/
func UnregisterCustomFormatter(key CustomFormatterKey) {
formatters := []customFormatterKeyPair{}
for _, f := range customFormatters {
if f.CustomFormatterKey == key {
continue
}
formatters = append(formatters, f)
}
customFormatters = formatters
}
var customFormatters = []customFormatterKeyPair{}
/*
Generates a formatted matcher success/failure message of the form:
Expected
<pretty printed actual>
<message>
<pretty printed expected>
If expected is omitted, then the message looks like:
Expected
<pretty printed actual>
<message>
*/
func Message(actual interface{}, message string, expected ...interface{}) string {
if len(expected) == 0 {
return fmt.Sprintf("Expected\n%s\n%s", Object(actual, 1), message)
}
return fmt.Sprintf("Expected\n%s\n%s\n%s", Object(actual, 1), message, Object(expected[0], 1))
}
/*
Generates a nicely formatted matcher success / failure message
Much like Message(...), but it attempts to pretty print diffs in strings
Expected
<string>: "...aaaaabaaaaa..."
to equal |
<string>: "...aaaaazaaaaa..."
*/
func MessageWithDiff(actual, message, expected string) string {
if TruncatedDiff && len(actual) >= int(TruncateThreshold) && len(expected) >= int(TruncateThreshold) {
diffPoint := findFirstMismatch(actual, expected)
formattedActual := truncateAndFormat(actual, diffPoint)
formattedExpected := truncateAndFormat(expected, diffPoint)
spacesBeforeFormattedMismatch := findFirstMismatch(formattedActual, formattedExpected)
tabLength := 4
spaceFromMessageToActual := tabLength + len("<string>: ") - len(message)
paddingCount := spaceFromMessageToActual + spacesBeforeFormattedMismatch
if paddingCount < 0 {
return Message(formattedActual, message, formattedExpected)
}
padding := strings.Repeat(" ", paddingCount) + "|"
return Message(formattedActual, message+padding, formattedExpected)
}
actual = escapedWithGoSyntax(actual)
expected = escapedWithGoSyntax(expected)
return Message(actual, message, expected)
}
func escapedWithGoSyntax(str string) string {
withQuotes := fmt.Sprintf("%q", str)
return withQuotes[1 : len(withQuotes)-1]
}
func truncateAndFormat(str string, index int) string {
leftPadding := `...`
rightPadding := `...`
start := index - int(CharactersAroundMismatchToInclude)
if start < 0 {
start = 0
leftPadding = ""
}
// slice index must include the mis-matched character
lengthOfMismatchedCharacter := 1
end := index + int(CharactersAroundMismatchToInclude) + lengthOfMismatchedCharacter
if end > len(str) {
end = len(str)
rightPadding = ""
}
return fmt.Sprintf("\"%s\"", leftPadding+str[start:end]+rightPadding)
}
func findFirstMismatch(a, b string) int {
aSlice := strings.Split(a, "")
bSlice := strings.Split(b, "")
for index, str := range aSlice {
if index > len(bSlice)-1 {
return index
}
if str != bSlice[index] {
return index
}
}
if len(b) > len(a) {
return len(a) + 1
}
return 0
}
const truncateHelpText = `
Gomega truncated this representation as it exceeds 'format.MaxLength'.
Consider having the object provide a custom 'GomegaStringer' representation
or adjust the parameters in Gomega's 'format' package.
Learn more here: https://onsi.github.io/gomega/#adjusting-output
`
func truncateLongStrings(s string) string {
if MaxLength > 0 && len(s) > MaxLength {
var sb strings.Builder
for i, r := range s {
if i < MaxLength {
sb.WriteRune(r)
continue
}
break
}
sb.WriteString("...\n")
sb.WriteString(truncateHelpText)
return sb.String()
}
return s
}
/*
Pretty prints the passed in object at the passed in indentation level.
Object recurses into deeply nested objects emitting pretty-printed representations of their components.
Modify format.MaxDepth to control how deep the recursion is allowed to go
Set format.UseStringerRepresentation to true to return object.GoString() or object.String() when available instead of
recursing into the object.
Set PrintContextObjects to true to print the content of objects implementing context.Context
*/
func Object(object interface{}, indentation uint) string {
indent := strings.Repeat(Indent, int(indentation))
value := reflect.ValueOf(object)
commonRepresentation := ""
if err, ok := object.(error); ok && !isNilValue(value) { // isNilValue check needed here to avoid nil deref due to boxed nil
commonRepresentation += "\n" + IndentString(err.Error(), indentation) + "\n" + indent
}
return fmt.Sprintf("%s<%s>: %s%s", indent, formatType(value), commonRepresentation, formatValue(value, indentation))
}
/*
IndentString takes a string and indents each line by the specified amount.
*/
func IndentString(s string, indentation uint) string {
return indentString(s, indentation, true)
}
func indentString(s string, indentation uint, indentFirstLine bool) string {
result := &strings.Builder{}
components := strings.Split(s, "\n")
indent := strings.Repeat(Indent, int(indentation))
for i, component := range components {
if i > 0 || indentFirstLine {
result.WriteString(indent)
}
result.WriteString(component)
if i < len(components)-1 {
result.WriteString("\n")
}
}
return result.String()
}
func formatType(v reflect.Value) string {
switch v.Kind() {
case reflect.Invalid:
return "nil"
case reflect.Chan:
return fmt.Sprintf("%s | len:%d, cap:%d", v.Type(), v.Len(), v.Cap())
case reflect.Ptr:
return fmt.Sprintf("%s | 0x%x", v.Type(), v.Pointer())
case reflect.Slice:
return fmt.Sprintf("%s | len:%d, cap:%d", v.Type(), v.Len(), v.Cap())
case reflect.Map:
return fmt.Sprintf("%s | len:%d", v.Type(), v.Len())
default:
return v.Type().String()
}
}
func formatValue(value reflect.Value, indentation uint) string {
if indentation > MaxDepth {
return "..."
}
if isNilValue(value) {
return "nil"
}
if value.CanInterface() {
obj := value.Interface()
// if a CustomFormatter handles this values, we'll go with that
for _, customFormatter := range customFormatters {
formatted, handled := customFormatter.CustomFormatter(obj)
// do not truncate a user-provided CustomFormatter()
if handled {
return indentString(formatted, indentation+1, false)
}
}
// GomegaStringer will take precedence to other representations and disregards UseStringerRepresentation
if x, ok := obj.(GomegaStringer); ok {
// do not truncate a user-defined GomegaString() value
return indentString(x.GomegaString(), indentation+1, false)
}
if UseStringerRepresentation {
switch x := obj.(type) {
case fmt.GoStringer:
return indentString(truncateLongStrings(x.GoString()), indentation+1, false)
case fmt.Stringer:
return indentString(truncateLongStrings(x.String()), indentation+1, false)
}
}
}
if !PrintContextObjects {
if value.Type().Implements(contextType) && indentation > 1 {
return "<suppressed context>"
}
}
switch value.Kind() {
case reflect.Bool:
return fmt.Sprintf("%v", value.Bool())
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
return fmt.Sprintf("%v", value.Int())
case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:
return fmt.Sprintf("%v", value.Uint())
case reflect.Uintptr:
return fmt.Sprintf("0x%x", value.Uint())
case reflect.Float32, reflect.Float64:
return fmt.Sprintf("%v", value.Float())
case reflect.Complex64, reflect.Complex128:
return fmt.Sprintf("%v", value.Complex())
case reflect.Chan:
return fmt.Sprintf("0x%x", value.Pointer())
case reflect.Func:
return fmt.Sprintf("0x%x", value.Pointer())
case reflect.Ptr:
return formatValue(value.Elem(), indentation)
case reflect.Slice:
return truncateLongStrings(formatSlice(value, indentation))
case reflect.String:
return truncateLongStrings(formatString(value.String(), indentation))
case reflect.Array:
return truncateLongStrings(formatSlice(value, indentation))
case reflect.Map:
return truncateLongStrings(formatMap(value, indentation))
case reflect.Struct:
if value.Type() == timeType && value.CanInterface() {
t, _ := value.Interface().(time.Time)
return t.Format(time.RFC3339Nano)
}
return truncateLongStrings(formatStruct(value, indentation))
case reflect.Interface:
return formatInterface(value, indentation)
default:
if value.CanInterface() {
return truncateLongStrings(fmt.Sprintf("%#v", value.Interface()))
}
return truncateLongStrings(fmt.Sprintf("%#v", value))
}
}
func formatString(object interface{}, indentation uint) string {
if indentation == 1 {
s := fmt.Sprintf("%s", object)
components := strings.Split(s, "\n")
result := ""
for i, component := range components {
if i == 0 {
result += component
} else {
result += Indent + component
}
if i < len(components)-1 {
result += "\n"
}
}
return result
} else {
return fmt.Sprintf("%q", object)
}
}
func formatSlice(v reflect.Value, indentation uint) string {
if v.Kind() == reflect.Slice && v.Type().Elem().Kind() == reflect.Uint8 && isPrintableString(string(v.Bytes())) {
return formatString(v.Bytes(), indentation)
}
l := v.Len()
result := make([]string, l)
longest := 0
for i := 0; i < l; i++ {
result[i] = formatValue(v.Index(i), indentation+1)
if len(result[i]) > longest {
longest = len(result[i])
}
}
if longest > longFormThreshold {
indenter := strings.Repeat(Indent, int(indentation))
return fmt.Sprintf("[\n%s%s,\n%s]", indenter+Indent, strings.Join(result, ",\n"+indenter+Indent), indenter)
}
return fmt.Sprintf("[%s]", strings.Join(result, ", "))
}
func formatMap(v reflect.Value, indentation uint) string {
l := v.Len()
result := make([]string, l)
longest := 0
for i, key := range v.MapKeys() {
value := v.MapIndex(key)
result[i] = fmt.Sprintf("%s: %s", formatValue(key, indentation+1), formatValue(value, indentation+1))
if len(result[i]) > longest {
longest = len(result[i])
}
}
if longest > longFormThreshold {
indenter := strings.Repeat(Indent, int(indentation))
return fmt.Sprintf("{\n%s%s,\n%s}", indenter+Indent, strings.Join(result, ",\n"+indenter+Indent), indenter)
}
return fmt.Sprintf("{%s}", strings.Join(result, ", "))
}
func formatStruct(v reflect.Value, indentation uint) string {
t := v.Type()
l := v.NumField()
result := []string{}
longest := 0
for i := 0; i < l; i++ {
structField := t.Field(i)
fieldEntry := v.Field(i)
representation := fmt.Sprintf("%s: %s", structField.Name, formatValue(fieldEntry, indentation+1))
result = append(result, representation)
if len(representation) > longest {
longest = len(representation)
}
}
if longest > longFormThreshold {
indenter := strings.Repeat(Indent, int(indentation))
return fmt.Sprintf("{\n%s%s,\n%s}", indenter+Indent, strings.Join(result, ",\n"+indenter+Indent), indenter)
}
return fmt.Sprintf("{%s}", strings.Join(result, ", "))
}
func formatInterface(v reflect.Value, indentation uint) string {
return fmt.Sprintf("<%s>%s", formatType(v.Elem()), formatValue(v.Elem(), indentation))
}
func isNilValue(a reflect.Value) bool {
switch a.Kind() {
case reflect.Invalid:
return true
case reflect.Chan, reflect.Func, reflect.Interface, reflect.Map, reflect.Ptr, reflect.Slice:
return a.IsNil()
}
return false
}
/*
Returns true when the string is entirely made of printable runes, false otherwise.
*/
func isPrintableString(str string) bool {
for _, runeValue := range str {
if !strconv.IsPrint(runeValue) {
return false
}
}
return true
}
| go | Apache-2.0 | b3b4703e958c25d54c4d48138d9e80ae32fadac3 | 2026-01-07T09:44:30.792320Z | false |
kubev2v/forklift | https://github.com/kubev2v/forklift/blob/b3b4703e958c25d54c4d48138d9e80ae32fadac3/vendor/github.com/onsi/ginkgo/ginkgo_dsl.go | vendor/github.com/onsi/ginkgo/ginkgo_dsl.go | /*
Ginkgo is a BDD-style testing framework for Golang
The godoc documentation describes Ginkgo's API. More comprehensive documentation (with examples!) is available at http://onsi.github.io/ginkgo/
Ginkgo's preferred matcher library is [Gomega](http://github.com/onsi/gomega)
Ginkgo on Github: http://github.com/onsi/ginkgo
Ginkgo is MIT-Licensed
*/
package ginkgo
import (
"flag"
"fmt"
"io"
"net/http"
"os"
"reflect"
"strings"
"time"
"github.com/onsi/ginkgo/config"
"github.com/onsi/ginkgo/internal/codelocation"
"github.com/onsi/ginkgo/internal/global"
"github.com/onsi/ginkgo/internal/remote"
"github.com/onsi/ginkgo/internal/testingtproxy"
"github.com/onsi/ginkgo/internal/writer"
"github.com/onsi/ginkgo/reporters"
"github.com/onsi/ginkgo/reporters/stenographer"
colorable "github.com/onsi/ginkgo/reporters/stenographer/support/go-colorable"
"github.com/onsi/ginkgo/types"
)
var deprecationTracker = types.NewDeprecationTracker()
const GINKGO_VERSION = config.VERSION
const GINKGO_PANIC = `
Your test failed.
Ginkgo panics to prevent subsequent assertions from running.
Normally Ginkgo rescues this panic so you shouldn't see it.
But, if you make an assertion in a goroutine, Ginkgo can't capture the panic.
To circumvent this, you should call
defer GinkgoRecover()
at the top of the goroutine that caused this panic.
`
func init() {
config.Flags(flag.CommandLine, "ginkgo", true)
GinkgoWriter = writer.New(os.Stdout)
}
//GinkgoWriter implements an io.Writer
//When running in verbose mode any writes to GinkgoWriter will be immediately printed
//to stdout. Otherwise, GinkgoWriter will buffer any writes produced during the current test and flush them to screen
//only if the current test fails.
var GinkgoWriter io.Writer
//The interface by which Ginkgo receives *testing.T
type GinkgoTestingT interface {
Fail()
}
//GinkgoRandomSeed returns the seed used to randomize spec execution order. It is
//useful for seeding your own pseudorandom number generators (PRNGs) to ensure
//consistent executions from run to run, where your tests contain variability (for
//example, when selecting random test data).
func GinkgoRandomSeed() int64 {
return config.GinkgoConfig.RandomSeed
}
//GinkgoParallelNode is deprecated, use GinkgoParallelProcess instead
func GinkgoParallelNode() int {
deprecationTracker.TrackDeprecation(types.Deprecations.ParallelNode(), codelocation.New(1))
return GinkgoParallelProcess()
}
//GinkgoParallelProcess returns the parallel process number for the current ginkgo process
//The process number is 1-indexed
func GinkgoParallelProcess() int {
return config.GinkgoConfig.ParallelNode
}
//Some matcher libraries or legacy codebases require a *testing.T
//GinkgoT implements an interface analogous to *testing.T and can be used if
//the library in question accepts *testing.T through an interface
//
// For example, with testify:
// assert.Equal(GinkgoT(), 123, 123, "they should be equal")
//
// Or with gomock:
// gomock.NewController(GinkgoT())
//
// GinkgoT() takes an optional offset argument that can be used to get the
// correct line number associated with the failure.
func GinkgoT(optionalOffset ...int) GinkgoTInterface {
offset := 3
if len(optionalOffset) > 0 {
offset = optionalOffset[0]
}
failedFunc := func() bool {
return CurrentGinkgoTestDescription().Failed
}
nameFunc := func() string {
return CurrentGinkgoTestDescription().FullTestText
}
return testingtproxy.New(GinkgoWriter, Fail, Skip, failedFunc, nameFunc, offset)
}
//The interface returned by GinkgoT(). This covers most of the methods
//in the testing package's T.
type GinkgoTInterface interface {
Cleanup(func())
Setenv(key, value string)
Error(args ...interface{})
Errorf(format string, args ...interface{})
Fail()
FailNow()
Failed() bool
Fatal(args ...interface{})
Fatalf(format string, args ...interface{})
Helper()
Log(args ...interface{})
Logf(format string, args ...interface{})
Name() string
Parallel()
Skip(args ...interface{})
SkipNow()
Skipf(format string, args ...interface{})
Skipped() bool
TempDir() string
}
//Custom Ginkgo test reporters must implement the Reporter interface.
//
//The custom reporter is passed in a SuiteSummary when the suite begins and ends,
//and a SpecSummary just before a spec begins and just after a spec ends
type Reporter reporters.Reporter
//Asynchronous specs are given a channel of the Done type. You must close or write to the channel
//to tell Ginkgo that your async test is done.
type Done chan<- interface{}
//GinkgoTestDescription represents the information about the current running test returned by CurrentGinkgoTestDescription
// FullTestText: a concatenation of ComponentTexts and the TestText
// ComponentTexts: a list of all texts for the Describes & Contexts leading up to the current test
// TestText: the text in the actual It or Measure node
// IsMeasurement: true if the current test is a measurement
// FileName: the name of the file containing the current test
// LineNumber: the line number for the current test
// Failed: if the current test has failed, this will be true (useful in an AfterEach)
type GinkgoTestDescription struct {
FullTestText string
ComponentTexts []string
TestText string
IsMeasurement bool
FileName string
LineNumber int
Failed bool
Duration time.Duration
}
//CurrentGinkgoTestDescripton returns information about the current running test.
func CurrentGinkgoTestDescription() GinkgoTestDescription {
summary, ok := global.Suite.CurrentRunningSpecSummary()
if !ok {
return GinkgoTestDescription{}
}
subjectCodeLocation := summary.ComponentCodeLocations[len(summary.ComponentCodeLocations)-1]
return GinkgoTestDescription{
ComponentTexts: summary.ComponentTexts[1:],
FullTestText: strings.Join(summary.ComponentTexts[1:], " "),
TestText: summary.ComponentTexts[len(summary.ComponentTexts)-1],
IsMeasurement: summary.IsMeasurement,
FileName: subjectCodeLocation.FileName,
LineNumber: subjectCodeLocation.LineNumber,
Failed: summary.HasFailureState(),
Duration: summary.RunTime,
}
}
//Measurement tests receive a Benchmarker.
//
//You use the Time() function to time how long the passed in body function takes to run
//You use the RecordValue() function to track arbitrary numerical measurements.
//The RecordValueWithPrecision() function can be used alternatively to provide the unit
//and resolution of the numeric measurement.
//The optional info argument is passed to the test reporter and can be used to
// provide the measurement data to a custom reporter with context.
//
//See http://onsi.github.io/ginkgo/#benchmark_tests for more details
type Benchmarker interface {
Time(name string, body func(), info ...interface{}) (elapsedTime time.Duration)
RecordValue(name string, value float64, info ...interface{})
RecordValueWithPrecision(name string, value float64, units string, precision int, info ...interface{})
}
//RunSpecs is the entry point for the Ginkgo test runner.
//You must call this within a Golang testing TestX(t *testing.T) function.
//
//To bootstrap a test suite you can use the Ginkgo CLI:
//
// ginkgo bootstrap
func RunSpecs(t GinkgoTestingT, description string) bool {
specReporters := []Reporter{buildDefaultReporter()}
if config.DefaultReporterConfig.ReportFile != "" {
reportFile := config.DefaultReporterConfig.ReportFile
specReporters[0] = reporters.NewJUnitReporter(reportFile)
specReporters = append(specReporters, buildDefaultReporter())
}
return runSpecsWithCustomReporters(t, description, specReporters)
}
//To run your tests with Ginkgo's default reporter and your custom reporter(s), replace
//RunSpecs() with this method.
func RunSpecsWithDefaultAndCustomReporters(t GinkgoTestingT, description string, specReporters []Reporter) bool {
deprecationTracker.TrackDeprecation(types.Deprecations.CustomReporter())
specReporters = append(specReporters, buildDefaultReporter())
return runSpecsWithCustomReporters(t, description, specReporters)
}
//To run your tests with your custom reporter(s) (and *not* Ginkgo's default reporter), replace
//RunSpecs() with this method. Note that parallel tests will not work correctly without the default reporter
func RunSpecsWithCustomReporters(t GinkgoTestingT, description string, specReporters []Reporter) bool {
deprecationTracker.TrackDeprecation(types.Deprecations.CustomReporter())
return runSpecsWithCustomReporters(t, description, specReporters)
}
func runSpecsWithCustomReporters(t GinkgoTestingT, description string, specReporters []Reporter) bool {
writer := GinkgoWriter.(*writer.Writer)
writer.SetStream(config.DefaultReporterConfig.Verbose)
reporters := make([]reporters.Reporter, len(specReporters))
for i, reporter := range specReporters {
reporters[i] = reporter
}
passed, hasFocusedTests := global.Suite.Run(t, description, reporters, writer, config.GinkgoConfig)
if deprecationTracker.DidTrackDeprecations() {
fmt.Fprintln(colorable.NewColorableStderr(), deprecationTracker.DeprecationsReport())
}
if passed && hasFocusedTests && strings.TrimSpace(os.Getenv("GINKGO_EDITOR_INTEGRATION")) == "" {
fmt.Println("PASS | FOCUSED")
os.Exit(types.GINKGO_FOCUS_EXIT_CODE)
}
return passed
}
func buildDefaultReporter() Reporter {
remoteReportingServer := config.GinkgoConfig.StreamHost
if remoteReportingServer == "" {
stenographer := stenographer.New(!config.DefaultReporterConfig.NoColor, config.GinkgoConfig.FlakeAttempts > 1, colorable.NewColorableStdout())
return reporters.NewDefaultReporter(config.DefaultReporterConfig, stenographer)
} else {
debugFile := ""
if config.GinkgoConfig.DebugParallel {
debugFile = fmt.Sprintf("ginkgo-node-%d.log", config.GinkgoConfig.ParallelNode)
}
return remote.NewForwardingReporter(config.DefaultReporterConfig, remoteReportingServer, &http.Client{}, remote.NewOutputInterceptor(), GinkgoWriter.(*writer.Writer), debugFile)
}
}
//Skip notifies Ginkgo that the current spec was skipped.
func Skip(message string, callerSkip ...int) {
skip := 0
if len(callerSkip) > 0 {
skip = callerSkip[0]
}
global.Failer.Skip(message, codelocation.New(skip+1))
panic(GINKGO_PANIC)
}
//Fail notifies Ginkgo that the current spec has failed. (Gomega will call Fail for you automatically when an assertion fails.)
func Fail(message string, callerSkip ...int) {
skip := 0
if len(callerSkip) > 0 {
skip = callerSkip[0]
}
global.Failer.Fail(message, codelocation.New(skip+1))
panic(GINKGO_PANIC)
}
//GinkgoRecover should be deferred at the top of any spawned goroutine that (may) call `Fail`
//Since Gomega assertions call fail, you should throw a `defer GinkgoRecover()` at the top of any goroutine that
//calls out to Gomega
//
//Here's why: Ginkgo's `Fail` method records the failure and then panics to prevent
//further assertions from running. This panic must be recovered. Ginkgo does this for you
//if the panic originates in a Ginkgo node (an It, BeforeEach, etc...)
//
//Unfortunately, if a panic originates on a goroutine *launched* from one of these nodes there's no
//way for Ginkgo to rescue the panic. To do this, you must remember to `defer GinkgoRecover()` at the top of such a goroutine.
func GinkgoRecover() {
e := recover()
if e != nil {
global.Failer.Panic(codelocation.New(1), e)
}
}
//Describe blocks allow you to organize your specs. A Describe block can contain any number of
//BeforeEach, AfterEach, JustBeforeEach, It, and Measurement blocks.
//
//In addition you can nest Describe, Context and When blocks. Describe, Context and When blocks are functionally
//equivalent. The difference is purely semantic -- you typically Describe the behavior of an object
//or method and, within that Describe, outline a number of Contexts and Whens.
func Describe(text string, body func()) bool {
global.Suite.PushContainerNode(text, body, types.FlagTypeNone, codelocation.New(1))
return true
}
//You can focus the tests within a describe block using FDescribe
func FDescribe(text string, body func()) bool {
global.Suite.PushContainerNode(text, body, types.FlagTypeFocused, codelocation.New(1))
return true
}
//You can mark the tests within a describe block as pending using PDescribe
func PDescribe(text string, body func()) bool {
global.Suite.PushContainerNode(text, body, types.FlagTypePending, codelocation.New(1))
return true
}
//You can mark the tests within a describe block as pending using XDescribe
func XDescribe(text string, body func()) bool {
global.Suite.PushContainerNode(text, body, types.FlagTypePending, codelocation.New(1))
return true
}
//Context blocks allow you to organize your specs. A Context block can contain any number of
//BeforeEach, AfterEach, JustBeforeEach, It, and Measurement blocks.
//
//In addition you can nest Describe, Context and When blocks. Describe, Context and When blocks are functionally
//equivalent. The difference is purely semantic -- you typical Describe the behavior of an object
//or method and, within that Describe, outline a number of Contexts and Whens.
func Context(text string, body func()) bool {
global.Suite.PushContainerNode(text, body, types.FlagTypeNone, codelocation.New(1))
return true
}
//You can focus the tests within a describe block using FContext
func FContext(text string, body func()) bool {
global.Suite.PushContainerNode(text, body, types.FlagTypeFocused, codelocation.New(1))
return true
}
//You can mark the tests within a describe block as pending using PContext
func PContext(text string, body func()) bool {
global.Suite.PushContainerNode(text, body, types.FlagTypePending, codelocation.New(1))
return true
}
//You can mark the tests within a describe block as pending using XContext
func XContext(text string, body func()) bool {
global.Suite.PushContainerNode(text, body, types.FlagTypePending, codelocation.New(1))
return true
}
//When blocks allow you to organize your specs. A When block can contain any number of
//BeforeEach, AfterEach, JustBeforeEach, It, and Measurement blocks.
//
//In addition you can nest Describe, Context and When blocks. Describe, Context and When blocks are functionally
//equivalent. The difference is purely semantic -- you typical Describe the behavior of an object
//or method and, within that Describe, outline a number of Contexts and Whens.
func When(text string, body func()) bool {
global.Suite.PushContainerNode("when "+text, body, types.FlagTypeNone, codelocation.New(1))
return true
}
//You can focus the tests within a describe block using FWhen
func FWhen(text string, body func()) bool {
global.Suite.PushContainerNode("when "+text, body, types.FlagTypeFocused, codelocation.New(1))
return true
}
//You can mark the tests within a describe block as pending using PWhen
func PWhen(text string, body func()) bool {
global.Suite.PushContainerNode("when "+text, body, types.FlagTypePending, codelocation.New(1))
return true
}
//You can mark the tests within a describe block as pending using XWhen
func XWhen(text string, body func()) bool {
global.Suite.PushContainerNode("when "+text, body, types.FlagTypePending, codelocation.New(1))
return true
}
//It blocks contain your test code and assertions. You cannot nest any other Ginkgo blocks
//within an It block.
//
//Ginkgo will normally run It blocks synchronously. To perform asynchronous tests, pass a
//function that accepts a Done channel. When you do this, you can also provide an optional timeout.
func It(text string, body interface{}, timeout ...float64) bool {
validateBodyFunc(body, codelocation.New(1))
global.Suite.PushItNode(text, body, types.FlagTypeNone, codelocation.New(1), parseTimeout(timeout...))
return true
}
//You can focus individual Its using FIt
func FIt(text string, body interface{}, timeout ...float64) bool {
validateBodyFunc(body, codelocation.New(1))
global.Suite.PushItNode(text, body, types.FlagTypeFocused, codelocation.New(1), parseTimeout(timeout...))
return true
}
//You can mark Its as pending using PIt
func PIt(text string, _ ...interface{}) bool {
global.Suite.PushItNode(text, func() {}, types.FlagTypePending, codelocation.New(1), 0)
return true
}
//You can mark Its as pending using XIt
func XIt(text string, _ ...interface{}) bool {
global.Suite.PushItNode(text, func() {}, types.FlagTypePending, codelocation.New(1), 0)
return true
}
//Specify blocks are aliases for It blocks and allow for more natural wording in situations
//which "It" does not fit into a natural sentence flow. All the same protocols apply for Specify blocks
//which apply to It blocks.
func Specify(text string, body interface{}, timeout ...float64) bool {
validateBodyFunc(body, codelocation.New(1))
global.Suite.PushItNode(text, body, types.FlagTypeNone, codelocation.New(1), parseTimeout(timeout...))
return true
}
//You can focus individual Specifys using FSpecify
func FSpecify(text string, body interface{}, timeout ...float64) bool {
validateBodyFunc(body, codelocation.New(1))
global.Suite.PushItNode(text, body, types.FlagTypeFocused, codelocation.New(1), parseTimeout(timeout...))
return true
}
//You can mark Specifys as pending using PSpecify
func PSpecify(text string, is ...interface{}) bool {
global.Suite.PushItNode(text, func() {}, types.FlagTypePending, codelocation.New(1), 0)
return true
}
//You can mark Specifys as pending using XSpecify
func XSpecify(text string, is ...interface{}) bool {
global.Suite.PushItNode(text, func() {}, types.FlagTypePending, codelocation.New(1), 0)
return true
}
//By allows you to better document large Its.
//
//Generally you should try to keep your Its short and to the point. This is not always possible, however,
//especially in the context of integration tests that capture a particular workflow.
//
//By allows you to document such flows. By must be called within a runnable node (It, BeforeEach, Measure, etc...)
//By will simply log the passed in text to the GinkgoWriter. If By is handed a function it will immediately run the function.
func By(text string, callbacks ...func()) {
preamble := "\x1b[1mSTEP\x1b[0m"
if config.DefaultReporterConfig.NoColor {
preamble = "STEP"
}
fmt.Fprintln(GinkgoWriter, preamble+": "+text)
if len(callbacks) == 1 {
callbacks[0]()
}
if len(callbacks) > 1 {
panic("just one callback per By, please")
}
}
//Measure blocks run the passed in body function repeatedly (determined by the samples argument)
//and accumulate metrics provided to the Benchmarker by the body function.
//
//The body function must have the signature:
// func(b Benchmarker)
func Measure(text string, body interface{}, samples int) bool {
deprecationTracker.TrackDeprecation(types.Deprecations.Measure(), codelocation.New(1))
global.Suite.PushMeasureNode(text, body, types.FlagTypeNone, codelocation.New(1), samples)
return true
}
//You can focus individual Measures using FMeasure
func FMeasure(text string, body interface{}, samples int) bool {
deprecationTracker.TrackDeprecation(types.Deprecations.Measure(), codelocation.New(1))
global.Suite.PushMeasureNode(text, body, types.FlagTypeFocused, codelocation.New(1), samples)
return true
}
//You can mark Measurements as pending using PMeasure
func PMeasure(text string, _ ...interface{}) bool {
deprecationTracker.TrackDeprecation(types.Deprecations.Measure(), codelocation.New(1))
global.Suite.PushMeasureNode(text, func(b Benchmarker) {}, types.FlagTypePending, codelocation.New(1), 0)
return true
}
//You can mark Measurements as pending using XMeasure
func XMeasure(text string, _ ...interface{}) bool {
deprecationTracker.TrackDeprecation(types.Deprecations.Measure(), codelocation.New(1))
global.Suite.PushMeasureNode(text, func(b Benchmarker) {}, types.FlagTypePending, codelocation.New(1), 0)
return true
}
//BeforeSuite blocks are run just once before any specs are run. When running in parallel, each
//parallel node process will call BeforeSuite.
//
//BeforeSuite blocks can be made asynchronous by providing a body function that accepts a Done channel
//
//You may only register *one* BeforeSuite handler per test suite. You typically do so in your bootstrap file at the top level.
func BeforeSuite(body interface{}, timeout ...float64) bool {
validateBodyFunc(body, codelocation.New(1))
global.Suite.SetBeforeSuiteNode(body, codelocation.New(1), parseTimeout(timeout...))
return true
}
//AfterSuite blocks are *always* run after all the specs regardless of whether specs have passed or failed.
//Moreover, if Ginkgo receives an interrupt signal (^C) it will attempt to run the AfterSuite before exiting.
//
//When running in parallel, each parallel node process will call AfterSuite.
//
//AfterSuite blocks can be made asynchronous by providing a body function that accepts a Done channel
//
//You may only register *one* AfterSuite handler per test suite. You typically do so in your bootstrap file at the top level.
func AfterSuite(body interface{}, timeout ...float64) bool {
validateBodyFunc(body, codelocation.New(1))
global.Suite.SetAfterSuiteNode(body, codelocation.New(1), parseTimeout(timeout...))
return true
}
//SynchronizedBeforeSuite blocks are primarily meant to solve the problem of setting up singleton external resources shared across
//nodes when running tests in parallel. For example, say you have a shared database that you can only start one instance of that
//must be used in your tests. When running in parallel, only one node should set up the database and all other nodes should wait
//until that node is done before running.
//
//SynchronizedBeforeSuite accomplishes this by taking *two* function arguments. The first is only run on parallel node #1. The second is
//run on all nodes, but *only* after the first function completes successfully. Ginkgo also makes it possible to send data from the first function (on Node 1)
//to the second function (on all the other nodes).
//
//The functions have the following signatures. The first function (which only runs on node 1) has the signature:
//
// func() []byte
//
//or, to run asynchronously:
//
// func(done Done) []byte
//
//The byte array returned by the first function is then passed to the second function, which has the signature:
//
// func(data []byte)
//
//or, to run asynchronously:
//
// func(data []byte, done Done)
//
//Here's a simple pseudo-code example that starts a shared database on Node 1 and shares the database's address with the other nodes:
//
// var dbClient db.Client
// var dbRunner db.Runner
//
// var _ = SynchronizedBeforeSuite(func() []byte {
// dbRunner = db.NewRunner()
// err := dbRunner.Start()
// Ω(err).ShouldNot(HaveOccurred())
// return []byte(dbRunner.URL)
// }, func(data []byte) {
// dbClient = db.NewClient()
// err := dbClient.Connect(string(data))
// Ω(err).ShouldNot(HaveOccurred())
// })
func SynchronizedBeforeSuite(node1Body interface{}, allNodesBody interface{}, timeout ...float64) bool {
global.Suite.SetSynchronizedBeforeSuiteNode(
node1Body,
allNodesBody,
codelocation.New(1),
parseTimeout(timeout...),
)
return true
}
//SynchronizedAfterSuite blocks complement the SynchronizedBeforeSuite blocks in solving the problem of setting up
//external singleton resources shared across nodes when running tests in parallel.
//
//SynchronizedAfterSuite accomplishes this by taking *two* function arguments. The first runs on all nodes. The second runs only on parallel node #1
//and *only* after all other nodes have finished and exited. This ensures that node 1, and any resources it is running, remain alive until
//all other nodes are finished.
//
//Both functions have the same signature: either func() or func(done Done) to run asynchronously.
//
//Here's a pseudo-code example that complements that given in SynchronizedBeforeSuite. Here, SynchronizedAfterSuite is used to tear down the shared database
//only after all nodes have finished:
//
// var _ = SynchronizedAfterSuite(func() {
// dbClient.Cleanup()
// }, func() {
// dbRunner.Stop()
// })
func SynchronizedAfterSuite(allNodesBody interface{}, node1Body interface{}, timeout ...float64) bool {
global.Suite.SetSynchronizedAfterSuiteNode(
allNodesBody,
node1Body,
codelocation.New(1),
parseTimeout(timeout...),
)
return true
}
//BeforeEach blocks are run before It blocks. When multiple BeforeEach blocks are defined in nested
//Describe and Context blocks the outermost BeforeEach blocks are run first.
//
//Like It blocks, BeforeEach blocks can be made asynchronous by providing a body function that accepts
//a Done channel
func BeforeEach(body interface{}, timeout ...float64) bool {
validateBodyFunc(body, codelocation.New(1))
global.Suite.PushBeforeEachNode(body, codelocation.New(1), parseTimeout(timeout...))
return true
}
//JustBeforeEach blocks are run before It blocks but *after* all BeforeEach blocks. For more details,
//read the [documentation](http://onsi.github.io/ginkgo/#separating_creation_and_configuration_)
//
//Like It blocks, BeforeEach blocks can be made asynchronous by providing a body function that accepts
//a Done channel
func JustBeforeEach(body interface{}, timeout ...float64) bool {
validateBodyFunc(body, codelocation.New(1))
global.Suite.PushJustBeforeEachNode(body, codelocation.New(1), parseTimeout(timeout...))
return true
}
//JustAfterEach blocks are run after It blocks but *before* all AfterEach blocks. For more details,
//read the [documentation](http://onsi.github.io/ginkgo/#separating_creation_and_configuration_)
//
//Like It blocks, JustAfterEach blocks can be made asynchronous by providing a body function that accepts
//a Done channel
func JustAfterEach(body interface{}, timeout ...float64) bool {
validateBodyFunc(body, codelocation.New(1))
global.Suite.PushJustAfterEachNode(body, codelocation.New(1), parseTimeout(timeout...))
return true
}
//AfterEach blocks are run after It blocks. When multiple AfterEach blocks are defined in nested
//Describe and Context blocks the innermost AfterEach blocks are run first.
//
//Like It blocks, AfterEach blocks can be made asynchronous by providing a body function that accepts
//a Done channel
func AfterEach(body interface{}, timeout ...float64) bool {
validateBodyFunc(body, codelocation.New(1))
global.Suite.PushAfterEachNode(body, codelocation.New(1), parseTimeout(timeout...))
return true
}
func validateBodyFunc(body interface{}, cl types.CodeLocation) {
t := reflect.TypeOf(body)
if t.Kind() != reflect.Func {
return
}
if t.NumOut() > 0 {
return
}
if t.NumIn() == 0 {
return
}
if t.In(0) == reflect.TypeOf(make(Done)) {
deprecationTracker.TrackDeprecation(types.Deprecations.Async(), cl)
}
}
func parseTimeout(timeout ...float64) time.Duration {
if len(timeout) == 0 {
return global.DefaultTimeout
} else {
return time.Duration(timeout[0] * float64(time.Second))
}
}
| go | Apache-2.0 | b3b4703e958c25d54c4d48138d9e80ae32fadac3 | 2026-01-07T09:44:30.792320Z | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.