This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"arena" | |
) | |
func main() { | |
mem := arena.NewArena() | |
i := arena.New[int](mem) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"arena" | |
) | |
func main() { | |
mem := arena.NewArena() | |
defer mem.Free() // Free the arena memory after out of scope |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"arena" | |
"fmt" | |
) | |
type T struct { | |
S string | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package article | |
import "testing" | |
func TestEqual(t *testing.T) { | |
tests := []struct { | |
a, b any | |
}{ | |
{1, 1}, | |
{false, true}, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | |
} | |
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | |
} | |
}) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package article | |
import ( | |
"reflect" | |
) | |
func Equal(a, b any) bool { | |
return reflect.DeepEqual(a, b) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package medium | |
import ( | |
"testing" | |
"github.com/metarsit/sshtest" | |
"gotest.tools/v3/assert" | |
) | |
func TestRunCmdOverSSH(t *testing.T) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package sshtest | |
import ( | |
"io" | |
"github.com/gliderlabs/ssh" | |
) | |
// HoneyPot encapsulates the initialized struct | |
type HoneyPot struct { |
NewerOlder