@@ -136,3 +136,80 @@ fn try_verify_against_date_command_format() {
136
136
date += chrono:: Duration :: days ( 55 ) ;
137
137
}
138
138
}
139
+
140
+ // The following panic tests should remove `#[should_panic]` after
141
+ // Issue #1010 is fixed.
142
+
143
+ #[ test]
144
+ #[ should_panic]
145
+ /// Derived from https://github.com/Koral77/replay_files/blob/ce5b5c88c2a45a089d7d5ce19c60a5e50283ba60/replays/chrono/replay_chrono1/src/main.rs
146
+ fn issue_1010_panic1 ( ) {
147
+ let _local0 = chrono:: naive:: NaiveDateTime :: from_timestamp_opt ( -4227854320 , 1678774288 ) ;
148
+ let _local1 = chrono:: Duration :: microseconds ( -7019067213869040 ) ;
149
+ let _local2_param0_helper1 = _local0. unwrap ( ) ;
150
+ // panics
151
+ _ = chrono:: DurationRound :: duration_trunc ( _local2_param0_helper1, _local1) ;
152
+ }
153
+
154
+ #[ test]
155
+ #[ should_panic]
156
+ /// Derived from https://github.com/Koral77/replay_files/blob/ce5b5c88c2a45a089d7d5ce19c60a5e50283ba60/replays/chrono/replay_chrono2/src/main.rs
157
+ fn issue_1010_panic2 ( ) {
158
+ let _local0 = chrono:: naive:: NaiveDateTime :: from_timestamp_opt ( 320041586 , 1920103021 ) ;
159
+ let _local1 = chrono:: Duration :: nanoseconds ( -8923838508697114584 ) ;
160
+ let _local2_param0_helper1 = _local0. unwrap ( ) ;
161
+ // panics
162
+ _ = chrono:: DurationRound :: duration_round ( _local2_param0_helper1, _local1) ;
163
+ }
164
+
165
+ #[ test]
166
+ #[ should_panic]
167
+ /// Derived from https://github.com/Koral77/replay_files/blob/ce5b5c88c2a45a089d7d5ce19c60a5e50283ba60/replays/chrono/replay_chrono3/src/main.rs
168
+ fn issue_1010_panic3 ( ) {
169
+ let _local0 = chrono:: naive:: NaiveDateTime :: from_timestamp_opt ( -2621440 , 0 ) ;
170
+ let _local1 = chrono:: Duration :: nanoseconds ( -9223372036854771421 ) ;
171
+ let _local2_param0_helper1 = _local0. unwrap ( ) ;
172
+ // panics
173
+ _ = chrono:: DurationRound :: duration_round ( _local2_param0_helper1, _local1) ;
174
+ }
175
+
176
+ #[ test]
177
+ /// Derived from https://github.com/Koral77/replay_files/blob/ce5b5c88c2a45a089d7d5ce19c60a5e50283ba60/replays/chrono/replay_chrono4/src/main.rs
178
+ fn issue_1010_nopanic4 ( ) {
179
+ let _local1 = chrono:: offset:: FixedOffset :: east_opt ( 17367308 ) ;
180
+ assert ! ( _local1. is_none( ) ) ;
181
+ }
182
+
183
+ #[ test]
184
+ /// Derived from https://github.com/Koral77/replay_files/blob/ce5b5c88c2a45a089d7d5ce19c60a5e50283ba60/replays/chrono/replay_chrono5/src/main.rs
185
+ fn issue_1010_nopanic5 ( ) {
186
+ let _local0 = chrono:: naive:: NaiveDateTime :: from_timestamp_opt ( -502509993984 , 64 ) ;
187
+ let _local1_param0_helper1 = _local0. unwrap ( ) ;
188
+ assert ! ( chrono:: Datelike :: with_ordinal0( & ( _local1_param0_helper1) , 4294967295 ) . is_none( ) ) ;
189
+ }
190
+
191
+ #[ test]
192
+ /// Derived from https://github.com/Koral77/replay_files/blob/ce5b5c88c2a45a089d7d5ce19c60a5e50283ba60/replays/chrono/replay_chrono6/src/main.rs
193
+ fn issue_1010_nopanic6 ( ) {
194
+ let _local0 = chrono:: naive:: NaiveDateTime :: from_timestamp_opt ( -754576364 , 336909572 ) ;
195
+ let _local1_param0_helper1 = _local0. unwrap ( ) ;
196
+ assert ! ( chrono:: Datelike :: with_day0( & ( _local1_param0_helper1) , 4294967295 ) . is_none( ) ) ;
197
+ }
198
+
199
+ #[ test]
200
+ /// Derived from https://github.com/Koral77/replay_files/blob/ce5b5c88c2a45a089d7d5ce19c60a5e50283ba60/replays/chrono/replay_chrono7/src/main.rs
201
+ fn issue_1010_nopanic7 ( ) {
202
+ #[ allow( deprecated) ]
203
+ let _local0 = chrono:: naive:: NaiveDateTime :: from_timestamp ( -8377300 , 742391807 ) ;
204
+ assert ! ( chrono:: Datelike :: with_month0( & ( _local0) , 4294967295 ) . is_none( ) ) ;
205
+ }
206
+
207
+ #[ test]
208
+ #[ should_panic]
209
+ /// Derived from https://github.com/Koral77/replay_files/blob/ce5b5c88c2a45a089d7d5ce19c60a5e50283ba60/replays/chrono/replay_chrono8/src/main.rs
210
+ fn issue_1010_panic8 ( ) {
211
+ #[ allow( deprecated) ]
212
+ let _local0 = chrono:: naive:: NaiveDateTime :: from_timestamp ( -11676614656 , 15282199 ) ;
213
+ // panics
214
+ _ = chrono:: naive:: NaiveDateTime :: timestamp_nanos ( & ( & _local0) ) ;
215
+ }
0 commit comments