News for hackers. Stuff that matters.
Re:There Are Only Four Billion Floats–So Test Them All (2014) by chriswarbo on Thursday February 09, 2023 @04:54PM (#34732095)
4 billion inputs is a little on the extreme end, especially for slower interpreted languages, but it's always useful to look for functions which can be exhaustively tested; e.g. booleans and enums.

I spotted a bug in a code review today, which was formatting dates with ordinal numbers, like "9th Feb". The ordinal logic only has to work for inputs 1 to 31, so I wrote an exhaustive test, which it failed by outputting "11st", "12nd" and "13rd" (due to only looking at the last digit)

Re:There Are Only Four Billion Floats–So Test Them All (2014) by ben0x539 on Thursday February 09, 2023 @04:57PM (#34732154)
A while back for some videogame related data processing I ended up writing a "regular number to roman numeral" (or maybe the other way around) function in idk ruby or something. Not super convinced that I had gotten it right, I sat down to write a few tests, and then I realized I only needed it to work for numbers up to like 16. So I deleted the actual code, extended the table of test cases to cover 1 through 20 just in case, and just did a lookup in that.
Re:There Are Only Four Billion Floats–So Test Them All (2014) by SnowHill9902 on Thursday February 09, 2023 @05:35PM (#34732655)
That’s actually the right solution to that specific problem.
Re:There Are Only Four Billion Floats–So Test Them All (2014) by giraffe_lady on Thursday February 09, 2023 @05:02PM (#34732234)
true senior eng shit right there.

https://i.imgflip.com/7alx6q.jpg

Re:There Are Only Four Billion Floats–So Test Them All (2014) by travisjungroth on Thursday February 09, 2023 @08:14PM (#34734314)
It happens. Writing the test puts you in the headspace of “assume the problem is already solved”, which is sometimes wildly more effective. There’s some story (that I hope an archivist can link) of someone writing a shell script to verify some giant program. Well, turns out the script could just _replace_ the program. Ran way faster. Sales wouldn’t have that, though.
Re:There Are Only Four Billion Floats–So Test Them All (2014) by JohnFen on Friday February 10, 2023 @12:43AM (#34736057)
Never underestimate the power of a properly placed lookup table.