Sha256: 998f979448c58644dadd154711ccb505c7b581fa72d0ee26d23a0616eea5dc96

Contents?: true

Size: 1.1 KB

Versions: 133

Compression:

Stored size: 1.1 KB

Contents

package change

import (
	"reflect"
	"testing"
)

const targetTestVersion = 1

func TestTestVersion(t *testing.T) {
	if testVersion != targetTestVersion {
		t.Fatalf("Found testVersion = %v, want %v", testVersion, targetTestVersion)
	}
}

func TestChange(t *testing.T) {
	for _, tc := range testCases {
		actual, err := Change(tc.coins, tc.target)
		if tc.valid {
			if err != nil {
				t.Fatalf("%s : Change(%v, %d): expected %v, got error %s",
					tc.description, tc.coins, tc.target, tc.expectedChange, err.Error())
			} else {
				if !reflect.DeepEqual(actual, tc.expectedChange) {
					t.Fatalf("%s : Change(%v, %d): expected %v, actual %v",
						tc.description, tc.coins, tc.target, tc.expectedChange, actual)
				} else {
					t.Logf("PASS: %s", tc.description)
				}
			}
		} else {
			if err == nil {
				t.Fatalf("%s : Change(%v, %d): expected error, got %v",
					tc.description, tc.coins, tc.target, actual)
			} else {
				t.Logf("PASS: %s", tc.description)
			}
		}
	}
}

func BenchmarkChange(b *testing.B) {
	for _, tc := range testCases {
		for i := 0; i < b.N; i++ {
			Change(tc.coins, tc.target)
		}
	}
}

Version data entries

133 entries across 133 versions & 1 rubygems

Version Path
trackler-2.1.0.39 tracks/go/exercises/change/change_test.go
trackler-2.1.0.38 tracks/go/exercises/change/change_test.go
trackler-2.1.0.37 tracks/go/exercises/change/change_test.go
trackler-2.1.0.36 tracks/go/exercises/change/change_test.go
trackler-2.1.0.34 tracks/go/exercises/change/change_test.go
trackler-2.1.0.33 tracks/go/exercises/change/change_test.go
trackler-2.1.0.32 tracks/go/exercises/change/change_test.go
trackler-2.1.0.31 tracks/go/exercises/change/change_test.go
trackler-2.1.0.30 tracks/go/exercises/change/change_test.go
trackler-2.1.0.29 tracks/go/exercises/change/change_test.go
trackler-2.1.0.28 tracks/go/exercises/change/change_test.go
trackler-2.1.0.27 tracks/go/exercises/change/change_test.go
trackler-2.1.0.26 tracks/go/exercises/change/change_test.go
trackler-2.1.0.25 tracks/go/exercises/change/change_test.go
trackler-2.1.0.24 tracks/go/exercises/change/change_test.go
trackler-2.1.0.23 tracks/go/exercises/change/change_test.go
trackler-2.1.0.22 tracks/go/exercises/change/change_test.go
trackler-2.1.0.21 tracks/go/exercises/change/change_test.go
trackler-2.1.0.20 tracks/go/exercises/change/change_test.go
trackler-2.1.0.19 tracks/go/exercises/change/change_test.go