From 7e413c5fc926b99cfa5ecf7ddf7b6755df432749 Mon Sep 17 00:00:00 2001 From: Nishanth Shanmugham Date: Mon, 13 Nov 2023 02:02:55 +0000 Subject: [PATCH] add test cases of non-enum switches for -default-case-required --- .../default-not-required/default_not_required.go | 13 +++++++++++++ .../default-required/default_required.go | 13 +++++++++++++ 2 files changed, 26 insertions(+) diff --git a/testdata/src/default-case-required/default-not-required/default_not_required.go b/testdata/src/default-case-required/default-not-required/default_not_required.go index 03cd18c..f02dce8 100644 --- a/testdata/src/default-case-required/default-not-required/default_not_required.go +++ b/testdata/src/default-case-required/default-not-required/default_not_required.go @@ -45,3 +45,16 @@ func _e(t dcr.T) { default: } } + + func _f() { + // should not report because these are not enum switch + // statements. + var x int + switch x { + case 0: + } + + switch { + case x == 0: + } +} diff --git a/testdata/src/default-case-required/default-required/default_required.go b/testdata/src/default-case-required/default-required/default_required.go index e196f40..33ce104 100644 --- a/testdata/src/default-case-required/default-required/default_required.go +++ b/testdata/src/default-case-required/default-required/default_required.go @@ -35,3 +35,16 @@ func _d(t dcr.T) { default: } } + + func _e() { + // should not report because these are not enum switch + // statements. + var x int + switch x { + case 0: + } + + switch { + case x == 0: + } +}