3 ms·
I’d like to see the unit tests for the non-true return state.
by Waterluvian 5y ago
I’d like to see the unit tests for the non-true return state.
- 1_player 5y agoResult is undefined if computer isn't on, so any value is OK, no tests necessary.
- OJFord 5y agoGP said for the 'non-true state', not the 'computer off state'. I.e. verify that the computer is off, given that the fn returns false (which is valid only as part of its undefined computer-off response).
- chizhik-pyzhik 5y agoI think that would have to be an integration test
- 13of40 5y agoIt's actually pretty straightforward: turn_computer_off(); Assert(!is_computer_on(), "Computer should have been off but it's on."); The opposite is a bit tricky, though.
- deleted 5y ago[deleted]
- ancode 5y agoThis assert doesn't work like you think it does. If the computer is off is_computer_on is undefined, so if this is called when the computer is already off it could return a nonzero value, thus resolving to true even though the computer is already off.