Il mar 6 set 2022, 07:01 Markus Armbruster <arm...@redhat.com> ha scritto:
> Next, permit me a few words on writing tests. For me, a unit test fails > by crashing. Crashing with a nice message is optional. The more likely > the failure, the more useful is niceness. Complete niceness is > impossible --- if we could predict all crashes, we wouldn't need tests. > Trying to push niceness can be overly verbose. Thus, judgement calls, > and matters of taste. > I agree; however, *relying* on a crash for correctness of the test is not great. Part of the test here is checking that an empty qdict_crumple returns a dictionary and not, say, a list. The newly-added assertion avoids that two wrongs end up making a right: if qobject_check_type somehow failed to identify the dictionary and returned (QDict *) obj, qdict_size would not crash. Unlikely as it is, it's nicer to spell out the postconditions that the test is checking. Paolo > Wanting to mollify Coverity is a valid argument. > >