Created
September 5, 2012 16:50
-
-
Save tenntenn/3639784 to your computer and use it in GitHub Desktop.
full test code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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