<|start_filename|>exercises/raindrops/cases_test.go<|end_filename|>
package raindrops

// Source: exercism/x-common
// Commit: <PASSWORD> Merge pull request #117 from mikeyjcat/add-raindrops-json

var tests = []struct {
	input    int
	expected string
}{
	{1, "1"},
	{3, "Pling"},
	{5, "Plang"},
	{7, "Plong"},
	{6, "Pling"},
	{9, "Pling"},
	{10, "Plang"},
	{14, "Plong"},
	{15, "PlingPlang"},
	{21, "PlingPlong"},
	{25, "Plang"},
	{35, "PlangPlong"},
	{49, "Plong"},
	{52, "52"},
	{105, "PlingPlangPlong"},
}


<|start_filename|>exercises/rna-transcription/rna_transcription_test.go<|end_filename|>
package strand

import "testing"

const targetTestVersion = 3

func TestRNATranscription(t *testing.T) {
	if testVersion != targetTestVersion {
		t.Fatalf("Found testVersion = %v, want %v", testVersion, targetTestVersion)
	}
	for _, test := range rnaTests {
		if actual := ToRNA(test.input); actual != test.expected {
			t.Errorf("ToRNA(%s): %s, expected %s",
				test.input, actual, test.expected)
		}
	}
}

func BenchmarkRNATranscription(b *testing.B) {
	for i := 0; i < b.N; i++ {
		for _, test := range rnaTests {
			ToRNA(test.input)
		}
	}
}


<|start_filename|>exercises/palindrome-products/palindrome_products_test.go<|end_filename|>
package palindrome

import (
	"fmt"
	"reflect"
	"strings"
	"testing"
)

// API to impliment:
// type Product struct {
// 	Product int // palindromic, of course
// 	// list of all possible two-factor factorizations of Product, within
// 	// given limits, in order
// 	Factorizations [][2]int
// }
// func Products(fmin, fmax int) (pmin, pmax Product, error)

var testData = []struct {
	// input to Products(): range limits for factors of the palindrome
	fmin, fmax int
	// output from Products():
	pmin, pmax Product // min and max palandromic products
	errPrefix  string  // start of text if there is an error, "" otherwise
}{
	{1, 9,
		Product{}, // zero value means don't bother to test it
		Product{9, [][2]int{{1, 9}, {3, 3}}},
		""},
	{10, 99,
		Product{121, [][2]int{{11, 11}}},
		Product{9009, [][2]int{{91, 99}}},
		""},
	{100, 999,
		Product{10201, [][2]int{{101, 101}}},
		Product{906609, [][2]int{{913, 993}}},
		""},
	{4, 10, Product{}, Product{}, "No palindromes"},
	{10, 4, Product{}, Product{}, "fmin > fmax"},
	/* bonus curiosities.  (can a negative number be a palindrome?
	// most say no
	{-99, -10, Product{}, Product{}, "Negative limits"},
	// but you can still get non-negative products from negative factors.
	{-99, -10,
		Product{121, [][2]int{{-11, -11}}},
		Product{9009, [][2]int{{-99, -91}}},
		""},
	{-2, 2,
		Product{0, [][2]int{{-2, 0}, {-1, 0}, {0, 0}, {0, 1}, {0, 2}}},
		Product{4, [][2]int{{-2, -2}, {2, 2}}},
		""},
	// or you could reverse the *digits*, keeping the minus sign in place.
	{-2, 2,
		Product{-4, [][2]int{{-2, 2}}},
		Product{4, [][2]int{{-2, -2}, {2, 2}}},
		""},
	{
	{0, (^uint(0))>>1, Product{}, Product{}, "This one's gonna overflow"},
	*/
}

func TestPalindromeProducts(t *testing.T) {
	for _, test := range testData {
		// common preamble for test failures
		ret := fmt.Sprintf("Products(%d, %d) returned",
			test.fmin, test.fmax)
		// test
		pmin, pmax, err := Products(test.fmin, test.fmax)
		switch {
		case err == nil:
			if test.errPrefix > "" {
				t.Fatalf(ret+" err = nil, want %q", test.errPrefix+"...")
			}
		case test.errPrefix == "":
			t.Fatalf(ret+" err = %q, want nil", err)
		case !strings.HasPrefix(err.Error(), test.errPrefix):
			t.Fatalf(ret+" err = %q, want %q", err, test.errPrefix+"...")
		default:
			continue // correct error, no further tests for this test case
		}
		matchProd := func(ww string, rp, wp Product) {
			if len(wp.Factorizations) > 0 && // option to skip test
				!reflect.DeepEqual(rp, wp) {
				t.Fatal(ret, ww, "=", rp, "want", wp)
			}
		}
		matchProd("pmin", pmin, test.pmin)
		matchProd("pmax", pmax, test.pmax)
	}
}

func BenchmarkPalindromeProducts(b *testing.B) {
	for i := 0; i < b.N; i++ {
		for _, test := range testData {
			Products(test.fmin, test.fmax)
		}
	}
}


<|start_filename|>exercises/anagram/anagram_test.go<|end_filename|>
package anagram

import (
	"fmt"
	"sort"
	"testing"
)

var testCases = []struct {
	subject     string
	candidates  []string
	expected    []string
	description string
}{
	{
		subject: "diaper",
		candidates: []string{
			"hello",
			"world",
			"zombies",
			"pants",
		},
		expected:    []string{},
		description: "no matches",
	},
	{
		subject: "ant",
		candidates: []string{
			"tan",
			"stand",
			"at",
		},
		expected:    []string{"tan"},
		description: "simple anagram",
	},
	{
		subject: "listen",
		candidates: []string{
			"enlists",
			"google",
			"inlets",
			"banana",
		},
		expected:    []string{"inlets"},
		description: "another simple anagram",
	},
	{
		subject: "master",
		candidates: []string{
			"stream",
			"pigeon",
			"maters",
		},
		expected:    []string{"maters", "stream"},
		description: "multiple anagrams",
	},
	{
		subject: "allergy",
		candidates: []string{
			"gallery",
			"ballerina",
			"regally",
			"clergy",
			"largely",
			"leading",
		},
		expected:    []string{"gallery", "largely", "regally"},
		description: "multiple anagrams (again)",
	},
	{
		subject: "galea",
		candidates: []string{
			"eagle",
		},
		expected:    []string{},
		description: "does not confuse different duplicates",
	},
	{
		subject: "corn",
		candidates: []string{
			"corn",
			"dark",
			"Corn",
			"rank",
			"CORN",
			"cron",
			"park",
		},
		expected:    []string{"cron"},
		description: "identical word is not anagram",
	},
	{
		subject: "mass",
		candidates: []string{
			"last",
		},
		expected:    []string{},
		description: "eliminate anagrams with same checksum",
	},
	{
		subject: "good",
		candidates: []string{
			"dog",
			"goody",
		},
		expected:    []string{},
		description: "eliminate anagram subsets",
	},
	{
		subject: "Orchestra",
		candidates: []string{
			"cashregiser",
			"carthorse",
			"radishes",
		},
		expected:    []string{"carthorse"},
		description: "subjects are case insensitive",
	},
	{
		subject: "orchestra",
		candidates: []string{
			"cashregiser",
			"Carthorse",
			"radishes",
		},
		expected:    []string{"carthorse"},
		description: "candidates are case insensitive",
	},
}

func equal(a []string, b []string) bool {
	if len(b) != len(a) {
		return false
	}

	sort.Strings(a)
	sort.Strings(b)
	return fmt.Sprintf("%v", a) == fmt.Sprintf("%v", b)
}

func TestDetectAnagrams(t *testing.T) {
	for _, tt := range testCases {
		actual := Detect(tt.subject, tt.candidates)
		if !equal(tt.expected, actual) {
			msg := `FAIL: %s
	Subject %s
	Candidates %v
	Expected %v
	Got %v
				`
			t.Fatalf(msg, tt.description, tt.subject, tt.candidates, tt.expected, actual)
		} else {
			t.Logf("PASS: %s", tt.description)
		}
	}
}

func BenchmarkDetectAnagrams(b *testing.B) {

	b.StopTimer()

	for _, tt := range testCases {
		b.StartTimer()

		for i := 0; i < b.N; i++ {
			Detect(tt.subject, tt.candidates)
		}

		b.StopTimer()
	}

}


<|start_filename|>exercises/rna-transcription/cases_test.go<|end_filename|>
package strand

// Source: exercism/x-common
// Commit: <PASSWORD>4 Merge pull request #121 from mikeyjcat/add-roman-numerals-test-definition

var rnaTests = []struct {
	input    string
	expected string
}{
	// rna complement of cytosine is guanine
	{"C", "G"},

	// rna complement of guanine is cytosine
	{"G", "C"},

	// rna complement of thymine is adenine
	{"T", "A"},

	// rna complement of adenine is uracil
	{"A", "U"},

	// rna complement
	{"ACGTGGTCTTAA", "UGCACCAGAAUU"},
}
