Add test with multiple switch statements

This commit is contained in:
Owen Mansel-Chan
2021-02-03 14:38:53 +00:00
parent 760d89b0d3
commit a7545cd11b

View File

@@ -86,6 +86,25 @@ func switchStatementReturningNilOnlyWhenConstant(s string) *string {
return &str
}
func multipleSwitchStatementReturningTrueOnlyWhenConstant(s string, t string) bool {
switch s {
case constantGlobalVariable, "string literal":
return true
case getRandomString():
return false
}
switch s {
case "another string literal":
return true
}
switch t {
case "another string literal":
return false
default:
return false
}
}
func switchStatementWithoutUsefulInfo(s string) bool {
switch s {
case constantGlobalVariable, "string literal":
@@ -149,6 +168,15 @@ func main() {
}
}
{
s := source()
if multipleSwitchStatementReturningTrueOnlyWhenConstant(s, getRandomString()) {
sink(s)
} else {
sink(s) // $dataflow=s
}
}
{
s := source()
if switchStatementWithoutUsefulInfo(s) {