Sha256: 3f6325c9a1a48d5f86a0a9cc797c6f7c8608ea64f3a8db678c6170c748e0f974

Contents?: true

Size: 1.38 KB

Versions: 122

Compression:

Stored size: 1.38 KB

Contents

package protein

import (
	"reflect"
	"testing"
)

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

Version data entries

122 entries across 122 versions & 1 rubygems

Version Path
trackler-2.2.1.180 tracks/go/exercises/protein-translation/protein_translation_test.go
trackler-2.2.1.179 tracks/go/exercises/protein-translation/protein_translation_test.go
trackler-2.2.1.178 tracks/go/exercises/protein-translation/protein_translation_test.go
trackler-2.2.1.177 tracks/go/exercises/protein-translation/protein_translation_test.go
trackler-2.2.1.176 tracks/go/exercises/protein-translation/protein_translation_test.go
trackler-2.2.1.175 tracks/go/exercises/protein-translation/protein_translation_test.go
trackler-2.2.1.174 tracks/go/exercises/protein-translation/protein_translation_test.go
trackler-2.2.1.173 tracks/go/exercises/protein-translation/protein_translation_test.go
trackler-2.2.1.172 tracks/go/exercises/protein-translation/protein_translation_test.go
trackler-2.2.1.171 tracks/go/exercises/protein-translation/protein_translation_test.go
trackler-2.2.1.170 tracks/go/exercises/protein-translation/protein_translation_test.go
trackler-2.2.1.169 tracks/go/exercises/protein-translation/protein_translation_test.go
trackler-2.2.1.167 tracks/go/exercises/protein-translation/protein_translation_test.go
trackler-2.2.1.166 tracks/go/exercises/protein-translation/protein_translation_test.go
trackler-2.2.1.165 tracks/go/exercises/protein-translation/protein_translation_test.go
trackler-2.2.1.164 tracks/go/exercises/protein-translation/protein_translation_test.go
trackler-2.2.1.163 tracks/go/exercises/protein-translation/protein_translation_test.go
trackler-2.2.1.162 tracks/go/exercises/protein-translation/protein_translation_test.go
trackler-2.2.1.161 tracks/go/exercises/protein-translation/protein_translation_test.go
trackler-2.2.1.160 tracks/go/exercises/protein-translation/protein_translation_test.go