(t *testing.T)
| 7 | ) |
| 8 | |
| 9 | func TestOsDateFormatUTCWithTwoParam(t *testing.T) { |
| 10 | t.Setenv("TZ", "Asia/Tokyo") |
| 11 | ls := NewState() |
| 12 | |
| 13 | g := ls.GetGlobal("os") |
| 14 | fn := ls.GetField(g, "date") |
| 15 | |
| 16 | int64ptr := func(i int64) *int64 { |
| 17 | return &i |
| 18 | } |
| 19 | cases := []struct { |
| 20 | Name string |
| 21 | Local time.Time |
| 22 | Now time.Time |
| 23 | Format string |
| 24 | Timestamp *int64 |
| 25 | }{ |
| 26 | { |
| 27 | "UTCWithTwoParam", |
| 28 | time.Now(), |
| 29 | time.Now().UTC(), |
| 30 | "!*t", |
| 31 | int64ptr(time.Now().UTC().Unix()), |
| 32 | }, |
| 33 | { |
| 34 | "LocalWithTwoParam", |
| 35 | time.Now(), |
| 36 | time.Now(), |
| 37 | "*t", |
| 38 | int64ptr(time.Now().Unix()), |
| 39 | }, |
| 40 | { |
| 41 | "UTCWithOnlyFormatParam", |
| 42 | time.Now(), |
| 43 | time.Now().UTC(), |
| 44 | "!*t", |
| 45 | nil, |
| 46 | }, |
| 47 | { |
| 48 | "LocalWithOnlyFormatParam", |
| 49 | time.Now(), |
| 50 | time.Now(), |
| 51 | "*t", |
| 52 | nil, |
| 53 | }, |
| 54 | } |
| 55 | |
| 56 | for _, c := range cases { |
| 57 | t.Run(c.Name, func(t *testing.T) { |
| 58 | args := make([]LValue, 0) |
| 59 | args = append(args, LString(c.Format)) |
| 60 | if c.Timestamp != nil { |
| 61 | args = append(args, LNumber(*c.Timestamp)) |
| 62 | } |
| 63 | err := ls.CallByParam(P{ |
| 64 | Fn: fn, |
| 65 | NRet: 1, |
| 66 | Protect: true, |
nothing calls this directly
no test coverage detected
searching dependent graphs…