Sha256: 25d3cb218a4a41bb17fccefe72cc6be35d15795910c3b5bae9edb9a475b2fe39

Contents?: true

Size: 1.56 KB

Versions: 158

Compression:

Stored size: 1.56 KB

Contents

package protein

import (
	"reflect"
	"testing"
)

const targetTestVersion = 1

type codonCase struct {
	input    string
	expected string
}

var codonTestCases = []codonCase{
	{"AUG", "Methionine"},
	{"UUU", "Phenylalanine"},
	{"UUC", "Phenylalanine"},
	{"UUA", "Leucine"},
	{"UUG", "Leucine"},
	{"UCU", "Serine"},
	{"UCC", "Serine"},
	{"UCA", "Serine"},
	{"UCG", "Serine"},
	{"UAU", "Tyrosine"},
	{"UAC", "Tyrosine"},
	{"UGU", "Cysteine"},
	{"UGC", "Cysteine"},
	{"UGG", "Tryptophan"},
	{"UAA", "STOP"},
	{"UAG", "STOP"},
	{"UGA", "STOP"},
}

type rnaCase struct {
	input    string
	expected []string
}

var proteinTestCases = []rnaCase{
	{"AUGUUUUCUUAAAUG", []string{"Methionine", "Phenylalanine", "Serine"}},
	{"AUGUUUUGG", []string{"Methionine", "Phenylalanine", "Tryptophan"}},
	{"AUGUUUUAA", []string{"Methionine", "Phenylalanine"}},
	{"UGGUGUUAUUAAUGGUUU", []string{"Tryptophan", "Cysteine", "Tyrosine"}},
}

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

func TestCodon(t *testing.T) {
	for _, test := range codonTestCases {
		actual := FromCodon(test.input)
		if actual != test.expected {
			t.Errorf("Protein Translation test [%s], expected [%s], actual [%s]", test.input, test.expected, actual)
		}
	}
}

func TestProtein(t *testing.T) {
	for _, test := range proteinTestCases {
		actual := FromRNA(test.input)
		if !reflect.DeepEqual(actual, test.expected) {
			t.Errorf("Protein Translation test [%s], expected %q, actual %q", test.input, test.expected, actual)
		}
	}
}

Version data entries

158 entries across 158 versions & 1 rubygems

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