Sha256: da4c533ef3a06a86c06b1d8fa8d5c87f3c0002028262f2bda4accdd4a877c585

Contents?: true

Size: 1.37 KB

Versions: 122

Compression:

Stored size: 1.37 KB

Contents

// +build step1 !step2,!step3

package robot

// Tests are separated into 3 steps.
//
// Run all tests with `go test` or run specific tests with the -tags option.
// Examples,
//
//    go test                      # run all tests
//    go test -tags step1          # run just step 1 tests.
//    go test -tags 'step1 step2'  # run step1 and step2 tests
//
// This source file contains step 1 tests only.  For other tests see
// robot_simulator_step2_test.go and robot_simulator_step3_test.go.
//
// You are given the source file defs.go which defines a number of things
// the test program requires.  It is organized into three sections by step.
//
// To complete step 1 you will define Right, Left, Advance, N, S, E, W,
// and Dir.String.  Complete step 1 before moving on to step 2.

import (
	"runtime"
	"testing"
)

func TestStep1(t *testing.T) {

	want := func(x, y int, dir Dir) {
		_, _, line, _ := runtime.Caller(1)
		if Step1Robot.X != x || Step1Robot.Y != y {
			t.Fatalf("(from line %d) robot at = %d, %d.  Want %d, %d.",
				line, Step1Robot.X, Step1Robot.Y, x, y)
		}
		if Step1Robot.Dir != dir {
			t.Fatalf("(from line %d) robot facing %v, want %v.",
				line, Step1Robot.Dir, dir)
		}
	}
	want(0, 0, N)

	Advance()
	want(0, 1, N)

	Right()
	want(0, 1, E)

	Advance()
	want(1, 1, E)

	Left()
	want(1, 1, N)

	Left()
	Left()
	Advance()
	want(1, 0, S)

	Right()
	Advance()
	want(0, 0, W)
}

Version data entries

122 entries across 122 versions & 1 rubygems

Version Path
trackler-2.2.1.180 tracks/go/exercises/robot-simulator/robot_simulator_test.go
trackler-2.2.1.179 tracks/go/exercises/robot-simulator/robot_simulator_test.go
trackler-2.2.1.178 tracks/go/exercises/robot-simulator/robot_simulator_test.go
trackler-2.2.1.177 tracks/go/exercises/robot-simulator/robot_simulator_test.go
trackler-2.2.1.176 tracks/go/exercises/robot-simulator/robot_simulator_test.go
trackler-2.2.1.175 tracks/go/exercises/robot-simulator/robot_simulator_test.go
trackler-2.2.1.174 tracks/go/exercises/robot-simulator/robot_simulator_test.go
trackler-2.2.1.173 tracks/go/exercises/robot-simulator/robot_simulator_test.go
trackler-2.2.1.172 tracks/go/exercises/robot-simulator/robot_simulator_test.go
trackler-2.2.1.171 tracks/go/exercises/robot-simulator/robot_simulator_test.go
trackler-2.2.1.170 tracks/go/exercises/robot-simulator/robot_simulator_test.go
trackler-2.2.1.169 tracks/go/exercises/robot-simulator/robot_simulator_test.go
trackler-2.2.1.167 tracks/go/exercises/robot-simulator/robot_simulator_test.go
trackler-2.2.1.166 tracks/go/exercises/robot-simulator/robot_simulator_test.go
trackler-2.2.1.165 tracks/go/exercises/robot-simulator/robot_simulator_test.go
trackler-2.2.1.164 tracks/go/exercises/robot-simulator/robot_simulator_test.go
trackler-2.2.1.163 tracks/go/exercises/robot-simulator/robot_simulator_test.go
trackler-2.2.1.162 tracks/go/exercises/robot-simulator/robot_simulator_test.go
trackler-2.2.1.161 tracks/go/exercises/robot-simulator/robot_simulator_test.go
trackler-2.2.1.160 tracks/go/exercises/robot-simulator/robot_simulator_test.go