MCPcopy Create free account
hub / github.com/dlclark/regexp2 / TestRunnerFixedStackPushHelpers

Function TestRunnerFixedStackPushHelpers

runner_codegen_test.go:5–27  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

3import "testing"
4
5func TestRunnerFixedStackPushHelpers(t *testing.T) {
6 r := &Runner{
7 runstack: make([]int, 8),
8 Runstackpos: 8,
9 runtrackcount: 1,
10 }
11
12 r.StackPush4(1, 2, 3, 4)
13 if got := r.StackDepth(); got != 4 {
14 t.Fatalf("StackDepth after StackPush4 = %d, want 4", got)
15 }
16 if got := popN(r, 4); !equalInts(got, []int{4, 3, 2, 1}) {
17 t.Fatalf("StackPush4 pop order = %v", got)
18 }
19
20 r.StackPush5(1, 2, 3, 4, 5)
21 if got := r.StackDepth(); got != 5 {
22 t.Fatalf("StackDepth after StackPush5 = %d, want 5", got)
23 }
24 if got := popN(r, 5); !equalInts(got, []int{5, 4, 3, 2, 1}) {
25 t.Fatalf("StackPush5 pop order = %v", got)
26 }
27}
28
29func popN(r *Runner, n int) []int {
30 vals := make([]int, 0, n)

Callers

nothing calls this directly

Calls 5

StackPush4Method · 0.95
StackDepthMethod · 0.95
StackPush5Method · 0.95
popNFunction · 0.85
equalIntsFunction · 0.85

Tested by

no test coverage detected