Sha256: ca2a2393a18f64561ab1ff1e89aaeafc305da240f4686f2b22d9be7702edfd02

Contents?: true

Size: 1.56 KB

Versions: 97

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 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)
		}
	}
}

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

Version data entries

97 entries across 97 versions & 1 rubygems

Version Path
trackler-2.0.6.40 tracks/go/exercises/protein-translation/protein_translation_test.go
trackler-2.0.6.39 tracks/go/exercises/protein-translation/protein_translation_test.go
trackler-2.0.6.38 tracks/go/exercises/protein-translation/protein_translation_test.go
trackler-2.0.6.37 tracks/go/exercises/protein-translation/protein_translation_test.go
trackler-2.0.6.36 tracks/go/exercises/protein-translation/protein_translation_test.go
trackler-2.0.6.35 tracks/go/exercises/protein-translation/protein_translation_test.go
trackler-2.0.6.34 tracks/go/exercises/protein-translation/protein_translation_test.go
trackler-2.0.6.33 tracks/go/exercises/protein-translation/protein_translation_test.go
trackler-2.0.6.32 tracks/go/exercises/protein-translation/protein_translation_test.go
trackler-2.0.6.31 tracks/go/exercises/protein-translation/protein_translation_test.go
trackler-2.0.6.30 tracks/go/exercises/protein-translation/protein_translation_test.go
trackler-2.0.6.29 tracks/go/exercises/protein-translation/protein_translation_test.go
trackler-2.0.6.28 tracks/go/exercises/protein-translation/protein_translation_test.go
trackler-2.0.6.27 tracks/go/exercises/protein-translation/protein_translation_test.go
trackler-2.0.6.26 tracks/go/exercises/protein-translation/protein_translation_test.go
trackler-2.0.6.25 tracks/go/exercises/protein-translation/protein_translation_test.go
trackler-2.0.6.24 tracks/go/exercises/protein-translation/protein_translation_test.go
trackler-2.0.6.23 tracks/go/exercises/protein-translation/protein_translation_test.go
trackler-2.0.6.22 tracks/go/exercises/protein-translation/protein_translation_test.go
trackler-2.0.6.21 tracks/go/exercises/protein-translation/protein_translation_test.go