Skip to content

Commit c137190

Browse files
committed
test(C): do not use assert
assert does nothing if NDEBUG is defined
1 parent 9ff1dc3 commit c137190

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

test/api/example.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
* along with dftd4. If not, see <https://www.gnu.org/licenses/>.
1616
**/
1717

18+
#include <stdio.h>
1819
#include <stdlib.h>
19-
#include <assert.h>
2020

2121
#include "dftd4.h"
2222

@@ -40,23 +40,23 @@ main (void)
4040
double sigma[9];
4141
double c6[49];
4242

43-
assert(dftd4_get_version() > 0);
43+
if (dftd4_get_version() <= 0) {return 1;}
4444

4545
dftd4_error error;
4646
dftd4_structure mol;
4747
dftd4_model disp;
4848
dftd4_param param;
4949

5050
error = dftd4_new_error();
51-
assert(!!error);
51+
if (!error) {return 1;}
5252

5353
mol = dftd4_new_structure(error, natoms, attyp, coord, NULL, NULL, NULL);
5454
if (dftd4_check_error(error)) {return 1;};
55-
assert(!!mol);
55+
if (!mol) {return 1;}
5656

5757
disp = dftd4_new_d4_model(error, mol);
5858
if (dftd4_check_error(error)) {return 1;}
59-
assert(!!disp);
59+
if (!disp) {return 1;}
6060

6161
// C6 coefficients
6262
dftd4_get_properties(error, mol, disp, NULL, NULL, c6, NULL);
@@ -65,7 +65,7 @@ main (void)
6565
// PBE-D4
6666
param = dftd4_new_rational_damping(error, 1.0, 0.95948085, 0.0, 0.38574991, 4.80688534, 16.0);
6767
if (dftd4_check_error(error)) {return 1;}
68-
assert(!!param);
68+
if (!param) {return 1;}
6969
dftd4_get_dispersion(error, mol, disp, param, &energy, NULL, NULL);
7070
if (dftd4_check_error(error)) {return 1;}
7171
dftd4_get_dispersion(error, mol, disp, param, &energy, gradient, sigma);
@@ -77,7 +77,7 @@ main (void)
7777
// DSD-BLYP-D4-ATM
7878
param = dftd4_load_rational_damping(error, "dsdblyp", true);
7979
if (dftd4_check_error(error)) {return 1;}
80-
assert(!!param);
80+
if (!param) {return 1;}
8181
dftd4_get_dispersion(error, mol, disp, param, &energy, NULL, NULL);
8282
if (dftd4_check_error(error)) {return 1;}
8383
dftd4_get_dispersion(error, mol, disp, param, &energy, gradient, sigma);
@@ -88,10 +88,10 @@ main (void)
8888
dftd4_delete(mol);
8989
dftd4_delete(error);
9090

91-
assert(!param);
92-
assert(!disp);
93-
assert(!mol);
94-
assert(!error);
91+
if (param) {return 1;}
92+
if (disp) {return 1;}
93+
if (mol) {return 1;}
94+
if (error) {return 1;}
9595

9696
return 0;
9797
}

0 commit comments

Comments
 (0)