package world import ( "testing" "github.com/stretchr/testify/require" ) // requireDrawerCommandNames asserts the exact command sequence recorded // by fakePrimitiveDrawer. func requireDrawerCommandNames(t *testing.T, d *fakePrimitiveDrawer, want ...string) { t.Helper() require.Equal(t, want, d.CommandNames()) } // requireDrawerCommandCount asserts the number of recorded commands. func requireDrawerCommandCount(t *testing.T, d *fakePrimitiveDrawer, want int) { t.Helper() require.Len(t, d.Commands(), want) } // requireDrawerCommandAt returns the command at the specified index. func requireDrawerCommandAt(t *testing.T, d *fakePrimitiveDrawer, index int) fakeDrawerCommand { t.Helper() cmds := d.Commands() require.GreaterOrEqual(t, index, 0) require.Less(t, index, len(cmds)) return cmds[index] } // requireDrawerSingleCommand returns the only command with the given name. func requireDrawerSingleCommand(t *testing.T, d *fakePrimitiveDrawer, name string) fakeDrawerCommand { t.Helper() cmds := d.CommandsByName(name) require.Len(t, cmds, 1) return cmds[0] } // requireCommandName asserts the command name. func requireCommandName(t *testing.T, cmd fakeDrawerCommand, want string) { t.Helper() require.Equal(t, want, cmd.Name) } // requireCommandArgs asserts the exact float arguments. func requireCommandArgs(t *testing.T, cmd fakeDrawerCommand, want ...float64) { t.Helper() require.Equal(t, want, cmd.Args) } // requireCommandArgsInDelta asserts the float arguments with tolerance. func requireCommandArgsInDelta(t *testing.T, cmd fakeDrawerCommand, delta float64, want ...float64) { t.Helper() require.Len(t, cmd.Args, len(want)) for i := range want { require.InDelta(t, want[i], cmd.Args[i], delta, "arg index %d", i) } } // requireCommandClipRects asserts the clip stack snapshot attached to the command. func requireCommandClipRects(t *testing.T, cmd fakeDrawerCommand, want ...fakeClipRect) { t.Helper() require.Equal(t, want, cmd.Clips) } // requireCommandLineWidth asserts the line width snapshot attached to the command. func requireCommandLineWidth(t *testing.T, cmd fakeDrawerCommand, want float64) { t.Helper() require.Equal(t, want, cmd.LineWidth) } // requireCommandDashes asserts the dash snapshot attached to the command. func requireCommandDashes(t *testing.T, cmd fakeDrawerCommand, want ...float64) { t.Helper() require.Equal(t, want, cmd.Dashes) } // requireCommandDashOffset asserts the dash offset snapshot attached to the command. func requireCommandDashOffset(t *testing.T, cmd fakeDrawerCommand, want float64) { t.Helper() require.Equal(t, want, cmd.DashOffset) }