Skip to content

Commit 9b0d013

Browse files
committed
Replace t.Fatal* with t.Error*.
1 parent 8c06d11 commit 9b0d013

6 files changed

+30
-30
lines changed

consts_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ func TestWeekday_String(t *testing.T) {
2626
} {
2727
t.Run(tt.expected, func(t *testing.T) {
2828
if out := tt.day.String(); out != tt.expected {
29-
t.Fatalf("stringified day = %s, want %s", out, tt.expected)
29+
t.Errorf("stringified day = %s, want %s", out, tt.expected)
3030
}
3131
})
3232
}
@@ -56,7 +56,7 @@ func TestMonth_String(t *testing.T) {
5656
} {
5757
t.Run(tt.expected, func(t *testing.T) {
5858
if out := tt.day.String(); out != tt.expected {
59-
t.Fatalf("stringified month = %s, want %s", out, tt.expected)
59+
t.Errorf("stringified month = %s, want %s", out, tt.expected)
6060
}
6161
})
6262
}

duration_test.go

+15-15
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ func TestDurationOf(t *testing.T) {
7878
t.Run(tt.name, func(t *testing.T) {
7979
d := chrono.DurationOf(tt.of)
8080
if out := d.Nanoseconds(); out != tt.nsec {
81-
t.Fatalf("d.Nanoseconds() = %f, want %f", out, tt.nsec)
81+
t.Errorf("d.Nanoseconds() = %f, want %f", out, tt.nsec)
8282
}
8383
})
8484
}
@@ -167,7 +167,7 @@ func TestDuration_units(t *testing.T) {
167167
t.Run(tt.name, func(t *testing.T) {
168168
d := chrono.DurationOf(tt.of)
169169
if out := tt.f(d); out != tt.expected {
170-
t.Fatalf("%v() = %f, want %f",
170+
t.Errorf("%v() = %f, want %f",
171171
runtime.FuncForPC(reflect.ValueOf(tt.f).Pointer()).Name(),
172172
out, tt.expected)
173173
}
@@ -243,23 +243,23 @@ func TestDuration_Add(t *testing.T) {
243243
t.Run(tt.name, func(t *testing.T) {
244244
t.Run("d1.Add(d2)", func(t *testing.T) {
245245
if ok := tt.d1.CanAdd(tt.d2); !ok {
246-
t.Fatalf("d1.CanAdd(d2) = false, want true")
246+
t.Error("d1.CanAdd(d2) = false, want true")
247247
}
248248

249249
d := tt.d1.Add(tt.d2)
250250
if d.Compare(tt.expected) != 0 {
251-
t.Fatalf("d1.Add(d2) = %v, want %v", d, tt.expected)
251+
t.Errorf("d1.Add(d2) = %v, want %v", d, tt.expected)
252252
}
253253
})
254254

255255
t.Run("d2.Add(d1)", func(t *testing.T) {
256256
if ok := tt.d2.CanAdd(tt.d1); !ok {
257-
t.Fatalf("d2.CanAdd(d1) = false, want true")
257+
t.Error("d2.CanAdd(d1) = false, want true")
258258
}
259259

260260
d := tt.d2.Add(tt.d1)
261261
if d.Compare(tt.expected) != 0 {
262-
t.Fatalf("d2.Add(d1) = %v, want %v", d, tt.expected)
262+
t.Errorf("d2.Add(d1) = %v, want %v", d, tt.expected)
263263
}
264264
})
265265
})
@@ -294,13 +294,13 @@ func TestDuration_Add(t *testing.T) {
294294
t.Run(tt.name, func(t *testing.T) {
295295
t.Run("d1.Add(d2)", func(t *testing.T) {
296296
if ok := tt.d1.CanAdd(tt.d2); ok {
297-
t.Fatalf("d1.CanAdd(d2) = true, want false")
297+
t.Error("d1.CanAdd(d2) = true, want false")
298298
}
299299

300300
func() {
301301
defer func() {
302302
if r := recover(); r == nil {
303-
t.Fatalf("expecting panic that didn't occur")
303+
t.Error("expecting panic that didn't occur")
304304
}
305305
}()
306306

@@ -310,13 +310,13 @@ func TestDuration_Add(t *testing.T) {
310310

311311
t.Run("d2.Add(d1)", func(t *testing.T) {
312312
if ok := tt.d2.CanAdd(tt.d1); ok {
313-
t.Fatalf("d2.CanAdd(d1) = true, want false")
313+
t.Error("d2.CanAdd(d1) = true, want false")
314314
}
315315

316316
func() {
317317
defer func() {
318318
if r := recover(); r == nil {
319-
t.Fatalf("expecting panic that didn't occur")
319+
t.Error("expecting panic that didn't occur")
320320
}
321321
}()
322322

@@ -470,7 +470,7 @@ func TestDuration_Format(t *testing.T) {
470470
t.Run(tt.name, func(t *testing.T) {
471471
d := chrono.DurationOf(tt.of)
472472
if out := d.Format(tt.exclusive...); out != tt.expected {
473-
t.Fatalf("formatted duration = %s, want %s", out, tt.expected)
473+
t.Errorf("formatted duration = %s, want %s", out, tt.expected)
474474
}
475475
})
476476
}
@@ -556,24 +556,24 @@ func TestDuration_Parse(t *testing.T) {
556556
t.Run(tt.name, func(t *testing.T) {
557557
var d chrono.Duration
558558
if err := d.Parse(tt.input); err != nil {
559-
t.Fatalf("failed to parse duation: %v", err)
559+
t.Errorf("failed to parse duation: %v", err)
560560
} else if d.Compare(tt.expected) != 0 {
561-
t.Fatalf("parsed duration = %v, want %v", d, tt.expected)
561+
t.Errorf("parsed duration = %v, want %v", d, tt.expected)
562562
}
563563
})
564564
}
565565

566566
t.Run("overflows", func(t *testing.T) {
567567
var d chrono.Duration
568568
if err := d.Parse("PT2562047788015216H"); err == nil {
569-
t.Fatal("expecting error but got nil")
569+
t.Error("expecting error but got nil")
570570
}
571571
})
572572

573573
t.Run("underflows", func(t *testing.T) {
574574
var d chrono.Duration
575575
if err := d.Parse("PT-2562047788015215H"); err == nil {
576-
t.Fatal("expecting error but got nil")
576+
t.Error("expecting error but got nil")
577577
}
578578
})
579579
}

extent_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@ func TestExtent_Truncate(t *testing.T) {
1111
e := 1*chrono.Hour + 20*chrono.Minute + 5*chrono.Second + 42*chrono.Millisecond + 307*chrono.Microsecond
1212

1313
if e2 := e.Truncate(200 * chrono.Microsecond); e2 != 4805042200000 {
14-
t.Fatalf("e.Truncate() = %d, want 4805042200000", e2)
14+
t.Errorf("e.Truncate() = %d, want 4805042200000", e2)
1515
}
1616
})
1717

1818
t.Run("negative", func(t *testing.T) {
1919
e := -1*chrono.Hour - 20*chrono.Minute - 5*chrono.Second - 42*chrono.Millisecond - 307*chrono.Microsecond
2020

2121
if e2 := e.Truncate(200 * chrono.Microsecond); e2 != -4805042200000 {
22-
t.Fatalf("e.Truncate() = %d, want -4805042200000", e2)
22+
t.Errorf("e.Truncate() = %d, want -4805042200000", e2)
2323
}
2424
})
2525
}

instant_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
func TestInstant_String(t *testing.T) {
1111
i := chronotest.InstantOf(11e14)
1212
if str := i.String(); str != "1100000000000000" {
13-
t.Fatalf("i.String() = %s, want 1100000000000000", str)
13+
t.Errorf("i.String() = %s, want 1100000000000000", str)
1414
}
1515
}
1616

@@ -37,6 +37,6 @@ func TestInstant_Until(t *testing.T) {
3737
i := chronotest.InstantOf(11e14)
3838
d := i.Until(chronotest.InstantOf(12e14))
3939
if nsec := d.Nanoseconds(); nsec != 1e14 {
40-
t.Fatalf("d.Nanoseconds() = %f, want 1e14", nsec)
40+
t.Errorf("d.Nanoseconds() = %f, want 1e14", nsec)
4141
}
4242
}

local_date_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ func TestLocalDateOf(t *testing.T) {
104104
func() {
105105
defer func() {
106106
if r := recover(); r == nil {
107-
t.Fatalf("expecting panic that didn't occur")
107+
t.Error("expecting panic that didn't occur")
108108
}
109109
}()
110110

period_test.go

+8-8
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ func TestPeriod_Format(t *testing.T) {
9595
} {
9696
t.Run(tt.name, func(t *testing.T) {
9797
if out := tt.input.Format(); out != tt.expected {
98-
t.Fatalf("formatted period = %s, want %s", out, tt.expected)
98+
t.Errorf("formatted period = %s, want %s", out, tt.expected)
9999
}
100100
})
101101
}
@@ -151,9 +151,9 @@ func TestPeriod_Parse(t *testing.T) {
151151
t.Run(tt.name, func(t *testing.T) {
152152
var p chrono.Period
153153
if err := p.Parse(tt.input); err != nil {
154-
t.Fatalf("failed to parse period: %v", err)
154+
t.Errorf("failed to parse period: %v", err)
155155
} else if !p.Equal(tt.expected) {
156-
t.Fatalf("parsed period = %v, want %v", p, tt.expected)
156+
t.Errorf("parsed period = %v, want %v", p, tt.expected)
157157
}
158158
})
159159
}
@@ -166,7 +166,7 @@ func TestPeriod_Parse(t *testing.T) {
166166
t.Run(tt, func(t *testing.T) {
167167
var p chrono.Period
168168
if err := p.Parse(tt); err == nil {
169-
t.Fatalf("expecting error but got nil: %v", err)
169+
t.Errorf("expecting error but got nil: %v", err)
170170
}
171171
})
172172
}
@@ -201,11 +201,11 @@ func TestParseDuration(t *testing.T) {
201201
} {
202202
t.Run(tt.name, func(t *testing.T) {
203203
if p, d, err := chrono.ParseDuration(tt.input); err != nil {
204-
t.Fatalf("failed to parse period & duration: %v", err)
204+
t.Errorf("failed to parse period & duration: %v", err)
205205
} else if !p.Equal(tt.period) {
206-
t.Fatalf("parsed period = %v, want %v", p, tt.period)
206+
t.Errorf("parsed period = %v, want %v", p, tt.period)
207207
} else if d.Compare(tt.duration) != 0 {
208-
t.Fatalf("parsed duration = %v, want %v", d, tt.duration)
208+
t.Errorf("parsed duration = %v, want %v", d, tt.duration)
209209
}
210210
})
211211
}
@@ -216,7 +216,7 @@ func TestParseDuration(t *testing.T) {
216216
"PT",
217217
} {
218218
if _, _, err := chrono.ParseDuration(tt); err == nil {
219-
t.Fatal("expecting error but got nil")
219+
t.Error("expecting error but got nil")
220220
}
221221
}
222222
})

0 commit comments

Comments
 (0)