-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain_test.go
36 lines (30 loc) · 956 Bytes
/
main_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package main
import (
"testing"
"fmt"
"time"
)
// Testing
func TestIsSameMonthYear(t *testing.T) {
date_a := time.Date(2021, time.Month(5), 24, 1, 2, 3, 4, time.Now().Location())
date_b := time.Date(2021, time.Month(5), 13, 5, 6, 7, 8, time.Now().Location())
is_same := isSameMonthYear(date_a, date_b)
if is_same == false {
t.Errorf("Year and Month are different")
}
}
// Benchmarking
func BenchmarkIsSameMonthYear(b *testing.B) {
for i := 0; i < b.N; i++ {
date_a := time.Date(2021, time.Month(5), 24, 1, 2, 3, 4, time.Now().Location())
date_b := time.Date(2021, time.Month(5), 13, 5, 6, 7, 8, time.Now().Location())
isSameMonthYear(date_a, date_b)
}
}
// Examples
func ExampleIsSameMonthYear() {
date_a := time.Date(2021, time.Month(5), 24, 1, 2, 3, 4, time.Now().Location())
date_b := time.Date(2021, time.Month(5), 13, 5, 6, 7, 8, time.Now().Location())
fmt.Println(isSameMonthYear(date_a, date_b))
// Output: true
}