Skip to content

Instantly share code, notes, and snippets.

View metarsit's full-sized avatar
✳️
Consumer Crypto

Part Thai metarsit

✳️
Consumer Crypto
View GitHub Profile
package main
import (
"arena"
)
func main() {
mem := arena.NewArena()
i := arena.New[int](mem)
package main
import (
"arena"
)
func main() {
mem := arena.NewArena()
defer mem.Free() // Free the arena memory after out of scope
package main
import (
"arena"
"fmt"
)
type T struct {
S string
}
package article
import "testing"
func TestEqual(t *testing.T) {
tests := []struct {
a, b any
}{
{1, 1},
{false, true},
var tcs = GenerateTestCasesForEqual(100000)
func TestEqualA(t *testing.T) {
for i, tc := range tcs {
t.Run(fmt.Sprintf("Test Case %d", i+1), func(t *testing.T) {
result := Equal(tc.a, tc.b)
if result != tc.expect {
t.Fatalf("test case number %d failed", i)
}
})
type TestCase struct {
a, b any
expect bool
}
// GenerateTestCasesForEqual takes in a number of test cases to generate
// and create an True cases for Equal function
func GenerateTestCasesForEqual(numberOfTestCases int) []TestCase {
tcs := make([]TestCase, numberOfTestCases)
func TestEqualSingleTestCase(t *testing.T) {
t.Run("Single Test Case", func(t *testing.T) {
result := Equal(1, 1)
if result != true {
t.Fatalf("test failed: wanted %v got %v", true, result)
}
})
}
@metarsit
metarsit / equal.go
Last active December 25, 2022 04:22
package article
import (
"reflect"
)
func Equal(a, b any) bool {
return reflect.DeepEqual(a, b)
}
package medium
import (
"testing"
"github.com/metarsit/sshtest"
"gotest.tools/v3/assert"
)
func TestRunCmdOverSSH(t *testing.T) {
package sshtest
import (
"io"
"github.com/gliderlabs/ssh"
)
// HoneyPot encapsulates the initialized struct
type HoneyPot struct {