Sha256: 696d9d7e40a93eb3e29833a3ab3e256501fc3195804cad785f52893a08306260

Contents?: true

Size: 1.31 KB

Versions: 153

Compression:

Stored size: 1.31 KB

Contents

package say

// The steps are interesting, but all that matters is the final exam.

import (
	"math"
	"testing"
)

const targetTestVersion = 1

var tests = []struct {
	uint64
	string
}{
	{1, "one"},
	{14, "fourteen"},
	{20, "twenty"},
	{22, "twenty-two"},
	{100, "one hundred"},
	{120, "one hundred twenty"},
	{123, "one hundred twenty-three"},
	{1000, "one thousand"},
	{1234, "one thousand two hundred thirty-four"},
	{1000000, "one million"},
	{1000002, "one million two"},
	{1002345, "one million two thousand three hundred forty-five"},
	{1e9, "one billion"},
	{987654321123, "nine hundred eighty-seven billion " +
		"six hundred fifty-four million " +
		"three hundred twenty-one thousand " +
		"one hundred twenty-three"},
	{0, "zero"},
	{math.MaxUint64, "eighteen quintillion " +
		"four hundred forty-six quadrillion " +
		"seven hundred forty-four trillion " +
		"seventy-three billion " +
		"seven hundred nine million " +
		"five hundred fifty-one thousand " +
		"six hundred fifteen"},
}

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

func TestSay(t *testing.T) {
	for _, test := range tests {
		if s := Say(test.uint64); s != test.string {
			t.Errorf("Say(%d) = %q.  Want %q.", test.uint64, s, test.string)
		}
	}
}

Version data entries

153 entries across 153 versions & 1 rubygems

Version Path
trackler-2.2.1.56 tracks/go/exercises/say/say_test.go
trackler-2.2.1.55 tracks/go/exercises/say/say_test.go
trackler-2.2.1.54 tracks/go/exercises/say/say_test.go
trackler-2.2.1.53 tracks/go/exercises/say/say_test.go
trackler-2.2.1.52 tracks/go/exercises/say/say_test.go
trackler-2.2.1.51 tracks/go/exercises/say/say_test.go
trackler-2.2.1.50 tracks/go/exercises/say/say_test.go
trackler-2.2.1.49 tracks/go/exercises/say/say_test.go
trackler-2.2.1.48 tracks/go/exercises/say/say_test.go
trackler-2.2.1.47 tracks/go/exercises/say/say_test.go
trackler-2.2.1.46 tracks/go/exercises/say/say_test.go
trackler-2.2.1.45 tracks/go/exercises/say/say_test.go
trackler-2.2.1.44 tracks/go/exercises/say/say_test.go
trackler-2.2.1.43 tracks/go/exercises/say/say_test.go
trackler-2.2.1.42 tracks/go/exercises/say/say_test.go
trackler-2.2.1.41 tracks/go/exercises/say/say_test.go
trackler-2.2.1.40 tracks/go/exercises/say/say_test.go
trackler-2.2.1.39 tracks/go/exercises/say/say_test.go
trackler-2.2.1.38 tracks/go/exercises/say/say_test.go
trackler-2.2.1.37 tracks/go/exercises/say/say_test.go