Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

【課題2】 #19

Open
wants to merge 52 commits into
base: master
Choose a base branch
from
Open

【課題2】 #19

wants to merge 52 commits into from

Conversation

nasjp
Copy link

@nasjp nasjp commented Sep 14, 2019

課題2

【TRY】io.Readerとio.Writer

  • io.Readerとio.Writerについて調べてみよう
    • 標準パッケージでどのように使われているか
    • io.Readerとio.Writerがあることでどういう利点があるのか具体例を挙げて考えてみる

kadai2/nas/doc/homework.md に記載

1回目の宿題のテストを作ってみて下さい

  • テストのしやすさを考えてリファクタリングしてみる
  • テストのカバレッジを取ってみる
  • テーブル駆動テストを行う
  • テストヘルパーを作ってみる

coverage: 89.1% of statements

@nasjp nasjp added the kadai2 label Sep 14, 2019
@nasjp nasjp self-assigned this Sep 14, 2019
func main() {
err := run()
if err != nil {
os.Exit(ExitCodeErr)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

エラーメッセージは出さない?

keepfile = ".gitkeep"
)

func SetupTest(t *testing.T, path string, isDir bool) func() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

一時ディレクトリを作って、コピーしてあとで全部消した方が楽そう

case true:
err := os.Mkdir(path, os.ModePerm)
if err != nil {
t.Errorf("Setup Error : %v", err)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

エラーが報告されたとしてもどうしようもないからt.Fatalfの方がよさそう

if err != nil {
t.Errorf("Setup Error : %v", err)
}
defer f.Close()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

エラー処理


img := image.NewRGBA(image.Rect(0, 0, 100, 100))
if err := jpeg.Encode(f, img, &jpeg.Options{Quality: 100}); err != nil {
t.Errorf("Setup Error : %v", err)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

t.Fatalf

}
}

func TestConvert(t *testing.T) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants