Sha256: fc5dee3be8fe6caf4b2b8ea733fd7a68cd0eabf95ae78a6d0be73e7e00499b75

Contents?: true

Size: 1.52 KB

Versions: 118

Compression:

Stored size: 1.52 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"
)

const targetTestVersion = 3

func TestStep1(t *testing.T) {

	if testVersion != targetTestVersion {
		t.Fatalf("Found testVersion = %v, want %v", testVersion, targetTestVersion)
	}
	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

118 entries across 118 versions & 1 rubygems

Version Path
trackler-2.0.8.18 tracks/go/exercises/robot-simulator/robot_simulator_test.go
trackler-2.0.8.17 tracks/go/exercises/robot-simulator/robot_simulator_test.go
trackler-2.0.8.16 tracks/go/exercises/robot-simulator/robot_simulator_test.go
trackler-2.0.8.15 tracks/go/exercises/robot-simulator/robot_simulator_test.go
trackler-2.0.8.14 tracks/go/exercises/robot-simulator/robot_simulator_test.go
trackler-2.0.8.13 tracks/go/exercises/robot-simulator/robot_simulator_test.go
trackler-2.0.8.12 tracks/go/exercises/robot-simulator/robot_simulator_test.go
trackler-2.0.8.11 tracks/go/exercises/robot-simulator/robot_simulator_test.go
trackler-2.0.8.10 tracks/go/exercises/robot-simulator/robot_simulator_test.go
trackler-2.0.8.9 tracks/go/exercises/robot-simulator/robot_simulator_test.go
trackler-2.0.8.8 tracks/go/exercises/robot-simulator/robot_simulator_test.go
trackler-2.0.8.7 tracks/go/exercises/robot-simulator/robot_simulator_test.go
trackler-2.0.8.6 tracks/go/exercises/robot-simulator/robot_simulator_test.go
trackler-2.0.8.5 tracks/go/exercises/robot-simulator/robot_simulator_test.go
trackler-2.0.8.4 tracks/go/exercises/robot-simulator/robot_simulator_test.go
trackler-2.0.8.3 tracks/go/exercises/robot-simulator/robot_simulator_test.go
trackler-2.0.8.2 tracks/go/exercises/robot-simulator/robot_simulator_test.go
trackler-2.0.8.1 tracks/go/exercises/robot-simulator/robot_simulator_test.go
trackler-2.0.7.0 tracks/go/exercises/robot-simulator/robot_simulator_test.go
trackler-2.0.6.44 tracks/go/exercises/robot-simulator/robot_simulator_test.go