I don't know when to use a static assert and when to use a unit test ?
Thread overview | |||||
---|---|---|---|---|---|
|
April 21, 2022 What is the difference between a static assert and a unit test? | ||||
---|---|---|---|---|
| ||||
April 21, 2022 Re: What is the difference between a static assert and a unit test? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Alain De Vos | On Thursday, 21 April 2022 at 22:26:57 UTC, Alain De Vos wrote: >I don't know when to use a static assert and when to use a unit test ? There is
|
April 21, 2022 Re: What is the difference between a static assert and a unit test? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Alain De Vos | On 4/21/22 6:26 PM, Alain De Vos wrote: >I don't know when to use a static assert and when to use a unit test ? An assert in general is something that must be true for the program to be valid. A normal assert is some runtime condition that must be true or the program will be terminated. A static assert is some compile-time condition that must be true or the compilation will be terminated. A unittest is a completely different thing -- this is testing generally a piece of your program (like a function), to ensure that given known inputs it returns known results. A unittest uses asserts to test that the results are valid. -Steve |