TestIsTime_VariousFormats_808 covers multiple scenarios for the IsTime function, including standard date formats (RFC3339, UnixDate), numeric timestamps as strings, and invalid inputs to ensure it correctly identifies time-like strings.
(t *testing.T)
| 835 | // including standard date formats (RFC3339, UnixDate), numeric timestamps as strings, |
| 836 | // and invalid inputs to ensure it correctly identifies time-like strings. |
| 837 | func TestIsTime_VariousFormats_808(t *testing.T) { |
| 838 | testCases := []struct { |
| 839 | name string |
| 840 | input string |
| 841 | expected bool |
| 842 | }{ |
| 843 | {"RFC3339", "2023-01-17T16:34:58Z", true}, |
| 844 | {"UnixDate", "Tue Jan 17 16:34:58 UTC 2023", true}, |
| 845 | {"NumericTimestamp", fmt.Sprintf("%f", float64(time.Now().UnixNano())), true}, |
| 846 | {"AlmostNow", fmt.Sprintf("%f", float64(time.Now().Add(-time.Hour).UnixNano())), true}, |
| 847 | {"TooOldNumeric", fmt.Sprintf("%f", float64(time.Now().Add(-48*time.Hour).UnixNano())), false}, |
| 848 | {"InvalidString", "not a date", false}, |
| 849 | {"EmptyString", "", false}, |
| 850 | } |
| 851 | |
| 852 | for _, tc := range testCases { |
| 853 | t.Run(tc.name, func(t *testing.T) { |
| 854 | assert.Equal(t, tc.expected, IsTime(tc.input)) |
| 855 | }) |
| 856 | } |
| 857 | } |
| 858 | |
| 859 | // TestToHTTPHeader_WithTimeValue_909 verifies that the ToHTTPHeader function correctly |
| 860 | // converts a map of strings to an http.Header object. It specifically checks that |