(t *testing.T)
| 1105 | } |
| 1106 | |
| 1107 | func TestTimeFormat(t *testing.T) { |
| 1108 | // Format a time using RFC3339 |
| 1109 | nanos := int64(1705314600123456789) // 2024-01-15 10:30:00.123456789 UTC |
| 1110 | |
| 1111 | tests := []struct { |
| 1112 | precision string |
| 1113 | want string |
| 1114 | }{ |
| 1115 | {"/second", "2024-01-15T10:30:00Z"}, |
| 1116 | {"/millisecond", "2024-01-15T10:30:00.123Z"}, |
| 1117 | {"/microsecond", "2024-01-15T10:30:00.123456Z"}, |
| 1118 | {"/nanosecond", "2024-01-15T10:30:00.123456789Z"}, |
| 1119 | } |
| 1120 | |
| 1121 | for _, test := range tests { |
| 1122 | t.Run(test.precision, func(t *testing.T) { |
| 1123 | expr := ast.ApplyFn{symbols.TimeFormat, []ast.BaseTerm{ |
| 1124 | ast.Time(nanos), |
| 1125 | name(test.precision), |
| 1126 | }} |
| 1127 | got, err := EvalApplyFn(expr, ast.ConstSubstMap{}) |
| 1128 | if err != nil { |
| 1129 | t.Fatalf("EvalApplyFn(%v) failed with %v", expr, err) |
| 1130 | } |
| 1131 | want := ast.String(test.want) |
| 1132 | if !got.Equals(want) { |
| 1133 | t.Errorf("EvalApplyFn(%v) = %v, want %v", expr, got, want) |
| 1134 | } |
| 1135 | }) |
| 1136 | } |
| 1137 | } |
| 1138 | |
| 1139 | func TestTimeFormatCivil(t *testing.T) { |
| 1140 | // 2024-01-15 10:30:00 UTC |
nothing calls this directly
no test coverage detected