go/analysis/passes/modernize/testdata/src/minmax/wrongoperators/wrongoperators.go
raw| 1 | package wrongoperators |
| 2 | |
| 3 | // min function with max logic - should NOT be detected (wrong logic) |
| 4 | func min(a, b int) int { |
| 5 | if a >= b { // This is max logic, not min logic |
| 6 | return a |
| 7 | } else { |
| 8 | return b |
| 9 | } |
| 10 | } |
| 11 | |
| 12 | // max function with min logic - should NOT be detected (wrong logic) |
| 13 | func max(a, b int) int { |
| 14 | if a <= b { // This is min logic, not max logic |
| 15 | return a |
| 16 | } else { |
| 17 | return b |
| 18 | } |
| 19 | } |