What is the difference between a static assert and a unit test?
    Steven Schveighoffer 
    schveiguy at gmail.com
       
    Fri Apr 22 02:48:51 UTC 2022
    
    
  
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
    
    
More information about the Digitalmars-d-learn
mailing list