Commit Graph

3 Commits

Author SHA1 Message Date
Chris Darroch
552614aee8 commands,tools: fix ClampInt() function and tests
The ClampInt() function does not always return a value
between its "min" and "max" arguments because it reverses
their meaning, and the relevant tests in the corresponding
tools/math_test.go file do not report the problem because
they do not execute when the "go test ./tools" command is run.
The latter bug is a result of the test functions lacking the
necessary Test* prefix to be recognized by the Go "test"
command.

After we fix the ClampInt() function, we rename all the
test functions in tools/math_test.go to follow the Test*()
naming scheme, which ensures they now run properly.

Lastly, we change the one caller of the ClampInt() function,
the migrateInfoCommand() function, which previously worked
correctly because it also reversed the order of the
arguments it passed to the function.  That reversal was
introduced in commit bd2e1b27368745f4014a448c371fd72c658ef9d6
in PR #2313, as part of the development of the "migrate info"
command, presumably because the author discovered the call
was not working as expected.
2021-03-10 21:11:54 -08:00
Taylor Blau
d2c6b0c96a tools/math: teach tools.ClampInt to clamp integers 2017-06-09 17:56:21 -06:00
Taylor Blau
3de701ffa0 git,tools: use tools.{Max,Min}Int instead of math package 2016-11-03 14:14:20 -06:00