100-exercises-to-learn-rust icon indicating copy to clipboard operation
100-exercises-to-learn-rust copied to clipboard

ch02 ex10 `u8_to_i8` test improvement

Open robjtede opened this issue 1 year ago • 0 comments

With the test being annotated with

#[allow(overflowing_literals)]

in combination with the test being:

assert_eq!(255 as i8, todo!());

a naïve answer of 255_i8 succeeds.

I'm guessing the idea of this is that one should answer with -1_uX but the person I was guiding through the exercises would have skipped right by if I hadn't said "this assertion will fail".

Maybe also relevant is that the overflow-checks profile, set on the workspace (as is necessary) from a couple of exercises ago is likely still there. If so, this set of tests might need one that "asserts" we turned it off again. (Though I suppose that interferes with the re-runnability of the tests.)

robjtede avatar May 19 '24 01:05 robjtede