From 95ec579eb68fcc01975462a74676e3bacd9814b0 Mon Sep 17 00:00:00 2001 From: cui fliter Date: Mon, 12 Sep 2022 09:27:11 +0000 Subject: [PATCH] strconv: add a test case when base is illegal Increase unit test coverage of strconv/itoa.go from 83.8% to 85% Change-Id: I0abdfc70a3f06251106f229c12ffb105eeb43fc8 GitHub-Last-Rev: da9755368b5db41123c8f945fecedd135e9f894a GitHub-Pull-Request: golang/go#55014 Reviewed-on: https://go-review.googlesource.com/c/go/+/430137 Reviewed-by: Ian Lance Taylor Run-TryBot: Jenny Rakoczy Reviewed-by: Jenny Rakoczy TryBot-Result: Gopher Robot Auto-Submit: Ian Lance Taylor Run-TryBot: Ian Lance Taylor Auto-Submit: Jenny Rakoczy --- src/strconv/itoa_test.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/strconv/itoa_test.go b/src/strconv/itoa_test.go index b5ee3aa828..b8bc52490a 100644 --- a/src/strconv/itoa_test.go +++ b/src/strconv/itoa_test.go @@ -93,6 +93,14 @@ func TestItoa(t *testing.T) { } } } + + // Override when base is illegal + defer func() { + if r := recover(); r == nil { + t.Fatalf("expected panic due to illegal base") + } + }() + FormatUint(12345678, 1) } type uitob64Test struct {