Skip to content

Instantly share code, notes, and snippets.

@tenntenn
Created September 5, 2012 16:50
Show Gist options
  • Save tenntenn/3639784 to your computer and use it in GitHub Desktop.
Save tenntenn/3639784 to your computer and use it in GitHub Desktop.
full test code
package student
import (
"testing"
)
func TestNewPanic(t *testing.T) {
defer func() {
if r := recover(); r == nil {
t.Error("panicが発生しませんでした。")
}
}()
New(0, "test")
}
func TestNew(t *testing.T) {
New(1, "test")
}
func TestString(t *testing.T) {
student := New(1, "test")
if student.String() != "1 test" {
t.Error("1 testが取得できることを期待してたが、%sが返ってきた",
student.String())
}
}
func TestName(t *testing.T) {
student := New(1, "test")
if student.Name() != "test" {
t.Error("testが取得できることを期待してたが、%sが返ってきた",
student.Name())
}
}
func TestId(t *testing.T) {
student := New(1, "test")
if student.Id() != 1 {
t.Error("1が取得できることを期待してたが、%dが返ってきた",
student.Id())
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment