From 34902b1c9adc19025ba4f964e14946da4c176f0e Mon Sep 17 00:00:00 2001 From: tokunagawataru Date: Fri, 6 Jul 2018 02:57:36 +0900 Subject: [PATCH 1/9] =?UTF-8?q?=E3=81=8A=E3=81=BF=E3=81=8F=E3=81=98?= =?UTF-8?q?=E3=82=B5=E3=83=BC=E3=83=90=E3=81=AE=E4=BD=9C=E6=88=90(json?= =?UTF-8?q?=E3=81=A7=E3=81=AE=E5=BF=9C=E7=AD=94,=20random=E6=8A=BD?= =?UTF-8?q?=E5=87=BA=E5=AE=9F=E8=A3=85)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kadai4/tokunaga/main.go | 59 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 kadai4/tokunaga/main.go diff --git a/kadai4/tokunaga/main.go b/kadai4/tokunaga/main.go new file mode 100644 index 0000000..2ea2031 --- /dev/null +++ b/kadai4/tokunaga/main.go @@ -0,0 +1,59 @@ +// handler は、 HTTP リクエストの情報を返します。 +package main + +import ( + "bytes" + crand "crypto/rand" + "encoding/json" + "fmt" + "log" + "math" + "math/big" + "math/rand" + "net/http" +) + +var box = map[int]string{ + 0: "大吉", + 1: "中吉", + 2: "小吉", + 3: "凶", + 4: "大凶", +} + +func init() { + if err := serRandSeed(); err != nil { + log.Fatal(err) + } +} + +func serRandSeed() error { + seed, err := crand.Int(crand.Reader, big.NewInt(math.MaxInt64)) + rand.Seed(seed.Int64()) + return err +} + +func main() { + omikuji := omikuji{} + http.HandleFunc("/omikuji", omikuji.open) + log.Fatal(http.ListenAndServe("localhost:8080", nil)) +} + +type omikuji struct { + Result string `json:"result"` +} + +func (o omikuji) open(w http.ResponseWriter, r *http.Request) { + o.pickUp() + p := &o + var buf bytes.Buffer + enc := json.NewEncoder(&buf) + if err := enc.Encode(p); err != nil { + log.Fatal(err) + } + fmt.Fprintf(w, buf.String()) +} + +func (o *omikuji)pickUp() { + o.Result = box[rand.Intn(5)] +} \ No newline at end of file From 798b12adaf4d6059af66e5ebb1d06510a2c89388 Mon Sep 17 00:00:00 2001 From: tokunagawataru Date: Wed, 11 Jul 2018 03:06:47 +0900 Subject: [PATCH 2/9] =?UTF-8?q?=E3=83=AA=E3=83=95=E3=82=A1=E3=82=AF?= =?UTF-8?q?=E3=82=BF=E3=83=AA=E3=83=B3=E3=82=B0,=20=E7=8F=BE=E5=9C=A8?= =?UTF-8?q?=E6=97=A5=E6=99=82=E3=81=AE=E5=8F=96=E5=BE=97=E3=82=92interface?= =?UTF-8?q?=E3=81=A7=E3=83=A2=E3=83=83=E3=82=AF=E3=81=A7=E3=81=8D=E3=82=8B?= =?UTF-8?q?=E3=82=88=E3=81=86=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kadai4/tokunaga/main.go | 60 ++++++++++++++++++++++++++++++++++------- 1 file changed, 51 insertions(+), 9 deletions(-) diff --git a/kadai4/tokunaga/main.go b/kadai4/tokunaga/main.go index 2ea2031..c16fff0 100644 --- a/kadai4/tokunaga/main.go +++ b/kadai4/tokunaga/main.go @@ -11,8 +11,11 @@ import ( "math/big" "math/rand" "net/http" + "time" ) +const daikiti = 0 + var box = map[int]string{ 0: "大吉", 1: "中吉", @@ -21,12 +24,32 @@ var box = map[int]string{ 4: "大凶", } +var syougatu = [...]string{ + "01-01", + "01-02", + "01-03", +} + func init() { if err := serRandSeed(); err != nil { log.Fatal(err) } } +type timer interface { + Now() time.Time +} + +type timeWrapper struct{} + +type omikuji struct { + Result string `json:"result"` +} + +func (t timeWrapper) Now() time.Time { + return time.Now() +} + func serRandSeed() error { seed, err := crand.Int(crand.Reader, big.NewInt(math.MaxInt64)) rand.Seed(seed.Int64()) @@ -39,21 +62,40 @@ func main() { log.Fatal(http.ListenAndServe("localhost:8080", nil)) } -type omikuji struct { - Result string `json:"result"` +func (o omikuji) open(w http.ResponseWriter, r *http.Request) { + o.pickUp(timeWrapper{}) + buf := encodeJson(&o) + fmt.Fprintf(w, buf.String()) } -func (o omikuji) open(w http.ResponseWriter, r *http.Request) { - o.pickUp() - p := &o +func encodeJson(p *omikuji) bytes.Buffer { var buf bytes.Buffer enc := json.NewEncoder(&buf) if err := enc.Encode(p); err != nil { log.Fatal(err) } - fmt.Fprintf(w, buf.String()) + return buf } -func (o *omikuji)pickUp() { - o.Result = box[rand.Intn(5)] -} \ No newline at end of file +func (o *omikuji) pickUp(timer timer) { + if isOsyougatu(time.Now()) { + o.Result = getDaikiti() + } else { + o.Result = box[rand.Intn(5)] + } + +} + +func isOsyougatu(date time.Time) bool { + day := date.Format("01-02") + for _, sanganichi := range syougatu { + if day == sanganichi { + return true + } + } + return false +} + +func getDaikiti() string { + return box[daikiti] +} From 21f21ae70819ba4b1ca4b126217ffb8d11d011c8 Mon Sep 17 00:00:00 2001 From: tokunagawataru Date: Thu, 12 Jul 2018 00:56:00 +0900 Subject: [PATCH 3/9] =?UTF-8?q?isOsyougatu,=20getDaikiti=E3=81=AE=E3=83=86?= =?UTF-8?q?=E3=82=B9=E3=83=88=E4=BD=9C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kadai4/tokunaga/main.go | 2 +- kadai4/tokunaga/main_test.go | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 kadai4/tokunaga/main_test.go diff --git a/kadai4/tokunaga/main.go b/kadai4/tokunaga/main.go index c16fff0..0a9949b 100644 --- a/kadai4/tokunaga/main.go +++ b/kadai4/tokunaga/main.go @@ -78,7 +78,7 @@ func encodeJson(p *omikuji) bytes.Buffer { } func (o *omikuji) pickUp(timer timer) { - if isOsyougatu(time.Now()) { + if isOsyougatu(timer.Now()) { o.Result = getDaikiti() } else { o.Result = box[rand.Intn(5)] diff --git a/kadai4/tokunaga/main_test.go b/kadai4/tokunaga/main_test.go new file mode 100644 index 0000000..3997da2 --- /dev/null +++ b/kadai4/tokunaga/main_test.go @@ -0,0 +1,36 @@ +package main + +import ( + "testing" + "time" +) + + +func TestIsOsyougatu(t *testing.T) { + cases := []struct{ + name string + input time.Time + expected bool + }{ + {name: "12/31", input: time.Date(2017, 12, 31,23,59,11,11, time.UTC), expected: false}, + {name: "1/1", input: time.Date(2018,1,1,9,11,11,11, time.UTC), expected: true}, + {name: "1/2", input: time.Date(2018,1,2,10,12,11,11, time.UTC), expected: true}, + {name: "1/3", input: time.Date(2018,1,3,11,12,11,11, time.UTC), expected: true}, + {name: "1/4", input: time.Date(2018,1,4,0,0,0,0, time.UTC), expected: false}, + } + for _, c := range cases { + t.Run(c.name, func(t *testing.T) { + if actual := isOsyougatu(c.input); actual != c.expected { + t.Errorf("want isOsyougatu(%s) = %v, got %v", c.input, c.expected, actual) + } + }) + } +} + +func TestGetDaikiti(t *testing.T) { + expected := "大吉" + actual := getDaikiti() + if actual != expected { + t.Errorf("want: getDaikiti() = %s, got: %s ", expected, actual) + } +} From 1e35b6027ddb7bc7ab8597b512689e205b0d524c Mon Sep 17 00:00:00 2001 From: tokunagawataru Date: Thu, 12 Jul 2018 23:59:20 +0900 Subject: [PATCH 4/9] =?UTF-8?q?=E3=81=8A=E3=81=BF=E3=81=8F=E3=81=98?= =?UTF-8?q?=E3=81=AE=E5=87=A6=E7=90=86=E3=82=92=E5=88=A5=E3=83=95=E3=82=A1?= =?UTF-8?q?=E3=82=A4=E3=83=AB=E3=81=AB=E5=88=86=E9=9B=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kadai4/tokunaga/main.go | 74 +---------------------------------- kadai4/tokunaga/omikuji.go | 79 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 80 insertions(+), 73 deletions(-) create mode 100644 kadai4/tokunaga/omikuji.go diff --git a/kadai4/tokunaga/main.go b/kadai4/tokunaga/main.go index 0a9949b..1b046d4 100644 --- a/kadai4/tokunaga/main.go +++ b/kadai4/tokunaga/main.go @@ -2,54 +2,20 @@ package main import ( - "bytes" crand "crypto/rand" - "encoding/json" - "fmt" "log" "math" "math/big" "math/rand" "net/http" - "time" ) -const daikiti = 0 - -var box = map[int]string{ - 0: "大吉", - 1: "中吉", - 2: "小吉", - 3: "凶", - 4: "大凶", -} - -var syougatu = [...]string{ - "01-01", - "01-02", - "01-03", -} - func init() { if err := serRandSeed(); err != nil { log.Fatal(err) } } -type timer interface { - Now() time.Time -} - -type timeWrapper struct{} - -type omikuji struct { - Result string `json:"result"` -} - -func (t timeWrapper) Now() time.Time { - return time.Now() -} - func serRandSeed() error { seed, err := crand.Int(crand.Reader, big.NewInt(math.MaxInt64)) rand.Seed(seed.Int64()) @@ -57,45 +23,7 @@ func serRandSeed() error { } func main() { - omikuji := omikuji{} + omikuji := Omikuji{} http.HandleFunc("/omikuji", omikuji.open) log.Fatal(http.ListenAndServe("localhost:8080", nil)) } - -func (o omikuji) open(w http.ResponseWriter, r *http.Request) { - o.pickUp(timeWrapper{}) - buf := encodeJson(&o) - fmt.Fprintf(w, buf.String()) -} - -func encodeJson(p *omikuji) bytes.Buffer { - var buf bytes.Buffer - enc := json.NewEncoder(&buf) - if err := enc.Encode(p); err != nil { - log.Fatal(err) - } - return buf -} - -func (o *omikuji) pickUp(timer timer) { - if isOsyougatu(timer.Now()) { - o.Result = getDaikiti() - } else { - o.Result = box[rand.Intn(5)] - } - -} - -func isOsyougatu(date time.Time) bool { - day := date.Format("01-02") - for _, sanganichi := range syougatu { - if day == sanganichi { - return true - } - } - return false -} - -func getDaikiti() string { - return box[daikiti] -} diff --git a/kadai4/tokunaga/omikuji.go b/kadai4/tokunaga/omikuji.go new file mode 100644 index 0000000..dc6117f --- /dev/null +++ b/kadai4/tokunaga/omikuji.go @@ -0,0 +1,79 @@ +package main + +import ( + "bytes" + "encoding/json" + "fmt" + "log" + "math/rand" + "net/http" + "time" +) + +const daikiti = 0 + +var box = map[int]string{ + 0: "大吉", + 1: "中吉", + 2: "小吉", + 3: "凶", + 4: "大凶", +} + +var syougatu = [...]string{ + "01-01", + "01-02", + "01-03", +} + +type timer interface { + Now() time.Time +} + +type timeWrapper struct{} + +func (t timeWrapper) Now() time.Time { + return time.Now() +} + +type Omikuji struct { + Result string `json:"result"` +} + +func (o Omikuji) open(w http.ResponseWriter, r *http.Request) { + o.pickUp(timeWrapper{}) + buf := encodeJson(&o) + fmt.Fprintf(w, buf.String()) +} + +func encodeJson(p *Omikuji) bytes.Buffer { + var buf bytes.Buffer + enc := json.NewEncoder(&buf) + if err := enc.Encode(p); err != nil { + log.Fatal(err) + } + return buf +} + +func (o *Omikuji) pickUp(timer timer) { + if isOsyougatu(timer.Now()) { + o.Result = getDaikiti() + } else { + o.Result = box[rand.Intn(5)] + } + +} + +func isOsyougatu(date time.Time) bool { + day := date.Format("01-02") + for _, sanganichi := range syougatu { + if day == sanganichi { + return true + } + } + return false +} + +func getDaikiti() string { + return box[daikiti] +} From 15cc9e0a02ea1f50349a5ed95ead862cde291ce8 Mon Sep 17 00:00:00 2001 From: tokunagawataru Date: Fri, 13 Jul 2018 00:29:06 +0900 Subject: [PATCH 5/9] =?UTF-8?q?main=E9=96=A2=E6=95=B0=E3=81=A7=E7=8F=BE?= =?UTF-8?q?=E5=9C=A8=E6=99=82=E5=88=BB=E5=8F=96=E5=BE=97=E7=94=A8=E3=81=AE?= =?UTF-8?q?interface=E3=82=92=E5=B7=AE=E3=81=97=E6=9B=BF=E3=81=88=E3=82=89?= =?UTF-8?q?=E3=82=8C=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kadai4/tokunaga/main.go | 9 ++++++++- kadai4/tokunaga/omikuji.go | 23 +++++++++++------------ 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/kadai4/tokunaga/main.go b/kadai4/tokunaga/main.go index 1b046d4..cf05af8 100644 --- a/kadai4/tokunaga/main.go +++ b/kadai4/tokunaga/main.go @@ -8,6 +8,7 @@ import ( "math/big" "math/rand" "net/http" + "time" ) func init() { @@ -22,8 +23,14 @@ func serRandSeed() error { return err } +type timeWrapper struct{} + +func (t timeWrapper) Now() time.Time { + return time.Now() +} + func main() { - omikuji := Omikuji{} + omikuji := omikuji{timer: timeWrapper{}} http.HandleFunc("/omikuji", omikuji.open) log.Fatal(http.ListenAndServe("localhost:8080", nil)) } diff --git a/kadai4/tokunaga/omikuji.go b/kadai4/tokunaga/omikuji.go index dc6117f..62d030f 100644 --- a/kadai4/tokunaga/omikuji.go +++ b/kadai4/tokunaga/omikuji.go @@ -30,33 +30,32 @@ type timer interface { Now() time.Time } -type timeWrapper struct{} - -func (t timeWrapper) Now() time.Time { - return time.Now() +type response struct { + Result string `json:"result"` } -type Omikuji struct { - Result string `json:"result"` +type omikuji struct { + timer + response } -func (o Omikuji) open(w http.ResponseWriter, r *http.Request) { - o.pickUp(timeWrapper{}) +func (o omikuji) open(w http.ResponseWriter, r *http.Request) { + o.pickUp() buf := encodeJson(&o) fmt.Fprintf(w, buf.String()) } -func encodeJson(p *Omikuji) bytes.Buffer { +func encodeJson(p *omikuji) bytes.Buffer { var buf bytes.Buffer enc := json.NewEncoder(&buf) - if err := enc.Encode(p); err != nil { + if err := enc.Encode(p.response); err != nil { log.Fatal(err) } return buf } -func (o *Omikuji) pickUp(timer timer) { - if isOsyougatu(timer.Now()) { +func (o *omikuji) pickUp() { + if isOsyougatu(o.timer.Now()) { o.Result = getDaikiti() } else { o.Result = box[rand.Intn(5)] From 39b906c214a62deb4715102076716f6b2f53ede6 Mon Sep 17 00:00:00 2001 From: tokunagawataru Date: Fri, 13 Jul 2018 01:17:06 +0900 Subject: [PATCH 6/9] =?UTF-8?q?main=E9=96=A2=E6=95=B0=E3=81=A7=E4=B9=B1?= =?UTF-8?q?=E6=95=B0=E5=8F=96=E5=BE=97=E7=94=A8=E3=81=AEinterface=E3=82=92?= =?UTF-8?q?=E5=B7=AE=E3=81=97=E6=9B=BF=E3=81=88=E3=82=89=E3=82=8C=E3=82=8B?= =?UTF-8?q?=E3=82=88=E3=81=86=E3=81=AB=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kadai4/tokunaga/main.go | 7 ++++++- kadai4/tokunaga/omikuji.go | 14 +++++++++----- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/kadai4/tokunaga/main.go b/kadai4/tokunaga/main.go index cf05af8..497e34b 100644 --- a/kadai4/tokunaga/main.go +++ b/kadai4/tokunaga/main.go @@ -24,13 +24,18 @@ func serRandSeed() error { } type timeWrapper struct{} +type randWrapper struct{} func (t timeWrapper) Now() time.Time { return time.Now() } +func (r randWrapper) Intn(n int) int { + return rand.Intn(n) +} + func main() { - omikuji := omikuji{timer: timeWrapper{}} + omikuji := omikuji{nower: timeWrapper{}, intner: randWrapper{}} http.HandleFunc("/omikuji", omikuji.open) log.Fatal(http.ListenAndServe("localhost:8080", nil)) } diff --git a/kadai4/tokunaga/omikuji.go b/kadai4/tokunaga/omikuji.go index 62d030f..6e14b8b 100644 --- a/kadai4/tokunaga/omikuji.go +++ b/kadai4/tokunaga/omikuji.go @@ -5,7 +5,6 @@ import ( "encoding/json" "fmt" "log" - "math/rand" "net/http" "time" ) @@ -26,16 +25,21 @@ var syougatu = [...]string{ "01-03", } -type timer interface { +type nower interface { Now() time.Time } +type intner interface { + Intn(int) int +} + type response struct { Result string `json:"result"` } type omikuji struct { - timer + nower + intner response } @@ -55,10 +59,10 @@ func encodeJson(p *omikuji) bytes.Buffer { } func (o *omikuji) pickUp() { - if isOsyougatu(o.timer.Now()) { + if isOsyougatu(o.Now()) { o.Result = getDaikiti() } else { - o.Result = box[rand.Intn(5)] + o.Result = box[o.Intn(5)] } } From 96c623dc24bd51a8fc4c0c9f068e384439024c53 Mon Sep 17 00:00:00 2001 From: tokunagawataru Date: Sat, 14 Jul 2018 13:53:16 +0900 Subject: [PATCH 7/9] =?UTF-8?q?handler=E4=BB=A5=E5=A4=96=E3=81=AE=E3=83=86?= =?UTF-8?q?=E3=82=B9=E3=83=88=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kadai4/tokunaga/omikuji.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/kadai4/tokunaga/omikuji.go b/kadai4/tokunaga/omikuji.go index 6e14b8b..5025c81 100644 --- a/kadai4/tokunaga/omikuji.go +++ b/kadai4/tokunaga/omikuji.go @@ -43,16 +43,16 @@ type omikuji struct { response } -func (o omikuji) open(w http.ResponseWriter, r *http.Request) { +func (o *omikuji) open(w http.ResponseWriter, r *http.Request) { o.pickUp() - buf := encodeJson(&o) + buf := o.encodeJson() fmt.Fprintf(w, buf.String()) } -func encodeJson(p *omikuji) bytes.Buffer { +func (o *omikuji) encodeJson() bytes.Buffer { var buf bytes.Buffer enc := json.NewEncoder(&buf) - if err := enc.Encode(p.response); err != nil { + if err := enc.Encode(o.response); err != nil { log.Fatal(err) } return buf From dd36f18e40e9c4c51e4f4412df162e718b64b1ee Mon Sep 17 00:00:00 2001 From: tokunagawataru Date: Sat, 14 Jul 2018 17:07:10 +0900 Subject: [PATCH 8/9] =?UTF-8?q?=E5=85=A8=E3=81=A6=E3=81=AE=E3=83=86?= =?UTF-8?q?=E3=82=B9=E3=83=88(handler=E5=90=AB=E3=82=80)=E3=82=92=E8=BF=BD?= =?UTF-8?q?=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kadai4/tokunaga/main_test.go | 85 ++++++++++++++++++++++++++++++++---- 1 file changed, 77 insertions(+), 8 deletions(-) diff --git a/kadai4/tokunaga/main_test.go b/kadai4/tokunaga/main_test.go index 3997da2..29fcd31 100644 --- a/kadai4/tokunaga/main_test.go +++ b/kadai4/tokunaga/main_test.go @@ -1,22 +1,91 @@ package main import ( + "io/ioutil" + "net/http" + "net/http/httptest" + "strings" "testing" "time" ) +type testNower struct { + now time.Time +} + +type testIntner struct { + randInt int +} + +func (t testNower) Now() time.Time { + return t.now +} +func (t testIntner) Intn(_ int) int { + return t.randInt - 1 +} + +func TestOpen(t *testing.T) { + shougatsu := testNower{now: time.Date(2018, 1, 1, 9, 11, 11, 11, time.UTC)} + w := httptest.NewRecorder() + r := httptest.NewRequest("GET", "/omikuji", nil) + o := omikuji{nower: shougatsu, intner: testIntner{randInt: 5}} + o.open(w, r) + rw := w.Result() + defer rw.Body.Close() + if rw.StatusCode != http.StatusOK { + t.Fatal("unexpected status code") + } + b, err := ioutil.ReadAll(rw.Body) + if err != nil { + t.Fatal("unexpected error") + } + expected := `{"result":"大吉"}` + if s := strings.TrimSpace(string(b)); s != expected { + t.Fatalf("want: %s, got: %s", expected, s) + } +} + +func TestEncodeJson(t *testing.T) { + expected := `{"result":"大吉"}` + o := omikuji{response: response{Result: "大吉"}} + actual := o.encodeJson() + if strings.TrimSpace(actual.String()) != expected { + t.Errorf("want: o.encodeJson() = %s, got: %s ", expected, actual) + } +} + +func TestPickUp(t *testing.T) { + nenmatsu := testNower{now: time.Date(2017, 12, 31, 23, 59, 11, 11, time.UTC)} + shougatsu := testNower{now: time.Date(2018, 1, 1, 9, 11, 11, 11, time.UTC)} + cases := []struct { + name string + input omikuji + expected string + }{ + {name: "お正月以外", input: omikuji{nower: nenmatsu, intner: testIntner{randInt: 5}}, expected: "大凶"}, + {name: "お正月", input: omikuji{nower: shougatsu, intner: testIntner{randInt: 5}}, expected: "大吉"}, + } + for _, c := range cases { + t.Run(c.name, func(t *testing.T) { + c.input.pickUp() + if actual := c.input.Result; actual != c.expected { + t.Errorf("want o.Result = %v, got %v", c.expected, actual) + } + }) + } +} func TestIsOsyougatu(t *testing.T) { - cases := []struct{ - name string - input time.Time + cases := []struct { + name string + input time.Time expected bool }{ - {name: "12/31", input: time.Date(2017, 12, 31,23,59,11,11, time.UTC), expected: false}, - {name: "1/1", input: time.Date(2018,1,1,9,11,11,11, time.UTC), expected: true}, - {name: "1/2", input: time.Date(2018,1,2,10,12,11,11, time.UTC), expected: true}, - {name: "1/3", input: time.Date(2018,1,3,11,12,11,11, time.UTC), expected: true}, - {name: "1/4", input: time.Date(2018,1,4,0,0,0,0, time.UTC), expected: false}, + {name: "12/31", input: time.Date(2017, 12, 31, 23, 59, 11, 11, time.UTC), expected: false}, + {name: "1/1", input: time.Date(2018, 1, 1, 9, 11, 11, 11, time.UTC), expected: true}, + {name: "1/2", input: time.Date(2018, 1, 2, 10, 12, 11, 11, time.UTC), expected: true}, + {name: "1/3", input: time.Date(2018, 1, 3, 11, 12, 11, 11, time.UTC), expected: true}, + {name: "1/4", input: time.Date(2018, 1, 4, 0, 0, 0, 0, time.UTC), expected: false}, } for _, c := range cases { t.Run(c.name, func(t *testing.T) { From c81a617ad79f40be30f013846accdba65bf66483 Mon Sep 17 00:00:00 2001 From: tokunagawataru Date: Sat, 14 Jul 2018 17:13:07 +0900 Subject: [PATCH 9/9] =?UTF-8?q?omikuji=E3=81=AE=E3=83=AD=E3=82=B8=E3=83=83?= =?UTF-8?q?=E3=82=AF=E3=82=92=E5=88=87=E3=82=8A=E5=87=BA=E3=81=97=E3=81=A6?= =?UTF-8?q?=E3=81=84=E3=82=8B=E3=81=AE=E3=81=A7test=E3=83=95=E3=82=A1?= =?UTF-8?q?=E3=82=A4=E3=83=AB=E3=82=92=E3=83=AA=E3=83=8D=E3=83=BC=E3=83=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kadai4/tokunaga/{main_test.go => omikuji_test.go} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename kadai4/tokunaga/{main_test.go => omikuji_test.go} (100%) diff --git a/kadai4/tokunaga/main_test.go b/kadai4/tokunaga/omikuji_test.go similarity index 100% rename from kadai4/tokunaga/main_test.go rename to kadai4/tokunaga/omikuji_test.go