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.78 tracks/go/exercises/protein-translation/protein_translation_test.go
trackler-2.2.1.77 tracks/go/exercises/protein-translation/protein_translation_test.go
trackler-2.2.1.76 tracks/go/exercises/protein-translation/protein_translation_test.go
trackler-2.2.1.75 tracks/go/exercises/protein-translation/protein_translation_test.go
trackler-2.2.1.74 tracks/go/exercises/protein-translation/protein_translation_test.go
trackler-2.2.1.73 tracks/go/exercises/protein-translation/protein_translation_test.go
trackler-2.2.1.72 tracks/go/exercises/protein-translation/protein_translation_test.go
trackler-2.2.1.71 tracks/go/exercises/protein-translation/protein_translation_test.go
trackler-2.2.1.70 tracks/go/exercises/protein-translation/protein_translation_test.go
trackler-2.2.1.69 tracks/go/exercises/protein-translation/protein_translation_test.go
trackler-2.2.1.68 tracks/go/exercises/protein-translation/protein_translation_test.go
trackler-2.2.1.67 tracks/go/exercises/protein-translation/protein_translation_test.go
trackler-2.2.1.66 tracks/go/exercises/protein-translation/protein_translation_test.go
trackler-2.2.1.65 tracks/go/exercises/protein-translation/protein_translation_test.go
trackler-2.2.1.64 tracks/go/exercises/protein-translation/protein_translation_test.go
trackler-2.2.1.63 tracks/go/exercises/protein-translation/protein_translation_test.go
trackler-2.2.1.62 tracks/go/exercises/protein-translation/protein_translation_test.go
trackler-2.2.1.61 tracks/go/exercises/protein-translation/protein_translation_test.go
trackler-2.2.1.60 tracks/go/exercises/protein-translation/protein_translation_test.go
trackler-2.2.1.59 tracks/go/exercises/protein-translation/protein_translation_test.go