1 /**
2  * \file    TestL3FormulaParser.c
3  * \brief   L3FormulaParser unit tests
4  * \author  Ben Bornstein
5  *
6  * <!--------------------------------------------------------------------------
7  * This file is part of libSBML.  Please visit http://sbml.org for more
8  * information about SBML, and the latest version of libSBML.
9  *
10  * Copyright (C) 2020 jointly by the following organizations:
11  *     1. California Institute of Technology, Pasadena, CA, USA
12  *     2. University of Heidelberg, Heidelberg, Germany
13  *     3. University College London, London, UK
14  *
15  * Copyright (C) 2019 jointly by the following organizations:
16  *     1. California Institute of Technology, Pasadena, CA, USA
17  *     2. University of Heidelberg, Heidelberg, Germany
18  *
19  * Copyright (C) 2013-2018 jointly by the following organizations:
20  *     1. California Institute of Technology, Pasadena, CA, USA
21  *     2. EMBL European Bioinformatics Institute (EMBL-EBI), Hinxton, UK
22  *     3. University of Heidelberg, Heidelberg, Germany
23  *
24  * Copyright (C) 2009-2013 jointly by the following organizations:
25  *     1. California Institute of Technology, Pasadena, CA, USA
26  *     2. EMBL European Bioinformatics Institute (EMBL-EBI), Hinxton, UK
27  *
28  * Copyright (C) 2006-2008 by the California Institute of Technology,
29  *     Pasadena, CA, USA
30  *
31  * Copyright (C) 2002-2005 jointly by the following organizations:
32  *     1. California Institute of Technology, Pasadena, CA, USA
33  *     2. Japan Science and Technology Agency, Japan
34  *
35  * This library is free software; you can redistribute it and/or modify it
36  * under the terms of the GNU Lesser General Public License as published by
37  * the Free Software Foundation.  A copy of the license agreement is provided
38  * in the file named "LICENSE.txt" included with this software distribution
39  * and also available online as http://sbml.org/software/libsbml/license.html
40  * ---------------------------------------------------------------------- -->*/
41 
42 #include <sbml/common/common.h>
43 #include <sbml/util/util.h>
44 #include <sbml/math/L3Parser.h>
45 #include <sbml/math/L3ParserSettings.h>
46 #include <sbml/Model.h>
47 
48 #include <check.h>
49 
50 #if __cplusplus
51 LIBSBML_CPP_NAMESPACE_USE
52 CK_CPPSTART
53 #endif
54 
START_TEST(test_SBML_parseL3Formula_1)55 START_TEST (test_SBML_parseL3Formula_1)
56 {
57   ASTNode_t *r = SBML_parseL3Formula("1");
58 
59 
60   fail_unless( ASTNode_getType       (r) == AST_INTEGER, NULL );
61   fail_unless( ASTNode_getInteger    (r) == 1, NULL );
62   fail_unless( ASTNode_getNumChildren(r) == 0, NULL );
63 
64   ASTNode_free(r);
65   // SBML_deleteL3Parser();
66 }
67 END_TEST
68 
69 
START_TEST(test_SBML_parseL3Formula_2)70 START_TEST (test_SBML_parseL3Formula_2)
71 {
72   ASTNode_t *r = SBML_parseL3Formula("2.1");
73 
74 
75   fail_unless( ASTNode_getType       (r) == AST_REAL, NULL );
76   fail_unless( ASTNode_getReal       (r) == 2.1, NULL );
77   fail_unless( ASTNode_getNumChildren(r) ==   0, NULL );
78 
79   ASTNode_free(r);
80   // SBML_deleteL3Parser();
81 }
82 END_TEST
83 
84 
START_TEST(test_SBML_parseL3Formula_3)85 START_TEST (test_SBML_parseL3Formula_3)
86 {
87   ASTNode_t *r = SBML_parseL3Formula("2.1e5");
88 
89 
90   fail_unless( ASTNode_getType       (r) == AST_REAL_E, NULL );
91   fail_unless( ASTNode_getMantissa   (r) == 2.1, NULL );
92   fail_unless( ASTNode_getExponent   (r) ==   5, NULL );
93   fail_unless( ASTNode_getNumChildren(r) ==   0, NULL );
94 
95   ASTNode_free(r);
96   // SBML_deleteL3Parser();
97 }
98 END_TEST
99 
100 
START_TEST(test_SBML_parseL3Formula_4)101 START_TEST (test_SBML_parseL3Formula_4)
102 {
103   ASTNode_t *r = SBML_parseL3Formula("foo");
104 
105 
106   fail_unless( ASTNode_getType(r) == AST_NAME     , NULL );
107   fail_unless( !strcmp(ASTNode_getName(r), "foo") , NULL );
108   fail_unless( ASTNode_getNumChildren(r) == 0     , NULL );
109 
110   ASTNode_free(r);
111   // SBML_deleteL3Parser();
112 }
113 END_TEST
114 
115 
START_TEST(test_SBML_parseL3Formula_5)116 START_TEST (test_SBML_parseL3Formula_5)
117 {
118   ASTNode_t *r = SBML_parseL3Formula("1 + foo");
119   ASTNode_t *c;
120 
121 
122 
123   fail_unless( ASTNode_getType       (r) == AST_PLUS, NULL );
124   fail_unless( ASTNode_getCharacter  (r) == '+', NULL );
125   fail_unless( ASTNode_getNumChildren(r) == 2  , NULL );
126 
127   c = ASTNode_getLeftChild(r);
128 
129   fail_unless( ASTNode_getType       (c) == AST_INTEGER, NULL );
130   fail_unless( ASTNode_getInteger    (c) == 1, NULL );
131   fail_unless( ASTNode_getNumChildren(c) == 0, NULL );
132 
133   c = ASTNode_getRightChild(r);
134 
135   fail_unless( ASTNode_getType(c) == AST_NAME     , NULL );
136   fail_unless( !strcmp(ASTNode_getName(c), "foo") , NULL );
137   fail_unless( ASTNode_getNumChildren(c) == 0     , NULL );
138 
139   ASTNode_free(r);
140   // SBML_deleteL3Parser();
141 }
142 END_TEST
143 
144 
START_TEST(test_SBML_parseL3Formula_6)145 START_TEST (test_SBML_parseL3Formula_6)
146 {
147   ASTNode_t *r = SBML_parseL3Formula("1 + 2");
148   ASTNode_t *c;
149 
150 
151 
152   fail_unless( ASTNode_getType       (r) == AST_PLUS, NULL );
153   fail_unless( ASTNode_getCharacter  (r) == '+', NULL );
154   fail_unless( ASTNode_getNumChildren(r) == 2  , NULL );
155 
156   c = ASTNode_getLeftChild(r);
157 
158   fail_unless( ASTNode_getType       (c) == AST_INTEGER, NULL );
159   fail_unless( ASTNode_getInteger    (c) == 1, NULL );
160   fail_unless( ASTNode_getNumChildren(c) == 0, NULL );
161 
162   c = ASTNode_getRightChild(r);
163 
164   fail_unless( ASTNode_getType       (c) == AST_INTEGER, NULL );
165   fail_unless( ASTNode_getInteger    (c) == 2, NULL );
166   fail_unless( ASTNode_getNumChildren(c) == 0, NULL );
167 
168   ASTNode_free(r);
169   // SBML_deleteL3Parser();
170 }
171 END_TEST
172 
173 
START_TEST(test_SBML_parseL3Formula_7)174 START_TEST (test_SBML_parseL3Formula_7)
175 {
176   ASTNode_t *r = SBML_parseL3Formula("1 + 2 * 3");
177   ASTNode_t *c;
178 
179 
180 
181   fail_unless( ASTNode_getType       (r) == AST_PLUS, NULL );
182   fail_unless( ASTNode_getCharacter  (r) == '+', NULL );
183   fail_unless( ASTNode_getNumChildren(r) == 2  , NULL );
184 
185   c = ASTNode_getLeftChild(r);
186 
187   fail_unless( ASTNode_getType       (c) == AST_INTEGER, NULL );
188   fail_unless( ASTNode_getInteger    (c) == 1, NULL );
189   fail_unless( ASTNode_getNumChildren(c) == 0, NULL );
190 
191   c = ASTNode_getRightChild(r);
192 
193   fail_unless( ASTNode_getType       (c) == AST_TIMES, NULL );
194   fail_unless( ASTNode_getCharacter  (c) == '*', NULL );
195   fail_unless( ASTNode_getNumChildren(c) == 2  , NULL );
196 
197   c = ASTNode_getLeftChild(c);
198 
199   fail_unless( ASTNode_getType       (c) == AST_INTEGER, NULL );
200   fail_unless( ASTNode_getInteger    (c) == 2, NULL );
201   fail_unless( ASTNode_getNumChildren(c) == 0, NULL );
202 
203   c = ASTNode_getRightChild( ASTNode_getRightChild(r) );
204 
205   fail_unless( ASTNode_getType       (c) == AST_INTEGER, NULL );
206   fail_unless( ASTNode_getInteger    (c) == 3, NULL );
207   fail_unless( ASTNode_getNumChildren(c) == 0, NULL );
208 
209   ASTNode_free(r);
210   // SBML_deleteL3Parser();
211 }
212 END_TEST
213 
214 
START_TEST(test_SBML_parseL3Formula_8)215 START_TEST (test_SBML_parseL3Formula_8)
216 {
217   ASTNode_t *r = SBML_parseL3Formula("(1 - 2) * 3");
218   ASTNode_t *c;
219 
220 
221   fail_unless( ASTNode_getType       (r) == AST_TIMES, NULL );
222   fail_unless( ASTNode_getCharacter  (r) == '*', NULL );
223   fail_unless( ASTNode_getNumChildren(r) == 2  , NULL );
224 
225   c = ASTNode_getLeftChild(r);
226 
227   fail_unless( ASTNode_getType       (c) == AST_MINUS, NULL );
228   fail_unless( ASTNode_getCharacter  (c) == '-', NULL );
229   fail_unless( ASTNode_getNumChildren(c) == 2, NULL );
230 
231   c = ASTNode_getRightChild(r);
232 
233   fail_unless( ASTNode_getType       (c) == AST_INTEGER, NULL );
234   fail_unless( ASTNode_getInteger    (c) == 3, NULL );
235   fail_unless( ASTNode_getNumChildren(c) == 0, NULL );
236 
237   c = ASTNode_getLeftChild( ASTNode_getLeftChild(r) );
238 
239   fail_unless( ASTNode_getType       (c) == AST_INTEGER, NULL );
240   fail_unless( ASTNode_getInteger    (c) == 1, NULL );
241   fail_unless( ASTNode_getNumChildren(c) == 0, NULL );
242 
243   c = ASTNode_getRightChild( ASTNode_getLeftChild(r) );
244 
245   fail_unless( ASTNode_getType       (c) == AST_INTEGER, NULL );
246   fail_unless( ASTNode_getInteger   (c)  == 2, NULL );
247   fail_unless( ASTNode_getNumChildren(c) == 0, NULL );
248 
249   ASTNode_free(r);
250   // SBML_deleteL3Parser();
251 }
252 END_TEST
253 
254 
START_TEST(test_SBML_parseL3Formula_9)255 START_TEST (test_SBML_parseL3Formula_9)
256 {
257   ASTNode_t *r = SBML_parseL3Formula("1 + -2 / 3");
258   ASTNode_t *c;
259 
260 
261   fail_unless( ASTNode_getType       (r) == AST_PLUS, NULL );
262   fail_unless( ASTNode_getCharacter  (r) == '+', NULL );
263   fail_unless( ASTNode_getNumChildren(r) == 2  , NULL );
264 
265   c = ASTNode_getLeftChild(r);
266 
267   fail_unless( ASTNode_getType       (c) == AST_INTEGER, NULL );
268   fail_unless( ASTNode_getInteger    (c) == 1, NULL );
269   fail_unless( ASTNode_getNumChildren(c) == 0, NULL );
270 
271   c = ASTNode_getRightChild(r);
272 
273   fail_unless( ASTNode_getType       (c) == AST_DIVIDE, NULL );
274   fail_unless( ASTNode_getCharacter  (c) == '/', NULL );
275   fail_unless( ASTNode_getNumChildren(c) == 2  , NULL );
276 
277   c = ASTNode_getLeftChild(c);
278 
279   fail_unless( ASTNode_getType       (c) == AST_MINUS, NULL );
280   fail_unless( ASTNode_getCharacter  (c) == '-', NULL );
281   fail_unless( ASTNode_getNumChildren(c) ==  1, NULL );
282 
283   c = ASTNode_getLeftChild(c);
284 
285   fail_unless( ASTNode_getType       (c) == AST_INTEGER, NULL );
286   fail_unless( ASTNode_getInteger    (c) == 2, NULL );
287   fail_unless( ASTNode_getNumChildren(c) == 0, NULL );
288 
289   c = ASTNode_getRightChild( ASTNode_getRightChild(r) );
290 
291   fail_unless( ASTNode_getType       (c) == AST_INTEGER, NULL );
292   fail_unless( ASTNode_getInteger    (c) == 3, NULL );
293   fail_unless( ASTNode_getNumChildren(c) == 0, NULL );
294 
295   ASTNode_free(r);
296   // SBML_deleteL3Parser();
297 }
298 END_TEST
299 
300 
START_TEST(test_SBML_parseL3Formula_10)301 START_TEST (test_SBML_parseL3Formula_10)
302 {
303   ASTNode_t *r = SBML_parseL3Formula("1 + -2e100 / 3");
304   ASTNode_t *c;
305 
306 
307   fail_unless( ASTNode_getType       (r) == AST_PLUS, NULL );
308   fail_unless( ASTNode_getCharacter  (r) == '+', NULL );
309   fail_unless( ASTNode_getNumChildren(r) == 2  , NULL );
310 
311   c = ASTNode_getLeftChild(r);
312 
313   fail_unless( ASTNode_getType       (c) == AST_INTEGER, NULL );
314   fail_unless( ASTNode_getInteger    (c) == 1, NULL );
315   fail_unless( ASTNode_getNumChildren(c) == 0, NULL );
316 
317   c = ASTNode_getRightChild(r);
318 
319   fail_unless( ASTNode_getType       (c) == AST_DIVIDE, NULL );
320   fail_unless( ASTNode_getCharacter  (c) == '/', NULL );
321   fail_unless( ASTNode_getNumChildren(c) == 2  , NULL );
322 
323   c = ASTNode_getLeftChild(c);
324 
325   fail_unless( ASTNode_getType       (c) == AST_MINUS, NULL );
326   fail_unless( ASTNode_getCharacter  (c) == '-', NULL );
327   fail_unless( ASTNode_getNumChildren(c) ==  1, NULL );
328 
329   c = ASTNode_getLeftChild(c);
330 
331   fail_unless( ASTNode_getType       (c) == AST_REAL_E, NULL );
332   fail_unless( ASTNode_getMantissa   (c) ==   2, NULL );
333   fail_unless( ASTNode_getExponent   (c) == 100, NULL );
334   fail_unless( ASTNode_getNumChildren(c) ==   0, NULL );
335 
336   c = ASTNode_getRightChild( ASTNode_getRightChild(r) );
337 
338   fail_unless( ASTNode_getType       (c) == AST_INTEGER, NULL );
339   fail_unless( ASTNode_getInteger    (c) == 3, NULL );
340   fail_unless( ASTNode_getNumChildren(c) == 0, NULL );
341 
342   ASTNode_free(r);
343   // SBML_deleteL3Parser();
344 }
345 END_TEST
346 
347 
START_TEST(test_SBML_parseL3Formula_11)348 START_TEST (test_SBML_parseL3Formula_11)
349 {
350   ASTNode_t *r = SBML_parseL3Formula("1 - -foo / 3");
351   ASTNode_t *c;
352 
353 
354 
355   fail_unless( ASTNode_getType       (r) == AST_MINUS, NULL );
356   fail_unless( ASTNode_getCharacter  (r) == '-', NULL );
357   fail_unless( ASTNode_getNumChildren(r) == 2  , NULL );
358 
359   c = ASTNode_getLeftChild(r);
360 
361   fail_unless( ASTNode_getType       (c) == AST_INTEGER, NULL );
362   fail_unless( ASTNode_getInteger    (c) == 1, NULL );
363   fail_unless( ASTNode_getNumChildren(c) == 0, NULL );
364 
365   c = ASTNode_getRightChild(r);
366 
367   fail_unless( ASTNode_getType       (c) == AST_DIVIDE, NULL );
368   fail_unless( ASTNode_getCharacter  (c) == '/', NULL );
369   fail_unless( ASTNode_getNumChildren(c) == 2, NULL );
370 
371   c = ASTNode_getLeftChild( ASTNode_getRightChild(r) );
372 
373   fail_unless( ASTNode_getType       (c) == AST_MINUS, NULL );
374   fail_unless( ASTNode_getCharacter  (c) == '-', NULL );
375   fail_unless( ASTNode_getNumChildren(c) == 1  , NULL );
376 
377   c = ASTNode_getLeftChild( ASTNode_getLeftChild( ASTNode_getRightChild(r) ) );
378 
379   fail_unless( ASTNode_getType(c) == AST_NAME     , NULL );
380   fail_unless( !strcmp(ASTNode_getName(c), "foo") , NULL );
381   fail_unless( ASTNode_getNumChildren(c) == 0     , NULL );
382 
383   c = ASTNode_getRightChild( ASTNode_getRightChild(r) );
384 
385   fail_unless( ASTNode_getType       (c) == AST_INTEGER, NULL );
386   fail_unless( ASTNode_getInteger    (c) == 3, NULL );
387   fail_unless( ASTNode_getNumChildren(c) == 0, NULL );
388 
389   ASTNode_free(r);
390   // SBML_deleteL3Parser();
391 }
392 END_TEST
393 
394 
START_TEST(test_SBML_parseL3Formula_12)395 START_TEST (test_SBML_parseL3Formula_12)
396 {
397   ASTNode_t *r = SBML_parseL3Formula("2 * foo^bar + 3.0");
398   ASTNode_t *c;
399 
400 
401   fail_unless( ASTNode_getType       (r) == AST_PLUS, NULL );
402   fail_unless( ASTNode_getCharacter  (r) == '+', NULL );
403   fail_unless( ASTNode_getNumChildren(r) == 2  , NULL );
404 
405   c = ASTNode_getLeftChild(r);
406 
407   fail_unless( ASTNode_getType       (c) == AST_TIMES, NULL );
408   fail_unless( ASTNode_getCharacter  (c) == '*', NULL );
409   fail_unless( ASTNode_getNumChildren(c) == 2  , NULL );
410 
411   c = ASTNode_getRightChild(r);
412 
413   fail_unless( ASTNode_getType       (c) == AST_REAL, NULL );
414   fail_unless( ASTNode_getReal       (c) == 3.0, NULL );
415   fail_unless( ASTNode_getNumChildren(c) == 0  , NULL );
416 
417   c = ASTNode_getLeftChild( ASTNode_getLeftChild(r) );
418 
419   fail_unless( ASTNode_getType       (c) == AST_INTEGER, NULL );
420   fail_unless( ASTNode_getInteger    (c) == 2, NULL );
421   fail_unless( ASTNode_getNumChildren(c) == 0, NULL );
422 
423   c = ASTNode_getRightChild( ASTNode_getLeftChild(r) );
424 
425   fail_unless( ASTNode_getType       (c) == AST_POWER, NULL );
426   fail_unless( ASTNode_getCharacter  (c) == '^', NULL );
427   fail_unless( ASTNode_getNumChildren(c) == 2  , NULL );
428 
429   c = ASTNode_getLeftChild( ASTNode_getRightChild( ASTNode_getLeftChild(r) ) );
430 
431   fail_unless( ASTNode_getType(c) == AST_NAME     , NULL );
432   fail_unless( !strcmp(ASTNode_getName(c), "foo") , NULL );
433   fail_unless( ASTNode_getNumChildren(c) == 0     , NULL );
434 
435   c = ASTNode_getRightChild( ASTNode_getRightChild( ASTNode_getLeftChild(r) ) );
436 
437   fail_unless( ASTNode_getType(c) == AST_NAME     , NULL );
438   fail_unless( !strcmp(ASTNode_getName(c), "bar") , NULL );
439   fail_unless( ASTNode_getNumChildren(c) == 0     , NULL );
440 
441   ASTNode_free(r);
442   // SBML_deleteL3Parser();
443 }
444 END_TEST
445 
446 
START_TEST(test_SBML_parseL3Formula_13)447 START_TEST (test_SBML_parseL3Formula_13)
448 {
449   ASTNode_t *r = SBML_parseL3Formula("foo()");
450 
451 
452   fail_unless( ASTNode_getType(r) == AST_FUNCTION , NULL );
453   fail_unless( !strcmp(ASTNode_getName(r), "foo") , NULL );
454   fail_unless( ASTNode_getNumChildren(r) == 0     , NULL );
455 
456   ASTNode_free(r);
457   // SBML_deleteL3Parser();
458 }
459 END_TEST
460 
461 
START_TEST(test_SBML_parseL3Formula_14)462 START_TEST (test_SBML_parseL3Formula_14)
463 {
464   ASTNode_t *r = SBML_parseL3Formula("foo(1)");
465   ASTNode_t *c;
466 
467 
468   fail_unless( ASTNode_getType(r) == AST_FUNCTION , NULL );
469   fail_unless( !strcmp(ASTNode_getName(r), "foo") , NULL );
470   fail_unless( ASTNode_getNumChildren(r) == 1     , NULL );
471 
472   c = ASTNode_getLeftChild(r);
473 
474   fail_unless( ASTNode_getType       (c) == AST_INTEGER, NULL );
475   fail_unless( ASTNode_getInteger    (c) == 1, NULL );
476   fail_unless( ASTNode_getNumChildren(c) == 0, NULL );
477 
478   ASTNode_free(r);
479   // SBML_deleteL3Parser();
480 }
481 END_TEST
482 
483 
START_TEST(test_SBML_parseL3Formula_15)484 START_TEST (test_SBML_parseL3Formula_15)
485 {
486   ASTNode_t *r = SBML_parseL3Formula("foo(1, bar)");
487   ASTNode_t *c;
488 
489 
490   fail_unless( ASTNode_getType(r) == AST_FUNCTION , NULL );
491   fail_unless( !strcmp(ASTNode_getName(r), "foo") , NULL );
492   fail_unless( ASTNode_getNumChildren(r) == 2     , NULL );
493 
494   c = ASTNode_getLeftChild(r);
495 
496   fail_unless( ASTNode_getType       (c) == AST_INTEGER, NULL );
497   fail_unless( ASTNode_getInteger    (c) == 1, NULL );
498   fail_unless( ASTNode_getNumChildren(c) == 0, NULL );
499 
500   c = ASTNode_getRightChild(r);
501 
502   fail_unless( ASTNode_getType(c) == AST_NAME     , NULL );
503   fail_unless( !strcmp(ASTNode_getName(c), "bar") , NULL );
504   fail_unless( ASTNode_getNumChildren(c) == 0     , NULL );
505 
506   ASTNode_free(r);
507   // SBML_deleteL3Parser();
508 }
509 END_TEST
510 
511 
START_TEST(test_SBML_parseL3Formula_16)512 START_TEST (test_SBML_parseL3Formula_16)
513 {
514   ASTNode_t *r = SBML_parseL3Formula("foo(1, bar, 2^-3)");
515   ASTNode_t *c;
516 
517 
518   fail_unless( ASTNode_getType(r) == AST_FUNCTION , NULL );
519   fail_unless( !strcmp(ASTNode_getName(r), "foo") , NULL );
520   fail_unless( ASTNode_getNumChildren(r) == 3     , NULL );
521 
522   c = ASTNode_getChild(r, 0);
523 
524   fail_unless( ASTNode_getType       (c) == AST_INTEGER, NULL );
525   fail_unless( ASTNode_getInteger    (c) == 1, NULL );
526   fail_unless( ASTNode_getNumChildren(c) == 0, NULL );
527 
528   c = ASTNode_getChild(r, 1);
529 
530   fail_unless( ASTNode_getType(c) == AST_NAME     , NULL );
531   fail_unless( !strcmp(ASTNode_getName(c), "bar") , NULL );
532   fail_unless( ASTNode_getNumChildren(c) == 0     , NULL );
533 
534   c = ASTNode_getChild(r, 2);
535 
536   fail_unless( ASTNode_getType       (c) == AST_POWER, NULL );
537   fail_unless( ASTNode_getCharacter  (c) == '^', NULL );
538   fail_unless( ASTNode_getNumChildren(c) == 2  , NULL );
539 
540   c = ASTNode_getLeftChild( ASTNode_getChild(r, 2) );
541 
542   fail_unless( ASTNode_getType       (c) == AST_INTEGER, NULL );
543   fail_unless( ASTNode_getInteger    (c) == 2, NULL );
544   fail_unless( ASTNode_getNumChildren(c) == 0, NULL );
545 
546   c = ASTNode_getRightChild( ASTNode_getChild(r, 2) );
547 
548   fail_unless( ASTNode_getType       (c) == AST_MINUS, NULL );
549   fail_unless( ASTNode_getCharacter  (c) == '-', NULL );
550   fail_unless( ASTNode_getNumChildren(c) ==  1, NULL );
551 
552   c = ASTNode_getLeftChild(c);
553 
554   fail_unless( ASTNode_getType       (c) == AST_INTEGER, NULL );
555   fail_unless( ASTNode_getInteger    (c) == 3, NULL );
556   fail_unless( ASTNode_getNumChildren(c) == 0 , NULL );
557 
558   ASTNode_free(r);
559   // SBML_deleteL3Parser();
560 }
561 END_TEST
562 
563 
START_TEST(test_SBML_parseL3Formula_17)564 START_TEST (test_SBML_parseL3Formula_17)
565 {
566   ASTNode_t *r = SBML_parseL3Formula("1//1");
567   char * error;
568 
569   fail_unless(r == NULL, NULL);
570   error = SBML_getLastParseL3Error();
571   fail_unless( !strcmp(error, "Error when parsing input '1//1' at position 3:  syntax error, unexpected '/'"), NULL);
572   safe_free(error);
573   // SBML_deleteL3Parser();
574 }
575 END_TEST
576 
577 
START_TEST(test_SBML_parseL3Formula_18)578 START_TEST (test_SBML_parseL3Formula_18)
579 {
580   ASTNode_t *r = SBML_parseL3Formula("1+2*3 4");
581   char * error;
582 
583   fail_unless(r == NULL, NULL);
584   error = SBML_getLastParseL3Error();
585   fail_unless( !strcmp(error, "Error when parsing input '1+2*3 4' at position 7:  syntax error, unexpected integer"), NULL);
586   safe_free(error);
587   // SBML_deleteL3Parser();
588 }
589 END_TEST
590 
591 
START_TEST(test_SBML_parseL3Formula_negInf)592 START_TEST (test_SBML_parseL3Formula_negInf)
593 {
594   ASTNode_t *r = SBML_parseL3Formula("-inf");
595 
596   fail_unless( ASTNode_getType       (r) == AST_MINUS, NULL );
597   fail_unless( ASTNode_getCharacter  (r) == '-', NULL );
598   fail_unless( ASTNode_getNumChildren(r) ==  1, NULL );
599 
600   ASTNode_t *c = ASTNode_getLeftChild(r);
601 
602 
603   fail_unless( ASTNode_getType(c)             == AST_REAL, NULL );
604   fail_unless( util_isInf(ASTNode_getReal(c)) ==  1, NULL );
605   fail_unless( ASTNode_getNumChildren(c)      ==  0, NULL );
606 
607   ASTNode_free(r);
608   // SBML_deleteL3Parser();
609 }
610 END_TEST
611 
612 
START_TEST(test_SBML_parseL3Formula_negZero)613 START_TEST (test_SBML_parseL3Formula_negZero)
614 {
615   ASTNode_t *r = SBML_parseL3Formula("-0.0");
616 
617   fail_unless( ASTNode_getType       (r) == AST_MINUS, NULL );
618   fail_unless( ASTNode_getCharacter  (r) == '-', NULL );
619   fail_unless( ASTNode_getNumChildren(r) ==  1, NULL );
620 
621   ASTNode_t *c = ASTNode_getLeftChild(r);
622 
623   fail_unless( ASTNode_getType(c)                 == AST_REAL, NULL );
624   fail_unless( util_isNegZero(ASTNode_getReal(c)) == 0, NULL );
625   fail_unless( ASTNode_getReal(c)                 == 0, NULL );
626   fail_unless( ASTNode_getNumChildren(c)          == 0, NULL );
627 
628   ASTNode_free(r);
629   // SBML_deleteL3Parser();
630 }
631 END_TEST
632 
START_TEST(test_SBML_parseL3Formula_e1)633 START_TEST (test_SBML_parseL3Formula_e1)
634 {
635   ASTNode_t *r = SBML_parseL3Formula("2.001e+5");
636 
637 
638   fail_unless( ASTNode_getType       (r) == AST_REAL_E, NULL );
639   fail_unless( ASTNode_getMantissa   (r) == 2.001, NULL );
640   fail_unless( ASTNode_getExponent   (r) ==   5, NULL );
641   fail_unless( ASTNode_getNumChildren(r) ==   0, NULL );
642 
643   ASTNode_free(r);
644   // SBML_deleteL3Parser();
645 }
646 END_TEST
647 
648 
START_TEST(test_SBML_parseL3Formula_e2)649 START_TEST (test_SBML_parseL3Formula_e2)
650 {
651   ASTNode_t *r = SBML_parseL3Formula(".001e+5");
652 
653 
654   fail_unless( ASTNode_getType       (r) == AST_REAL_E, NULL );
655   fail_unless( ASTNode_getMantissa   (r) == .001, NULL );
656   fail_unless( ASTNode_getExponent   (r) ==   5, NULL );
657   fail_unless( ASTNode_getNumChildren(r) ==   0, NULL );
658 
659   ASTNode_free(r);
660   // SBML_deleteL3Parser();
661 }
662 END_TEST
663 
664 
START_TEST(test_SBML_parseL3Formula_e3)665 START_TEST (test_SBML_parseL3Formula_e3)
666 {
667   ASTNode_t *r = SBML_parseL3Formula(".001e-5");
668 
669 
670   fail_unless( ASTNode_getType       (r) == AST_REAL_E, NULL );
671   fail_unless( ASTNode_getMantissa   (r) == .001, NULL );
672   fail_unless( ASTNode_getExponent   (r) ==  -5, NULL );
673   fail_unless( ASTNode_getNumChildren(r) ==   0, NULL );
674 
675   ASTNode_free(r);
676   // SBML_deleteL3Parser();
677 }
678 END_TEST
679 
680 
START_TEST(test_SBML_parseL3Formula_e4)681 START_TEST (test_SBML_parseL3Formula_e4)
682 {
683   ASTNode_t *r = SBML_parseL3Formula("2.e-005");
684 
685 
686   fail_unless( ASTNode_getType       (r) == AST_REAL_E, NULL );
687   fail_unless( ASTNode_getMantissa   (r) ==   2, NULL );
688   fail_unless( ASTNode_getExponent   (r) ==  -5, NULL );
689   fail_unless( ASTNode_getNumChildren(r) ==   0, NULL );
690 
691   ASTNode_free(r);
692   // SBML_deleteL3Parser();
693 }
694 END_TEST
695 
696 
START_TEST(test_SBML_parseL3Formula_e5)697 START_TEST (test_SBML_parseL3Formula_e5)
698 {
699   ASTNode_t *r = SBML_parseL3Formula(".e+5");
700   char * error;
701 
702   fail_unless(r == NULL, NULL);
703   error = SBML_getLastParseL3Error();
704   fail_unless( !strcmp(error, "Error when parsing input '.e+5' at position 1:  syntax error, unexpected $undefined"), NULL);
705 
706   ASTNode_free(r);
707   safe_free(error);
708   // SBML_deleteL3Parser();
709 }
710 END_TEST
711 
712 
START_TEST(test_SBML_parseL3Formula_rational1)713 START_TEST (test_SBML_parseL3Formula_rational1)
714 {
715   ASTNode_t *r = SBML_parseL3Formula("(3/4)");
716 
717   fail_unless( ASTNode_getType       (r) == AST_RATIONAL, NULL );
718   fail_unless( ASTNode_getNumerator  (r) ==   3, NULL );
719   fail_unless( ASTNode_getDenominator(r) ==   4, NULL );
720   fail_unless( ASTNode_getReal       (r) ==   0.75, NULL );
721   fail_unless( ASTNode_getNumChildren(r) ==   0, NULL );
722 
723   ASTNode_free(r);
724   // SBML_deleteL3Parser();
725 }
726 END_TEST
727 
728 
START_TEST(test_SBML_parseL3Formula_rational2)729 START_TEST (test_SBML_parseL3Formula_rational2)
730 {
731   ASTNode_t *r = SBML_parseL3Formula("(3/4) mL");
732   char * units = ASTNode_getUnits(r);
733 
734   fail_unless( ASTNode_getType       (r) == AST_RATIONAL, NULL );
735   fail_unless( ASTNode_getNumerator  (r) ==   3, NULL );
736   fail_unless( ASTNode_getDenominator(r) ==   4, NULL );
737   fail_unless( ASTNode_getReal       (r) ==   0.75, NULL );
738   fail_unless( !strcmp(units, "mL"), NULL );
739   fail_unless( ASTNode_getNumChildren(r) ==   0, NULL );
740 
741   ASTNode_free(r);
742   safe_free(units);
743   // SBML_deleteL3Parser();
744 }
745 END_TEST
746 
747 
START_TEST(test_SBML_parseL3Formula_rational3)748 START_TEST (test_SBML_parseL3Formula_rational3)
749 {
750   ASTNode_t *r = SBML_parseL3Formula("3/4");
751 
752   fail_unless( ASTNode_getType       (r) == AST_DIVIDE, NULL );
753   fail_unless( ASTNode_getCharacter  (r) == '/', NULL );
754   fail_unless( ASTNode_getNumChildren(r) == 2  , NULL );
755 
756   ASTNode_t *c = ASTNode_getLeftChild(r);
757 
758   fail_unless( ASTNode_getType       (c) == AST_INTEGER, NULL );
759   fail_unless( ASTNode_getInteger    (c) == 3, NULL );
760   fail_unless( ASTNode_getNumChildren(c) == 0, NULL );
761 
762   c = ASTNode_getRightChild(r);
763 
764   fail_unless( ASTNode_getType       (c) == AST_INTEGER, NULL );
765   fail_unless( ASTNode_getInteger    (c) == 4, NULL );
766   fail_unless( ASTNode_getNumChildren(c) == 0, NULL );
767 
768   ASTNode_free(r);
769   // SBML_deleteL3Parser();
770 }
771 END_TEST
772 
773 
START_TEST(test_SBML_parseL3Formula_rational4)774 START_TEST (test_SBML_parseL3Formula_rational4)
775 {
776   ASTNode_t *r = SBML_parseL3Formula("(3/x)");
777 
778   fail_unless( ASTNode_getType       (r) == AST_DIVIDE, NULL );
779   fail_unless( ASTNode_getCharacter  (r) == '/', NULL );
780   fail_unless( ASTNode_getNumChildren(r) == 2  , NULL );
781 
782   ASTNode_t *c = ASTNode_getLeftChild(r);
783 
784   fail_unless( ASTNode_getType       (c) == AST_INTEGER, NULL );
785   fail_unless( ASTNode_getInteger    (c) == 3, NULL );
786   fail_unless( ASTNode_getNumChildren(c) == 0, NULL );
787 
788   c = ASTNode_getRightChild(r);
789 
790   fail_unless( ASTNode_getType       (c) == AST_NAME, NULL );
791   fail_unless( !strcmp(ASTNode_getName(c), "x"), NULL );
792   fail_unless( ASTNode_getNumChildren(c) == 0, NULL );
793 
794   ASTNode_free(r);
795   // SBML_deleteL3Parser();
796 }
797 END_TEST
798 
799 
START_TEST(test_SBML_parseL3Formula_rational5)800 START_TEST (test_SBML_parseL3Formula_rational5)
801 {
802   ASTNode_t *r = SBML_parseL3Formula("(3/4.4)");
803 
804   fail_unless( ASTNode_getType       (r) == AST_DIVIDE, NULL );
805   fail_unless( ASTNode_getCharacter  (r) == '/', NULL );
806   fail_unless( ASTNode_getNumChildren(r) == 2  , NULL );
807 
808   ASTNode_t *c = ASTNode_getLeftChild(r);
809 
810   fail_unless( ASTNode_getType       (c) == AST_INTEGER, NULL );
811   fail_unless( ASTNode_getInteger    (c) == 3, NULL );
812   fail_unless( ASTNode_getNumChildren(c) == 0, NULL );
813 
814   c = ASTNode_getRightChild(r);
815 
816   fail_unless( ASTNode_getType       (c) == AST_REAL, NULL );
817   fail_unless( ASTNode_getReal       (c) == 4.4, NULL );
818   fail_unless( ASTNode_getNumChildren(c) == 0, NULL );
819 
820   ASTNode_free(r);
821   // SBML_deleteL3Parser();
822 }
823 END_TEST
824 
825 
START_TEST(test_SBML_parseL3Formula_rational6)826 START_TEST (test_SBML_parseL3Formula_rational6)
827 {
828   ASTNode_t *r = SBML_parseL3Formula("3/4 ml");
829   char * units;
830 
831   fail_unless( ASTNode_getType       (r) == AST_DIVIDE, NULL );
832   fail_unless( ASTNode_getCharacter  (r) == '/', NULL );
833   fail_unless( ASTNode_getNumChildren(r) == 2  , NULL );
834 
835   ASTNode_t *c = ASTNode_getLeftChild(r);
836 
837   fail_unless( ASTNode_getType       (c) == AST_INTEGER, NULL );
838   fail_unless( ASTNode_getInteger    (c) == 3, NULL );
839   fail_unless( ASTNode_getNumChildren(c) == 0, NULL );
840 
841   c = ASTNode_getRightChild(r);
842 
843   units = ASTNode_getUnits(c);
844   fail_unless( ASTNode_getType       (c) == AST_INTEGER, NULL );
845   fail_unless( ASTNode_getInteger    (c) == 4, NULL );
846   fail_unless( !strcmp(units, "ml"), NULL );
847   fail_unless( ASTNode_getNumChildren(c) == 0, NULL );
848 
849   ASTNode_free(r);
850   safe_free(units);
851   // SBML_deleteL3Parser();
852 }
853 END_TEST
854 
855 
856 
START_TEST(test_SBML_parseL3Formula_rational7)857 START_TEST (test_SBML_parseL3Formula_rational7)
858 {
859   ASTNode_t *r = SBML_parseL3Formula("(3/4.4) ml");
860   char * error;
861 
862   fail_unless(r == NULL, NULL);
863   error = SBML_getLastParseL3Error();
864   fail_unless( !strcmp(error, "Error when parsing input '(3/4.4) ml' at position 10:  syntax error, unexpected element name"), NULL );
865   safe_free(error);
866   // SBML_deleteL3Parser();
867 }
868 END_TEST
869 
870 
START_TEST(test_SBML_parseL3Formula_constants1)871 START_TEST (test_SBML_parseL3Formula_constants1)
872 {
873   ASTNode_t *r = SBML_parseL3Formula("true");
874   fail_unless( ASTNode_getType       (r) == AST_CONSTANT_TRUE, NULL );
875   fail_unless( ASTNode_getNumChildren(r) ==   0, NULL );
876   ASTNode_free(r);
877   // SBML_deleteL3Parser();
878 }
879 END_TEST
880 
881 
START_TEST(test_SBML_parseL3Formula_constants2)882 START_TEST (test_SBML_parseL3Formula_constants2)
883 {
884   ASTNode_t *r = SBML_parseL3Formula("false");
885   fail_unless( ASTNode_getType       (r) == AST_CONSTANT_FALSE, NULL );
886   fail_unless( ASTNode_getNumChildren(r) ==   0, NULL );
887   ASTNode_free(r);
888   // SBML_deleteL3Parser();
889 }
890 END_TEST
891 
892 
START_TEST(test_SBML_parseL3Formula_constants3)893 START_TEST (test_SBML_parseL3Formula_constants3)
894 {
895   ASTNode_t *r = SBML_parseL3Formula("pi");
896   fail_unless( ASTNode_getType       (r) == AST_CONSTANT_PI, NULL );
897   fail_unless( ASTNode_getNumChildren(r) ==   0, NULL );
898   ASTNode_free(r);
899   // SBML_deleteL3Parser();
900 }
901 END_TEST
902 
903 
START_TEST(test_SBML_parseL3Formula_constants4)904 START_TEST (test_SBML_parseL3Formula_constants4)
905 {
906   ASTNode_t *r = SBML_parseL3Formula("exponentiale");
907   fail_unless( ASTNode_getType       (r) == AST_CONSTANT_E, NULL );
908   fail_unless( ASTNode_getNumChildren(r) ==   0, NULL );
909   ASTNode_free(r);
910   // SBML_deleteL3Parser();
911 }
912 END_TEST
913 
914 
START_TEST(test_SBML_parseL3Formula_constants5)915 START_TEST (test_SBML_parseL3Formula_constants5)
916 {
917   ASTNode_t *r = SBML_parseL3Formula("avogadro");
918   fail_unless( ASTNode_getType       (r) == AST_NAME_AVOGADRO, NULL );
919   fail_unless( ASTNode_getNumChildren(r) ==   0, NULL );
920   ASTNode_free(r);
921   // SBML_deleteL3Parser();
922 }
923 END_TEST
924 
925 
START_TEST(test_SBML_parseL3Formula_constants6)926 START_TEST (test_SBML_parseL3Formula_constants6)
927 {
928   ASTNode_t *r = SBML_parseL3Formula("time");
929   fail_unless( ASTNode_getType       (r) == AST_NAME_TIME, NULL );
930   fail_unless( ASTNode_getNumChildren(r) ==   0, NULL );
931   ASTNode_free(r);
932   // SBML_deleteL3Parser();
933 }
934 END_TEST
935 
936 
START_TEST(test_SBML_parseL3Formula_constants7)937 START_TEST (test_SBML_parseL3Formula_constants7)
938 {
939   ASTNode_t *r = SBML_parseL3Formula("inf");
940   fail_unless( ASTNode_getType(r)             == AST_REAL, NULL );
941   fail_unless( util_isInf(ASTNode_getReal(r)) ==  1, NULL );
942   fail_unless( ASTNode_getNumChildren(r)      ==  0, NULL );
943   ASTNode_free(r);
944   // SBML_deleteL3Parser();
945 }
946 END_TEST
947 
948 
START_TEST(test_SBML_parseL3Formula_constants8)949 START_TEST (test_SBML_parseL3Formula_constants8)
950 {
951   ASTNode_t *r = SBML_parseL3Formula("infinity");
952   fail_unless( ASTNode_getType(r)             == AST_REAL, NULL );
953   fail_unless( util_isInf(ASTNode_getReal(r)) ==  1, NULL );
954   fail_unless( ASTNode_getNumChildren(r)      ==  0, NULL );
955   ASTNode_free(r);
956   // SBML_deleteL3Parser();
957 }
958 END_TEST
959 
960 
START_TEST(test_SBML_parseL3Formula_constants9)961 START_TEST (test_SBML_parseL3Formula_constants9)
962 {
963   ASTNode_t *r = SBML_parseL3Formula("INF");
964   fail_unless( ASTNode_getType(r)             == AST_REAL, NULL );
965   fail_unless( util_isInf(ASTNode_getReal(r)) ==  1, NULL );
966   fail_unless( ASTNode_getNumChildren(r)      ==  0, NULL );
967   ASTNode_free(r);
968   // SBML_deleteL3Parser();
969 }
970 END_TEST
971 
972 
START_TEST(test_SBML_parseL3Formula_constants10)973 START_TEST (test_SBML_parseL3Formula_constants10)
974 {
975   ASTNode_t *r = SBML_parseL3Formula("notanumber");
976   fail_unless( ASTNode_getType(r)        == AST_REAL, NULL );
977   fail_unless( util_isNaN(ASTNode_getReal(r)) ==  1, NULL );
978   fail_unless( ASTNode_getNumChildren(r) ==  0, NULL );
979   ASTNode_free(r);
980   // SBML_deleteL3Parser();
981 }
982 END_TEST
983 
984 
START_TEST(test_SBML_parseL3Formula_constants11)985 START_TEST (test_SBML_parseL3Formula_constants11)
986 {
987   ASTNode_t *r = SBML_parseL3Formula("nan");
988   fail_unless( ASTNode_getType(r)        == AST_REAL, NULL );
989   fail_unless( util_isNaN(ASTNode_getReal(r)) ==  1, NULL );
990   fail_unless( ASTNode_getNumChildren(r) ==  0, NULL );
991   ASTNode_free(r);
992   // SBML_deleteL3Parser();
993 }
994 END_TEST
995 
996 
START_TEST(test_SBML_parseL3Formula_constants12)997 START_TEST (test_SBML_parseL3Formula_constants12)
998 {
999   ASTNode_t *r = SBML_parseL3Formula("NaN");
1000   fail_unless( ASTNode_getType(r)        == AST_REAL, NULL );
1001   fail_unless( util_isNaN(ASTNode_getReal(r)) ==  1, NULL );
1002   fail_unless( ASTNode_getNumChildren(r) ==  0, NULL );
1003   ASTNode_free(r);
1004   // SBML_deleteL3Parser();
1005 }
1006 END_TEST
1007 
1008 
START_TEST(test_SBML_parseL3Formula_modulo)1009 START_TEST (test_SBML_parseL3Formula_modulo)
1010 {
1011   ASTNode_t *r = SBML_parseL3Formula("x % y");
1012   fail_unless(r != NULL);
1013   char * s = SBML_formulaToString(r);
1014   //Instead of trying to go through everything individually, we'll just test the round-tripping:
1015   fail_unless( !strcmp(s, "piecewise(x - y * ceil(x / y), xor(lt(x, 0), lt(y, 0)), x - y * floor(x / y))"), NULL );
1016   ASTNode_free(r);
1017   safe_free(s);
1018 }
1019 END_TEST
1020 
1021 
START_TEST(test_SBML_parseL3Formula_modulo2)1022 START_TEST(test_SBML_parseL3Formula_modulo2)
1023 {
1024   L3ParserSettings l3ps;
1025   l3ps.setParseModuloL3v2(L3P_MODULO_IS_REM);
1026   ASTNode_t *r = SBML_parseL3FormulaWithSettings("x % y", &l3ps);
1027   fail_unless(r != NULL);
1028   char * s = SBML_formulaToString(r);
1029   //Instead of trying to go through everything individually, we'll just test the round-tripping:
1030   fail_unless(!strcmp(s, "rem(x, y)"), NULL);
1031   ASTNode_free(r);
1032   safe_free(s);
1033 }
1034 END_TEST
1035 
1036 
START_TEST(test_SBML_parseL3Formula_modulo3)1037 START_TEST(test_SBML_parseL3Formula_modulo3)
1038 {
1039   L3ParserSettings l3ps;
1040   l3ps.setParseModuloL3v2(L3P_MODULO_IS_PIECEWISE);
1041   ASTNode_t *r = SBML_parseL3FormulaWithSettings("x % y", &l3ps);
1042   fail_unless(r != NULL);
1043   char * s = SBML_formulaToString(r);
1044   //Instead of trying to go through everything individually, we'll just test the round-tripping:
1045   fail_unless(!strcmp(s, "piecewise(x - y * ceil(x / y), xor(lt(x, 0), lt(y, 0)), x - y * floor(x / y))"), NULL);
1046   ASTNode_free(r);
1047   safe_free(s);
1048 }
1049 END_TEST
1050 
1051 
START_TEST(test_SBML_parseL3Formula_l3v2functions)1052 START_TEST(test_SBML_parseL3Formula_l3v2functions)
1053 {
1054   ASTNode_t *r = SBML_parseL3Formula("max(x,y)");
1055   fail_unless(r != NULL);
1056   ASTNode_t *c;
1057 
1058 
1059   fail_unless(ASTNode_getType(r) == AST_FUNCTION_MAX, NULL);
1060   fail_unless(ASTNode_getNumChildren(r) == 2, NULL);
1061 
1062   c = ASTNode_getChild(r, 0);
1063 
1064   fail_unless(ASTNode_getType(c) == AST_NAME, NULL);
1065   fail_unless(!strcmp(ASTNode_getName(c), "x"), NULL);
1066   fail_unless(ASTNode_getNumChildren(c) == 0, NULL);
1067 
1068   c = ASTNode_getChild(r, 1);
1069 
1070   fail_unless(ASTNode_getType(c) == AST_NAME, NULL);
1071   fail_unless(!strcmp(ASTNode_getName(c), "y"), NULL);
1072   fail_unless(ASTNode_getNumChildren(c) == 0, NULL);
1073 
1074   ASTNode_free(r);
1075 }
1076 END_TEST
1077 
1078 
START_TEST(test_SBML_parseL3Formula_l3v2functions2)1079 START_TEST(test_SBML_parseL3Formula_l3v2functions2)
1080 {
1081   L3ParserSettings l3ps;
1082   l3ps.setParseL3v2Functions(L3P_PARSE_L3V2_FUNCTIONS_AS_GENERIC);
1083   ASTNode_t *r = SBML_parseL3FormulaWithSettings("max(x,y)", &l3ps);
1084   ASTNode_t *c;
1085 
1086   fail_unless(r != NULL);
1087   fail_unless(ASTNode_getType(r) == AST_FUNCTION, NULL);
1088   fail_unless(!strcmp(ASTNode_getName(r), "max"), NULL);
1089   fail_unless(ASTNode_getNumChildren(r) == 2, NULL);
1090 
1091   c = ASTNode_getChild(r, 0);
1092 
1093   fail_unless(ASTNode_getType(c) == AST_NAME, NULL);
1094   fail_unless(!strcmp(ASTNode_getName(c), "x"), NULL);
1095   fail_unless(ASTNode_getNumChildren(c) == 0, NULL);
1096 
1097   c = ASTNode_getChild(r, 1);
1098 
1099   fail_unless(ASTNode_getType(c) == AST_NAME, NULL);
1100   fail_unless(!strcmp(ASTNode_getName(c), "y"), NULL);
1101   fail_unless(ASTNode_getNumChildren(c) == 0, NULL);
1102 
1103   ASTNode_free(r);
1104 }
1105 END_TEST
1106 
1107 
START_TEST(test_SBML_parseL3Formula_l3v2functions3)1108 START_TEST(test_SBML_parseL3Formula_l3v2functions3)
1109 {
1110   L3ParserSettings l3ps;
1111   l3ps.setParseL3v2Functions(L3P_PARSE_L3V2_FUNCTIONS_DIRECTLY);
1112   ASTNode_t *r = SBML_parseL3FormulaWithSettings("max(x,y)", &l3ps);
1113   fail_unless(r != NULL);
1114   ASTNode_t *c;
1115 
1116 
1117   fail_unless(ASTNode_getType(r) == AST_FUNCTION_MAX, NULL);
1118   fail_unless(ASTNode_getNumChildren(r) == 2, NULL);
1119 
1120   c = ASTNode_getChild(r, 0);
1121 
1122   fail_unless(ASTNode_getType(c) == AST_NAME, NULL);
1123   fail_unless(!strcmp(ASTNode_getName(c), "x"), NULL);
1124   fail_unless(ASTNode_getNumChildren(c) == 0, NULL);
1125 
1126   c = ASTNode_getChild(r, 1);
1127 
1128   fail_unless(ASTNode_getType(c) == AST_NAME, NULL);
1129   fail_unless(!strcmp(ASTNode_getName(c), "y"), NULL);
1130   fail_unless(ASTNode_getNumChildren(c) == 0, NULL);
1131 
1132   ASTNode_free(r);
1133 }
1134 END_TEST
1135 
1136 
START_TEST(test_SBML_parseL3Formula_oddMathML1)1137 START_TEST (test_SBML_parseL3Formula_oddMathML1)
1138 {
1139   ASTNode_t *r = SBML_parseL3Formula("sqrt(3)");
1140 
1141   fail_unless( ASTNode_getType       (r) == AST_FUNCTION_ROOT, NULL );
1142   fail_unless( ASTNode_getNumChildren(r) == 2  , NULL );
1143 
1144   ASTNode_t *c = ASTNode_getLeftChild(r);
1145 
1146   fail_unless( ASTNode_getType       (c) == AST_INTEGER, NULL );
1147   fail_unless( ASTNode_getInteger    (c) == 2, NULL );
1148   fail_unless( ASTNode_getNumChildren(c) == 0, NULL );
1149 
1150   c = ASTNode_getRightChild(r);
1151 
1152   fail_unless( ASTNode_getType       (c) == AST_INTEGER, NULL );
1153   fail_unless( ASTNode_getInteger    (c) == 3, NULL );
1154   fail_unless( ASTNode_getNumChildren(c) == 0, NULL );
1155 
1156   ASTNode_free(r);
1157   // SBML_deleteL3Parser();
1158 }
1159 END_TEST
1160 
1161 
START_TEST(test_SBML_parseL3Formula_oddMathML2)1162 START_TEST (test_SBML_parseL3Formula_oddMathML2)
1163 {
1164   ASTNode_t *r = SBML_parseL3Formula("sqr(3)");
1165 
1166   fail_unless( ASTNode_getType       (r) == AST_FUNCTION_POWER, NULL );
1167   fail_unless( ASTNode_getNumChildren(r) == 2  , NULL );
1168 
1169   ASTNode_t *c = ASTNode_getLeftChild(r);
1170 
1171   fail_unless( ASTNode_getType       (c) == AST_INTEGER, NULL );
1172   fail_unless( ASTNode_getInteger    (c) == 3, NULL );
1173   fail_unless( ASTNode_getNumChildren(c) == 0, NULL );
1174 
1175   c = ASTNode_getRightChild(r);
1176 
1177   fail_unless( ASTNode_getType       (c) == AST_INTEGER, NULL );
1178   fail_unless( ASTNode_getInteger    (c) == 2, NULL );
1179   fail_unless( ASTNode_getNumChildren(c) == 0, NULL );
1180 
1181   ASTNode_free(r);
1182   // SBML_deleteL3Parser();
1183 }
1184 END_TEST
1185 
1186 
START_TEST(test_SBML_parseL3Formula_oddMathML3)1187 START_TEST (test_SBML_parseL3Formula_oddMathML3)
1188 {
1189   ASTNode_t *r = SBML_parseL3Formula("log10(3)");
1190 
1191   fail_unless( ASTNode_getType       (r) == AST_FUNCTION_LOG, NULL );
1192   fail_unless( ASTNode_getNumChildren(r) == 2  , NULL );
1193 
1194   ASTNode_t *c = ASTNode_getLeftChild(r);
1195 
1196   fail_unless( ASTNode_getType       (c) == AST_INTEGER, NULL );
1197   fail_unless( ASTNode_getInteger    (c) == 10, NULL );
1198   fail_unless( ASTNode_getNumChildren(c) == 0, NULL );
1199 
1200   c = ASTNode_getRightChild(r);
1201 
1202   fail_unless( ASTNode_getType       (c) == AST_INTEGER, NULL );
1203   fail_unless( ASTNode_getInteger    (c) == 3, NULL );
1204   fail_unless( ASTNode_getNumChildren(c) == 0, NULL );
1205 
1206   ASTNode_free(r);
1207   // SBML_deleteL3Parser();
1208 }
1209 END_TEST
1210 
1211 
START_TEST(test_SBML_parseL3Formula_oddMathML4)1212 START_TEST (test_SBML_parseL3Formula_oddMathML4)
1213 {
1214   ASTNode_t *r = SBML_parseL3Formula("log(4.4, 3)");
1215 
1216   fail_unless( ASTNode_getType       (r) == AST_FUNCTION_LOG, NULL );
1217   fail_unless( ASTNode_getNumChildren(r) == 2  , NULL );
1218 
1219   ASTNode_t *c = ASTNode_getLeftChild(r);
1220 
1221   fail_unless( ASTNode_getType       (c) == AST_REAL, NULL );
1222   fail_unless( ASTNode_getReal       (c) == 4.4, NULL );
1223   fail_unless( ASTNode_getNumChildren(c) == 0, NULL );
1224 
1225   c = ASTNode_getRightChild(r);
1226 
1227   fail_unless( ASTNode_getType       (c) == AST_INTEGER, NULL );
1228   fail_unless( ASTNode_getInteger    (c) == 3, NULL );
1229   fail_unless( ASTNode_getNumChildren(c) == 0, NULL );
1230 
1231   ASTNode_free(r);
1232   // SBML_deleteL3Parser();
1233 }
1234 END_TEST
1235 
1236 
START_TEST(test_SBML_parseL3Formula_oddMathML5)1237 START_TEST (test_SBML_parseL3Formula_oddMathML5)
1238 {
1239   ASTNode_t *r = SBML_parseL3Formula("root(1.1, 3)");
1240 
1241   fail_unless( ASTNode_getType       (r) == AST_FUNCTION_ROOT, NULL );
1242   fail_unless( ASTNode_getNumChildren(r) == 2  , NULL );
1243 
1244   ASTNode_t *c = ASTNode_getLeftChild(r);
1245 
1246   fail_unless( ASTNode_getType       (c) == AST_REAL, NULL );
1247   fail_unless( ASTNode_getReal       (c) == 1.1, NULL );
1248   fail_unless( ASTNode_getNumChildren(c) == 0, NULL );
1249 
1250   c = ASTNode_getRightChild(r);
1251 
1252   fail_unless( ASTNode_getType       (c) == AST_INTEGER, NULL );
1253   fail_unless( ASTNode_getInteger    (c) == 3, NULL );
1254   fail_unless( ASTNode_getNumChildren(c) == 0, NULL );
1255 
1256   ASTNode_free(r);
1257   // SBML_deleteL3Parser();
1258 }
1259 END_TEST
1260 
1261 
START_TEST(test_SBML_parseL3Formula_modelPresent1)1262 START_TEST (test_SBML_parseL3Formula_modelPresent1)
1263 {
1264   Model_t *model = Model_create(3,1);
1265   Parameter *p = Model_createParameter(model);
1266   Parameter_setId(p, "infinity");
1267   ASTNode_t *r = SBML_parseL3FormulaWithModel("infinity", model);
1268 
1269   fail_unless( ASTNode_getType       (r) == AST_NAME, NULL );
1270   fail_unless( !strcmp(ASTNode_getName(r), "infinity") , NULL );
1271   fail_unless( ASTNode_getNumChildren(r) == 0  , NULL );
1272 
1273   ASTNode_free(r);
1274   // SBML_deleteL3Parser();
1275   Model_free(model);
1276 }
1277 END_TEST
1278 
1279 
START_TEST(test_SBML_parseL3Formula_modelPresent2)1280 START_TEST (test_SBML_parseL3Formula_modelPresent2)
1281 {
1282   Model_t *model = Model_create(3,1);
1283   Species *p = Model_createSpecies(model);
1284   Species_setId(p, "true");
1285   ASTNode_t *r = SBML_parseL3FormulaWithModel("true", model);
1286 
1287   fail_unless( ASTNode_getType       (r) == AST_NAME, NULL );
1288   fail_unless( !strcmp(ASTNode_getName(r), "true") , NULL );
1289   fail_unless( ASTNode_getNumChildren(r) == 0  , NULL );
1290 
1291   ASTNode_free(r);
1292   // SBML_deleteL3Parser();
1293   Model_free(model);
1294 }
1295 END_TEST
1296 
1297 
START_TEST(test_SBML_parseL3Formula_modelPresent3)1298 START_TEST (test_SBML_parseL3Formula_modelPresent3)
1299 {
1300   Model_t *model = Model_create(3,1);
1301   Compartment *p = Model_createCompartment(model);
1302   Compartment_setId(p, "NaN");
1303   ASTNode_t *r = SBML_parseL3FormulaWithModel("NaN", model);
1304 
1305   fail_unless( ASTNode_getType       (r) == AST_NAME, NULL );
1306   fail_unless( !strcmp(ASTNode_getName(r), "NaN") , NULL );
1307   fail_unless( ASTNode_getNumChildren(r) == 0  , NULL );
1308 
1309   ASTNode_free(r);
1310   // SBML_deleteL3Parser();
1311   Model_free(model);
1312 }
1313 END_TEST
1314 
1315 
START_TEST(test_SBML_parseL3Formula_modelPresent4)1316 START_TEST (test_SBML_parseL3Formula_modelPresent4)
1317 {
1318   Model_t *model = Model_create(3,1);
1319   Reaction *p = Model_createReaction(model);
1320   Reaction_setId(p, "pi");
1321   ASTNode_t *r = SBML_parseL3FormulaWithModel("pi", model);
1322 
1323   fail_unless( ASTNode_getType       (r) == AST_NAME, NULL );
1324   fail_unless( !strcmp(ASTNode_getName(r), "pi") , NULL );
1325   fail_unless( ASTNode_getNumChildren(r) == 0  , NULL );
1326 
1327   ASTNode_free(r);
1328   // SBML_deleteL3Parser();
1329   Model_free(model);
1330 }
1331 END_TEST
1332 
1333 
START_TEST(test_SBML_parseL3Formula_modelPresent5)1334 START_TEST (test_SBML_parseL3Formula_modelPresent5)
1335 {
1336   Model_t *model = Model_create(3,1);
1337   Reaction *p = Model_createReaction(model);
1338   SpeciesReference_t* sr = Reaction_createProduct(p);
1339   SpeciesReference_setId(sr, "avogadro");
1340   ASTNode_t *r = SBML_parseL3FormulaWithModel("avogadro", model);
1341 
1342   fail_unless( ASTNode_getType       (r) == AST_NAME, NULL );
1343   fail_unless( !strcmp(ASTNode_getName(r), "avogadro") , NULL );
1344   fail_unless( ASTNode_getNumChildren(r) == 0  , NULL );
1345 
1346   ASTNode_free(r);
1347   // SBML_deleteL3Parser();
1348   Model_free(model);
1349 }
1350 END_TEST
1351 
1352 
START_TEST(test_SBML_parseL3Formula_modelPresent6)1353 START_TEST (test_SBML_parseL3Formula_modelPresent6)
1354 {
1355   Model_t *model = Model_create(3,1);
1356   Reaction *p = Model_createReaction(model);
1357   SpeciesReference_t* sr = Reaction_createProduct(p);
1358   SpeciesReference_setId(sr, "AVOGADRO");
1359   ASTNode_t *r = SBML_parseL3FormulaWithModel("avogadro", model);
1360 
1361   fail_unless( ASTNode_getType       (r) == AST_NAME_AVOGADRO, NULL );
1362   fail_unless( !strcmp(ASTNode_getName(r), "avogadro") , NULL );
1363   fail_unless( ASTNode_getNumChildren(r) == 0  , NULL );
1364 
1365   ASTNode_free(r);
1366   // SBML_deleteL3Parser();
1367   Model_free(model);
1368 }
1369 END_TEST
1370 
1371 
START_TEST(test_SBML_parseL3Formula_modelPresent7)1372 START_TEST (test_SBML_parseL3Formula_modelPresent7)
1373 {
1374   Model_t *model = Model_create(3,1);
1375   FunctionDefinition *p = Model_createFunctionDefinition(model);
1376   FunctionDefinition_setId(p, "sin");
1377   ASTNode_t *r = SBML_parseL3FormulaWithModel("sin(x, y)", model);
1378 
1379   fail_unless( ASTNode_getType       (r) == AST_FUNCTION, NULL );
1380   fail_unless( !strcmp(ASTNode_getName(r), "sin") , NULL );
1381   fail_unless( ASTNode_getNumChildren(r) == 2  , NULL );
1382 
1383   ASTNode_free(r);
1384   // SBML_deleteL3Parser();
1385   Model_free(model);
1386 }
1387 END_TEST
1388 
1389 
START_TEST(test_SBML_parseL3Formula_arguments)1390 START_TEST (test_SBML_parseL3Formula_arguments)
1391 {
1392   char * error;
1393   ASTNode_t *r = SBML_parseL3Formula("sin(x,y)");
1394   fail_unless(r == NULL, NULL);
1395   error = SBML_getLastParseL3Error();
1396   fail_unless( !strcmp(error, "Error when parsing input 'sin(x,y)' at position 8:  The function 'sin' takes exactly one argument, but 2 were found."), NULL );
1397   safe_free(error);
1398 
1399   r = SBML_parseL3Formula("delay(x)");
1400   fail_unless(r == NULL, NULL);
1401   error = SBML_getLastParseL3Error();
1402   fail_unless( !strcmp(error, "Error when parsing input 'delay(x)' at position 8:  The function 'delay' takes exactly two arguments, but 1 were found."), NULL );
1403   safe_free(error);
1404 
1405   r = SBML_parseL3Formula("piecewise()");
1406   fail_unless(r == NULL, NULL);
1407   error = SBML_getLastParseL3Error();
1408   fail_unless( !strcmp(error, "Error when parsing input 'piecewise()' at position 11:  The function 'piecewise' takes at least one argument, but none were found."), NULL );
1409   safe_free(error);
1410 
1411   r = SBML_parseL3Formula("gt(x)");
1412   fail_unless(r == NULL, NULL);
1413   error = SBML_getLastParseL3Error();
1414   fail_unless( !strcmp(error, "Error when parsing input 'gt(x)' at position 5:  The function 'gt' takes at least two arguments, but 1 were found."), NULL );
1415   safe_free(error);
1416 
1417   r = SBML_parseL3Formula("minus()");
1418   fail_unless(r == NULL, NULL);
1419   error = SBML_getLastParseL3Error();
1420   fail_unless( !strcmp(error, "Error when parsing input 'minus()' at position 7:  The function 'minus' takes exactly one or two arguments, but 0 were found."), NULL );
1421   safe_free(error);
1422 
1423   r = SBML_parseL3Formula("root(x, y, z)");
1424   fail_unless(r == NULL, NULL);
1425   error = SBML_getLastParseL3Error();
1426   fail_unless( !strcmp(error, "Error when parsing input 'root(x, y, z)' at position 13:  The function 'root' takes exactly one or two arguments, but 3 were found."), NULL );
1427   safe_free(error);
1428 
1429   r = SBML_parseL3Formula("power()");
1430   fail_unless(r == NULL, NULL);
1431   error = SBML_getLastParseL3Error();
1432   fail_unless( !strcmp(error, "Error when parsing input 'power()' at position 7:  The function 'power' takes exactly two arguments, but 0 were found."), NULL );
1433   safe_free(error);
1434 
1435   // max and min can have zero arguments
1436   //r = SBML_parseL3Formula("max()");
1437   //fail_unless(r == NULL, NULL);
1438   //error = SBML_getLastParseL3Error();
1439   //fail_unless( !strcmp(error, "Error when parsing input 'max()' at position 5:  The function 'max' takes at least one argument, but 0 were found."), NULL );
1440   //safe_free(error);
1441 
1442   //r = SBML_parseL3Formula("min()");
1443   //fail_unless(r == NULL, NULL);
1444   //error = SBML_getLastParseL3Error();
1445   //fail_unless( !strcmp(error, "Error when parsing input 'min()' at position 5:  The function 'min' takes at least one argument, but 0 were found."), NULL );
1446   //safe_free(error);
1447 
1448   r = SBML_parseL3Formula("rateOf()");
1449   fail_unless(r == NULL, NULL);
1450   error = SBML_getLastParseL3Error();
1451   fail_unless( !strcmp(error, "Error when parsing input 'rateOf()' at position 8:  The function 'rateOf' takes exactly one argument, but 0 were found."), NULL );
1452   safe_free(error);
1453 
1454   r = SBML_parseL3Formula("rateOf(a, b)");
1455   fail_unless(r == NULL, NULL);
1456   error = SBML_getLastParseL3Error();
1457   fail_unless( !strcmp(error, "Error when parsing input 'rateOf(a, b)' at position 12:  The function 'rateOf' takes exactly one argument, but 2 were found."), NULL );
1458   safe_free(error);
1459 
1460   r = SBML_parseL3Formula("rateOf(1.3)");
1461   fail_unless(r == NULL, NULL);
1462   error = SBML_getLastParseL3Error();
1463   fail_unless( !strcmp(error, "Error when parsing input 'rateOf(1.3)' at position 11:  The function 'rateOf' takes exactly one argument, which must be the identifier of an element in the model."), NULL );
1464   safe_free(error);
1465 
1466   r = SBML_parseL3Formula("rateOf(a+b)");
1467   fail_unless(r == NULL, NULL);
1468   error = SBML_getLastParseL3Error();
1469   fail_unless( !strcmp(error, "Error when parsing input 'rateOf(a+b)' at position 11:  The function 'rateOf' takes exactly one argument, which must be the identifier of an element in the model."), NULL );
1470   safe_free(error);
1471 
1472   r = SBML_parseL3Formula("quotient(1,2,3)");
1473   fail_unless(r == NULL, NULL);
1474   error = SBML_getLastParseL3Error();
1475   fail_unless( !strcmp(error, "Error when parsing input 'quotient(1,2,3)' at position 15:  The function 'quotient' takes exactly two arguments, but 3 were found."), NULL );
1476   safe_free(error);
1477 
1478   r = SBML_parseL3Formula("rem()");
1479   fail_unless(r == NULL, NULL);
1480   error = SBML_getLastParseL3Error();
1481   fail_unless( !strcmp(error, "Error when parsing input 'rem()' at position 5:  The function 'rem' takes exactly two arguments, but 0 were found."), NULL );
1482   safe_free(error);
1483 
1484   r = SBML_parseL3Formula("implies(a)");
1485   fail_unless(r == NULL, NULL);
1486   error = SBML_getLastParseL3Error();
1487   fail_unless( !strcmp(error, "Error when parsing input 'implies(a)' at position 10:  The function 'implies' takes exactly two arguments, but 1 were found."), NULL );
1488   safe_free(error);
1489 
1490 }
1491 END_TEST
1492 
1493 
START_TEST(test_SBML_parseL3Formula_logic1)1494 START_TEST (test_SBML_parseL3Formula_logic1)
1495 {
1496   ASTNode_t *r = SBML_parseL3Formula("1 && 2 == 3");
1497   ASTNode_t *c;
1498 
1499 
1500 
1501   fail_unless( ASTNode_getType       (r) == AST_LOGICAL_AND, NULL );
1502   fail_unless( !strcmp(ASTNode_getName(r), "and") , NULL );
1503   fail_unless( ASTNode_getNumChildren(r) == 2  , NULL );
1504 
1505   c = ASTNode_getLeftChild(r);
1506 
1507   fail_unless( ASTNode_getType       (c) == AST_INTEGER, NULL );
1508   fail_unless( ASTNode_getInteger    (c) == 1, NULL );
1509   fail_unless( ASTNode_getNumChildren(c) == 0, NULL );
1510 
1511   c = ASTNode_getRightChild(r);
1512 
1513   fail_unless( ASTNode_getType       (c) == AST_RELATIONAL_EQ, NULL );
1514   fail_unless( !strcmp(ASTNode_getName(c), "eq") , NULL );
1515   fail_unless( ASTNode_getNumChildren(c) == 2  , NULL );
1516 
1517   c = ASTNode_getLeftChild(c);
1518 
1519   fail_unless( ASTNode_getType       (c) == AST_INTEGER, NULL );
1520   fail_unless( ASTNode_getInteger    (c) == 2, NULL );
1521   fail_unless( ASTNode_getNumChildren(c) == 0, NULL );
1522 
1523   c = ASTNode_getRightChild( ASTNode_getRightChild(r) );
1524 
1525   fail_unless( ASTNode_getType       (c) == AST_INTEGER, NULL );
1526   fail_unless( ASTNode_getInteger    (c) == 3, NULL );
1527   fail_unless( ASTNode_getNumChildren(c) == 0, NULL );
1528 
1529   ASTNode_free(r);
1530   // SBML_deleteL3Parser();
1531 }
1532 END_TEST
1533 
1534 
START_TEST(test_SBML_parseL3Formula_logic2)1535 START_TEST (test_SBML_parseL3Formula_logic2)
1536 {
1537   ASTNode_t *r = SBML_parseL3Formula("(1 && 2) == 3");
1538   ASTNode_t *c;
1539 
1540 
1541   fail_unless( ASTNode_getType       (r) == AST_RELATIONAL_EQ, NULL );
1542   fail_unless( !strcmp(ASTNode_getName(r), "eq") , NULL );
1543   fail_unless( ASTNode_getNumChildren(r) == 2  , NULL );
1544 
1545   c = ASTNode_getLeftChild(r);
1546 
1547   fail_unless( ASTNode_getType       (c) == AST_LOGICAL_AND, NULL );
1548   fail_unless( !strcmp(ASTNode_getName(c), "and") , NULL );
1549   fail_unless( ASTNode_getNumChildren(c) == 2, NULL );
1550 
1551   c = ASTNode_getRightChild(r);
1552 
1553   fail_unless( ASTNode_getType       (c) == AST_INTEGER, NULL );
1554   fail_unless( ASTNode_getInteger    (c) == 3, NULL );
1555   fail_unless( ASTNode_getNumChildren(c) == 0, NULL );
1556 
1557   c = ASTNode_getLeftChild( ASTNode_getLeftChild(r) );
1558 
1559   fail_unless( ASTNode_getType       (c) == AST_INTEGER, NULL );
1560   fail_unless( ASTNode_getInteger    (c) == 1, NULL );
1561   fail_unless( ASTNode_getNumChildren(c) == 0, NULL );
1562 
1563   c = ASTNode_getRightChild( ASTNode_getLeftChild(r) );
1564 
1565   fail_unless( ASTNode_getType       (c) == AST_INTEGER, NULL );
1566   fail_unless( ASTNode_getInteger   (c)  == 2, NULL );
1567   fail_unless( ASTNode_getNumChildren(c) == 0, NULL );
1568 
1569   ASTNode_free(r);
1570   // SBML_deleteL3Parser();
1571 }
1572 END_TEST
1573 
1574 
START_TEST(test_SBML_parseL3Formula_precedence)1575 START_TEST (test_SBML_parseL3Formula_precedence)
1576 {
1577   ASTNode_t *root = SBML_parseL3Formula("a && b == !(c - d * e^-f) ");
1578   ASTNode_t *left;
1579   ASTNode_t *right;
1580 
1581   fail_unless( ASTNode_getType       (root) == AST_LOGICAL_AND, NULL );
1582   fail_unless( !strcmp(ASTNode_getName(root), "and") , NULL );
1583   fail_unless( ASTNode_getNumChildren(root) == 2  , NULL );
1584 
1585   left = ASTNode_getLeftChild(root);
1586 
1587   fail_unless( ASTNode_getType       (left) == AST_NAME, NULL );
1588   fail_unless( !strcmp(ASTNode_getName(left), "a") , NULL );
1589   fail_unless( ASTNode_getNumChildren(left) == 0, NULL );
1590 
1591   right = ASTNode_getRightChild(root);
1592 
1593   fail_unless( ASTNode_getType       (right) == AST_RELATIONAL_EQ, NULL );
1594   fail_unless( !strcmp(ASTNode_getName(right), "eq") , NULL );
1595   fail_unless( ASTNode_getNumChildren(right) == 2  , NULL );
1596 
1597   left = ASTNode_getLeftChild(right);
1598 
1599   fail_unless( ASTNode_getType       (left) == AST_NAME, NULL );
1600   fail_unless( !strcmp(ASTNode_getName(left), "b") , NULL );
1601   fail_unless( ASTNode_getNumChildren(left) == 0, NULL );
1602 
1603   right = ASTNode_getRightChild(right);
1604 
1605   fail_unless( ASTNode_getType       (right) == AST_LOGICAL_NOT, NULL );
1606   fail_unless( !strcmp(ASTNode_getName(right), "not") , NULL );
1607   fail_unless( ASTNode_getNumChildren(right) == 1, NULL );
1608 
1609   right = ASTNode_getLeftChild(right);
1610 
1611   fail_unless( ASTNode_getType       (right) == AST_MINUS, NULL );
1612   fail_unless( ASTNode_getCharacter  (right) == '-', NULL );
1613   fail_unless( ASTNode_getNumChildren(right) == 2, NULL );
1614 
1615   left = ASTNode_getLeftChild(right);
1616 
1617   fail_unless( ASTNode_getType       (left) == AST_NAME, NULL );
1618   fail_unless( !strcmp(ASTNode_getName(left), "c") , NULL );
1619   fail_unless( ASTNode_getNumChildren(left) == 0, NULL );
1620 
1621   right = ASTNode_getRightChild(right);
1622 
1623   fail_unless( ASTNode_getType       (right) == AST_TIMES, NULL );
1624   fail_unless( ASTNode_getCharacter  (right) == '*', NULL );
1625   fail_unless( ASTNode_getNumChildren(right) == 2, NULL );
1626 
1627   left = ASTNode_getLeftChild(right);
1628 
1629   fail_unless( ASTNode_getType       (left) == AST_NAME, NULL );
1630   fail_unless( !strcmp(ASTNode_getName(left), "d") , NULL );
1631   fail_unless( ASTNode_getNumChildren(left) == 0, NULL );
1632 
1633   right = ASTNode_getRightChild(right);
1634 
1635   fail_unless( ASTNode_getType       (right) == AST_POWER, NULL );
1636   fail_unless( ASTNode_getCharacter  (right) == '^', NULL );
1637   fail_unless( ASTNode_getNumChildren(right) == 2, NULL );
1638 
1639   left = ASTNode_getLeftChild(right);
1640 
1641   fail_unless( ASTNode_getType       (left) == AST_NAME, NULL );
1642   fail_unless( !strcmp(ASTNode_getName(left), "e") , NULL );
1643   fail_unless( ASTNode_getNumChildren(left) == 0, NULL );
1644 
1645   right = ASTNode_getRightChild(right);
1646 
1647   fail_unless( ASTNode_getType       (right) == AST_MINUS, NULL );
1648   fail_unless( ASTNode_getCharacter  (right) == '-', NULL );
1649   fail_unless( ASTNode_getNumChildren(right) == 1, NULL );
1650 
1651   left = ASTNode_getLeftChild(right);
1652 
1653   fail_unless( ASTNode_getType       (left) == AST_NAME, NULL );
1654   fail_unless( !strcmp(ASTNode_getName(left), "f") , NULL );
1655   fail_unless( ASTNode_getNumChildren(left) == 0, NULL );
1656 
1657   ASTNode_free(root);
1658   // SBML_deleteL3Parser();
1659 }
1660 END_TEST
1661 
1662 
START_TEST(test_SBML_parseL3Formula_parselogsettings)1663 START_TEST (test_SBML_parseL3Formula_parselogsettings)
1664 {
1665   //Default:
1666   ASTNode_t *r = SBML_parseL3Formula("log(4.4)");
1667   ASTNode_t *c;
1668   char * error;
1669 
1670   fail_unless( ASTNode_getType       (r) == AST_FUNCTION_LOG, NULL );
1671   fail_unless( ASTNode_getNumChildren(r) == 2  , NULL );
1672 
1673   c = ASTNode_getLeftChild(r);
1674   fail_unless( ASTNode_getType       (c) == AST_INTEGER, NULL );
1675   fail_unless( ASTNode_getInteger    (c) == 10, NULL );
1676   fail_unless( ASTNode_getNumChildren(c) == 0, NULL );
1677 
1678   c = ASTNode_getRightChild(r);
1679   fail_unless( ASTNode_getType       (c) == AST_REAL, NULL );
1680   fail_unless( ASTNode_getReal       (c) == 4.4, NULL );
1681   fail_unless( ASTNode_getNumChildren(c) == 0, NULL );
1682 
1683   ASTNode_free(r);
1684   L3ParserSettings settings;
1685 
1686   //Explicit parsing as ln
1687   settings.setParseLog(L3P_PARSE_LOG_AS_LN);
1688   r = SBML_parseL3FormulaWithSettings("log(4.4)", &settings);
1689   fail_unless( ASTNode_getType       (r) == AST_FUNCTION_LN, NULL );
1690   fail_unless( ASTNode_getNumChildren(r) == 1  , NULL );
1691 
1692   c = ASTNode_getLeftChild(r);
1693 
1694   fail_unless( ASTNode_getType       (c) == AST_REAL, NULL );
1695   fail_unless( ASTNode_getReal       (c) == 4.4, NULL );
1696   fail_unless( ASTNode_getNumChildren(c) == 0, NULL );
1697 
1698   ASTNode_free(r);
1699 
1700   //Explicit parsing as log10
1701   settings.setParseLog(L3P_PARSE_LOG_AS_LOG10);
1702   r = SBML_parseL3FormulaWithSettings("log(4.4)", &settings);
1703   fail_unless( ASTNode_getType       (r) == AST_FUNCTION_LOG, NULL );
1704   fail_unless( ASTNode_getNumChildren(r) == 2  , NULL );
1705 
1706   c = ASTNode_getLeftChild(r);
1707   fail_unless( ASTNode_getType       (c) == AST_INTEGER, NULL );
1708   fail_unless( ASTNode_getInteger    (c) == 10, NULL );
1709   fail_unless( ASTNode_getNumChildren(c) == 0, NULL );
1710 
1711   c = ASTNode_getRightChild(r);
1712   fail_unless( ASTNode_getType       (c) == AST_REAL, NULL );
1713   fail_unless( ASTNode_getReal       (c) == 4.4, NULL );
1714   fail_unless( ASTNode_getNumChildren(c) == 0, NULL );
1715 
1716   ASTNode_free(r);
1717 
1718   //Explicit setting as error
1719   settings.setParseLog(L3P_PARSE_LOG_AS_ERROR);
1720   r = SBML_parseL3FormulaWithSettings("log(4.4)", &settings);
1721 
1722   error = SBML_getLastParseL3Error();
1723   fail_unless( r == NULL, NULL );
1724   fail_unless( !strcmp(error, "Error when parsing input 'log(4.4)' at position 8:  Writing a function as 'log(x)' was legal in the L1 parser, but translated as the natural log, not the base-10 log.  This construct is disallowed entirely as being ambiguous, and you are encouraged instead to use 'ln(x)', 'log10(x)', or 'log(base, x)'."), NULL);
1725 
1726   safe_free(error);
1727   // SBML_deleteL3Parser();
1728 }
1729 END_TEST
1730 
1731 
START_TEST(test_SBML_parseL3Formula_collapseminussettings1)1732 START_TEST (test_SBML_parseL3Formula_collapseminussettings1)
1733 {
1734   //Default:
1735   ASTNode_t *r = SBML_parseL3Formula("--4.4");
1736   ASTNode_t *c;
1737 
1738   fail_unless( ASTNode_getType       (r) == AST_MINUS, NULL );
1739   fail_unless( ASTNode_getNumChildren(r) == 1  , NULL );
1740 
1741   c = ASTNode_getLeftChild(r);
1742   fail_unless( ASTNode_getType       (c) == AST_MINUS, NULL );
1743   fail_unless( ASTNode_getNumChildren(c) == 1  , NULL );
1744 
1745   c = ASTNode_getLeftChild(c);
1746   fail_unless( ASTNode_getType       (c) == AST_REAL, NULL );
1747   fail_unless( ASTNode_getReal       (c) == 4.4, NULL );
1748   fail_unless( ASTNode_getNumChildren(c) == 0, NULL );
1749 
1750   ASTNode_free(r);
1751   L3ParserSettings settings;
1752 
1753   //Explicit parsing to collapse the minuses
1754   settings.setParseCollapseMinus(L3P_COLLAPSE_UNARY_MINUS);
1755   r = SBML_parseL3FormulaWithSettings("--4.4", &settings);
1756   fail_unless( ASTNode_getType       (r) == AST_REAL, NULL );
1757   fail_unless( ASTNode_getReal       (r) == 4.4, NULL );
1758   fail_unless( ASTNode_getNumChildren(r) == 0, NULL );
1759 
1760   ASTNode_free(r);
1761 
1762   //Explicit parsing to expand the minuses
1763   settings.setParseCollapseMinus(L3P_EXPAND_UNARY_MINUS);
1764   r = SBML_parseL3Formula("--4.4");
1765 
1766   fail_unless( ASTNode_getType       (r) == AST_MINUS, NULL );
1767   fail_unless( ASTNode_getNumChildren(r) == 1  , NULL );
1768 
1769   c = ASTNode_getLeftChild(r);
1770   fail_unless( ASTNode_getType       (c) == AST_MINUS, NULL );
1771   fail_unless( ASTNode_getNumChildren(c) == 1  , NULL );
1772 
1773   c = ASTNode_getLeftChild(c);
1774   fail_unless( ASTNode_getType       (c) == AST_REAL, NULL );
1775   fail_unless( ASTNode_getReal       (c) == 4.4, NULL );
1776   fail_unless( ASTNode_getNumChildren(c) == 0, NULL );
1777 
1778   ASTNode_free(r);
1779   // SBML_deleteL3Parser();
1780 }
1781 END_TEST
1782 
1783 
START_TEST(test_SBML_parseL3Formula_collapseminussettings2)1784 START_TEST (test_SBML_parseL3Formula_collapseminussettings2)
1785 {
1786   //Default:
1787   ASTNode_t *r = SBML_parseL3Formula("--x");
1788   ASTNode_t *c;
1789 
1790   fail_unless( ASTNode_getType       (r) == AST_MINUS, NULL );
1791   fail_unless( ASTNode_getNumChildren(r) == 1  , NULL );
1792 
1793   c = ASTNode_getLeftChild(r);
1794   fail_unless( ASTNode_getType       (c) == AST_MINUS, NULL );
1795   fail_unless( ASTNode_getNumChildren(c) == 1  , NULL );
1796 
1797   c = ASTNode_getLeftChild(c);
1798   fail_unless( ASTNode_getType       (c) == AST_NAME, NULL );
1799   fail_unless( !strcmp(ASTNode_getName(c), "x"), NULL );
1800   fail_unless( ASTNode_getNumChildren(c) == 0, NULL );
1801 
1802   ASTNode_free(r);
1803   L3ParserSettings settings;
1804 
1805   //Explicit parsing to collapse the minuses
1806   settings.setParseCollapseMinus(L3P_COLLAPSE_UNARY_MINUS);
1807   r = SBML_parseL3FormulaWithSettings("--x", &settings);
1808   fail_unless( ASTNode_getType       (r) == AST_NAME, NULL );
1809   fail_unless( !strcmp(ASTNode_getName(r), "x"), NULL );
1810   fail_unless( ASTNode_getNumChildren(r) == 0, NULL );
1811 
1812   ASTNode_free(r);
1813 
1814   //Explicit parsing to expand the minuses
1815   settings.setParseCollapseMinus(L3P_EXPAND_UNARY_MINUS);
1816   r = SBML_parseL3FormulaWithSettings("--x", &settings);
1817 
1818   fail_unless( ASTNode_getType       (r) == AST_MINUS, NULL );
1819   fail_unless( ASTNode_getNumChildren(r) == 1  , NULL );
1820 
1821   c = ASTNode_getLeftChild(r);
1822   fail_unless( ASTNode_getType       (c) == AST_MINUS, NULL );
1823   fail_unless( ASTNode_getNumChildren(c) == 1  , NULL );
1824 
1825   c = ASTNode_getLeftChild(c);
1826   fail_unless( ASTNode_getType       (c) == AST_NAME, NULL );
1827   fail_unless( !strcmp(ASTNode_getName(c), "x"), NULL );
1828   fail_unless( ASTNode_getNumChildren(c) == 0, NULL );
1829 
1830   ASTNode_free(r);
1831   // SBML_deleteL3Parser();
1832 }
1833 END_TEST
1834 
1835 
START_TEST(test_SBML_parseL3Formula_collapseminussettings3)1836 START_TEST (test_SBML_parseL3Formula_collapseminussettings3)
1837 {
1838   //Default:
1839   ASTNode_t *r = SBML_parseL3Formula("x---4.4");
1840   ASTNode_t *c;
1841 
1842   fail_unless( ASTNode_getType       (r) == AST_MINUS, NULL );
1843   fail_unless( ASTNode_getNumChildren(r) == 2  , NULL );
1844 
1845   c = ASTNode_getLeftChild(r);
1846   fail_unless( ASTNode_getType       (c) == AST_NAME, NULL );
1847   fail_unless( !strcmp(ASTNode_getName(c), "x"), NULL );
1848   fail_unless( ASTNode_getNumChildren(c) == 0, NULL );
1849 
1850   c = ASTNode_getRightChild(r);
1851   fail_unless( ASTNode_getType       (c) == AST_MINUS, NULL );
1852   fail_unless( ASTNode_getNumChildren(c) == 1  , NULL );
1853 
1854   c = ASTNode_getLeftChild(c);
1855   fail_unless( ASTNode_getType       (c) == AST_MINUS, NULL );
1856   fail_unless( ASTNode_getNumChildren(c) == 1  , NULL );
1857 
1858   c = ASTNode_getLeftChild(c);
1859   fail_unless( ASTNode_getType       (c) == AST_REAL, NULL );
1860   fail_unless( ASTNode_getReal       (c) == 4.4, NULL );
1861   fail_unless( ASTNode_getNumChildren(c) == 0, NULL );
1862 
1863   ASTNode_free(r);
1864   L3ParserSettings settings;
1865 
1866   //Explicit parsing to collapse the minuses
1867   settings.setParseCollapseMinus(L3P_COLLAPSE_UNARY_MINUS);
1868   r = SBML_parseL3FormulaWithSettings("x---4.4", &settings);
1869   fail_unless( ASTNode_getType       (r) == AST_MINUS, NULL );
1870   fail_unless( ASTNode_getNumChildren(r) == 2  , NULL );
1871 
1872   c = ASTNode_getLeftChild(r);
1873   fail_unless( ASTNode_getType       (c) == AST_NAME, NULL );
1874   fail_unless( !strcmp(ASTNode_getName(c), "x"), NULL );
1875   fail_unless( ASTNode_getNumChildren(c) == 0, NULL );
1876 
1877   c = ASTNode_getRightChild(r);
1878   fail_unless( ASTNode_getType       (c) == AST_REAL, NULL );
1879   fail_unless( ASTNode_getReal       (c) == 4.4, NULL );
1880   fail_unless( ASTNode_getNumChildren(c) == 0, NULL );
1881 
1882   ASTNode_free(r);
1883 
1884   //Explicit parsing to expand the minuses
1885   settings.setParseCollapseMinus(L3P_EXPAND_UNARY_MINUS);
1886   r = SBML_parseL3FormulaWithSettings("x---4.4", &settings);
1887 
1888   fail_unless( ASTNode_getType       (r) == AST_MINUS, NULL );
1889   fail_unless( ASTNode_getNumChildren(r) == 2  , NULL );
1890 
1891   c = ASTNode_getLeftChild(r);
1892   fail_unless( ASTNode_getType       (c) == AST_NAME, NULL );
1893   fail_unless( !strcmp(ASTNode_getName(c), "x"), NULL );
1894   fail_unless( ASTNode_getNumChildren(c) == 0, NULL );
1895 
1896   c = ASTNode_getRightChild(r);
1897   fail_unless( ASTNode_getType       (c) == AST_MINUS, NULL );
1898   fail_unless( ASTNode_getNumChildren(c) == 1  , NULL );
1899 
1900   c = ASTNode_getLeftChild(c);
1901   fail_unless( ASTNode_getType       (c) == AST_MINUS, NULL );
1902   fail_unless( ASTNode_getNumChildren(c) == 1  , NULL );
1903 
1904   c = ASTNode_getLeftChild(c);
1905   fail_unless( ASTNode_getType       (c) == AST_REAL, NULL );
1906   fail_unless( ASTNode_getReal       (c) == 4.4, NULL );
1907   fail_unless( ASTNode_getNumChildren(c) == 0, NULL );
1908 
1909   ASTNode_free(r);
1910   // SBML_deleteL3Parser();
1911 }
1912 END_TEST
1913 
1914 
START_TEST(test_SBML_parseL3Formula_collapseminussettings4)1915 START_TEST (test_SBML_parseL3Formula_collapseminussettings4)
1916 {
1917   //Default:
1918   ASTNode_t *r = SBML_parseL3Formula("x---y");
1919   ASTNode_t *c;
1920 
1921   fail_unless( ASTNode_getType       (r) == AST_MINUS, NULL );
1922   fail_unless( ASTNode_getNumChildren(r) == 2  , NULL );
1923 
1924   c = ASTNode_getLeftChild(r);
1925   fail_unless( ASTNode_getType       (c) == AST_NAME, NULL );
1926   fail_unless( !strcmp(ASTNode_getName(c), "x"), NULL );
1927   fail_unless( ASTNode_getNumChildren(c) == 0, NULL );
1928 
1929   c = ASTNode_getRightChild(r);
1930   fail_unless( ASTNode_getType       (c) == AST_MINUS, NULL );
1931   fail_unless( ASTNode_getNumChildren(c) == 1  , NULL );
1932 
1933   c = ASTNode_getLeftChild(c);
1934   fail_unless( ASTNode_getType       (c) == AST_MINUS, NULL );
1935   fail_unless( ASTNode_getNumChildren(c) == 1  , NULL );
1936 
1937   c = ASTNode_getLeftChild(c);
1938   fail_unless( ASTNode_getType       (c) == AST_NAME, NULL );
1939   fail_unless( !strcmp(ASTNode_getName(c), "y"), NULL );
1940   fail_unless( ASTNode_getNumChildren(c) == 0, NULL );
1941 
1942   ASTNode_free(r);
1943   L3ParserSettings settings;
1944 
1945   //Explicit parsing to collapse the minuses
1946   settings.setParseCollapseMinus(L3P_COLLAPSE_UNARY_MINUS);
1947   r = SBML_parseL3FormulaWithSettings("x---y", &settings);
1948   fail_unless( ASTNode_getType       (r) == AST_MINUS, NULL );
1949   fail_unless( ASTNode_getNumChildren(r) == 2  , NULL );
1950 
1951   c = ASTNode_getLeftChild(r);
1952   fail_unless( ASTNode_getType       (c) == AST_NAME, NULL );
1953   fail_unless( !strcmp(ASTNode_getName(c), "x"), NULL );
1954   fail_unless( ASTNode_getNumChildren(c) == 0, NULL );
1955 
1956   c = ASTNode_getRightChild(r);
1957   fail_unless( ASTNode_getType       (c) == AST_NAME, NULL );
1958   fail_unless( !strcmp(ASTNode_getName(c), "y"), NULL );
1959   fail_unless( ASTNode_getNumChildren(c) == 0, NULL );
1960 
1961   ASTNode_free(r);
1962 
1963   //Explicit parsing to expand the minuses
1964   settings.setParseCollapseMinus(L3P_EXPAND_UNARY_MINUS);
1965   r = SBML_parseL3FormulaWithSettings("x---y", &settings);
1966 
1967   fail_unless( ASTNode_getType       (r) == AST_MINUS, NULL );
1968   fail_unless( ASTNode_getNumChildren(r) == 2  , NULL );
1969 
1970   c = ASTNode_getLeftChild(r);
1971   fail_unless( ASTNode_getType       (c) == AST_NAME, NULL );
1972   fail_unless( !strcmp(ASTNode_getName(c), "x"), NULL );
1973   fail_unless( ASTNode_getNumChildren(c) == 0, NULL );
1974 
1975   c = ASTNode_getRightChild(r);
1976   fail_unless( ASTNode_getType       (c) == AST_MINUS, NULL );
1977   fail_unless( ASTNode_getNumChildren(c) == 1  , NULL );
1978 
1979   c = ASTNode_getLeftChild(c);
1980   fail_unless( ASTNode_getType       (c) == AST_MINUS, NULL );
1981   fail_unless( ASTNode_getNumChildren(c) == 1  , NULL );
1982 
1983   c = ASTNode_getLeftChild(c);
1984   fail_unless( ASTNode_getType       (c) == AST_NAME, NULL );
1985   fail_unless( !strcmp(ASTNode_getName(c), "y"), NULL );
1986   fail_unless( ASTNode_getNumChildren(c) == 0, NULL );
1987 
1988   ASTNode_free(r);
1989   // SBML_deleteL3Parser();
1990 }
1991 END_TEST
1992 
1993 
START_TEST(test_SBML_parseL3Formula_collapseminussettings5)1994 START_TEST (test_SBML_parseL3Formula_collapseminussettings5)
1995 {
1996   //Explicit parsing to collapse the minuses
1997   L3ParserSettings settings;
1998   settings.setParseCollapseMinus(L3P_COLLAPSE_UNARY_MINUS);
1999   ASTNode_t* r = SBML_parseL3FormulaWithSettings("---4", &settings);
2000   fail_unless( ASTNode_getType       (r) == AST_INTEGER, NULL );
2001   fail_unless( ASTNode_getInteger    (r) == -4, NULL );
2002   fail_unless( ASTNode_getNumChildren(r) == 0, NULL );
2003   ASTNode_free(r);
2004 
2005   r = SBML_parseL3FormulaWithSettings("---(3/8)", &settings);
2006   fail_unless( ASTNode_getType       (r) == AST_RATIONAL, NULL );
2007   fail_unless( ASTNode_getNumerator  (r) == -3, NULL );
2008   fail_unless( ASTNode_getDenominator(r) == 8, NULL );
2009   fail_unless( ASTNode_getNumChildren(r) == 0, NULL );
2010   ASTNode_free(r);
2011 
2012   r = SBML_parseL3FormulaWithSettings("---(-3/8)", &settings);
2013   fail_unless( ASTNode_getType       (r) == AST_RATIONAL, NULL );
2014   fail_unless( ASTNode_getNumerator  (r) == 3, NULL );
2015   fail_unless( ASTNode_getDenominator(r) == 8, NULL );
2016   fail_unless( ASTNode_getNumChildren(r) == 0, NULL );
2017   ASTNode_free(r);
2018 
2019   r = SBML_parseL3FormulaWithSettings("---4.4", &settings);
2020   fail_unless( ASTNode_getType       (r) == AST_REAL, NULL );
2021   fail_unless( ASTNode_getReal       (r) == -4.4, NULL );
2022   fail_unless( ASTNode_getNumChildren(r) == 0, NULL );
2023   ASTNode_free(r);
2024 
2025   r = SBML_parseL3FormulaWithSettings("---4e-3", &settings);
2026   fail_unless( ASTNode_getType       (r) == AST_REAL_E, NULL );
2027   fail_unless( ASTNode_getMantissa   (r) == -4, NULL );
2028   fail_unless( ASTNode_getExponent   (r) == -3, NULL );
2029   fail_unless( ASTNode_getNumChildren(r) == 0, NULL );
2030   ASTNode_free(r);
2031 
2032   r = SBML_parseL3FormulaWithSettings("---.4", &settings);
2033   fail_unless( ASTNode_getType       (r) == AST_REAL, NULL );
2034   fail_unless( ASTNode_getReal       (r) == -.4, NULL );
2035   fail_unless( ASTNode_getNumChildren(r) == 0, NULL );
2036   ASTNode_free(r);
2037 
2038   // SBML_deleteL3Parser();
2039 }
2040 END_TEST
2041 
2042 
START_TEST(test_SBML_parseL3Formula_unaryPlus)2043 START_TEST (test_SBML_parseL3Formula_unaryPlus)
2044 {
2045   //A unary plus is currently a no-op.
2046   ASTNode_t* r = SBML_parseL3Formula("+++4");
2047   fail_unless( ASTNode_getType       (r) == AST_INTEGER, NULL );
2048   fail_unless( ASTNode_getInteger    (r) == 4, NULL );
2049   fail_unless( ASTNode_getNumChildren(r) == 0, NULL );
2050   ASTNode_free(r);
2051 
2052   r = SBML_parseL3Formula("+++(3/8)");
2053   fail_unless( ASTNode_getType       (r) == AST_RATIONAL, NULL );
2054   fail_unless( ASTNode_getNumerator  (r) == 3, NULL );
2055   fail_unless( ASTNode_getDenominator(r) == 8, NULL );
2056   fail_unless( ASTNode_getNumChildren(r) == 0, NULL );
2057   ASTNode_free(r);
2058 
2059   r = SBML_parseL3Formula("+++(+(3/8))");
2060   fail_unless( ASTNode_getType       (r) == AST_RATIONAL, NULL );
2061   fail_unless( ASTNode_getNumerator  (r) == 3, NULL );
2062   fail_unless( ASTNode_getDenominator(r) == 8, NULL );
2063   fail_unless( ASTNode_getNumChildren(r) == 0, NULL );
2064   ASTNode_free(r);
2065 
2066   r = SBML_parseL3Formula("+++4.4");
2067   fail_unless( ASTNode_getType       (r) == AST_REAL, NULL );
2068   fail_unless( ASTNode_getReal       (r) == 4.4, NULL );
2069   fail_unless( ASTNode_getNumChildren(r) == 0, NULL );
2070   ASTNode_free(r);
2071 
2072   r = SBML_parseL3Formula("+++4e-3");
2073   fail_unless( ASTNode_getType       (r) == AST_REAL_E, NULL );
2074   fail_unless( ASTNode_getMantissa   (r) == 4, NULL );
2075   fail_unless( ASTNode_getExponent   (r) == -3, NULL );
2076   fail_unless( ASTNode_getNumChildren(r) == 0, NULL );
2077   ASTNode_free(r);
2078 
2079   r = SBML_parseL3Formula("+++.4");
2080   fail_unless( ASTNode_getType       (r) == AST_REAL, NULL );
2081   fail_unless( ASTNode_getReal       (r) == .4, NULL );
2082   fail_unless( ASTNode_getNumChildren(r) == 0, NULL );
2083   ASTNode_free(r);
2084 
2085   r = SBML_parseL3Formula("3+++4");
2086   fail_unless( ASTNode_getType       (r) == AST_PLUS, NULL );
2087   ASTNode_t* c = ASTNode_getChild(r, 0);
2088   fail_unless( ASTNode_getType       (c) == AST_INTEGER, NULL );
2089   fail_unless( ASTNode_getInteger    (c) == 3, NULL );
2090   fail_unless( ASTNode_getNumChildren(c) == 0, NULL );
2091   c = ASTNode_getChild(r, 1);
2092   fail_unless( ASTNode_getType       (c) == AST_INTEGER, NULL );
2093   fail_unless( ASTNode_getInteger    (c) == 4, NULL );
2094   fail_unless( ASTNode_getNumChildren(c) == 0, NULL );
2095   ASTNode_free(r);
2096 
2097   // SBML_deleteL3Parser();
2098 }
2099 END_TEST
2100 
2101 
START_TEST(test_SBML_parseL3Formula_avogadrosettings)2102 START_TEST (test_SBML_parseL3Formula_avogadrosettings)
2103 {
2104   ASTNode_t *r = SBML_parseL3Formula("avogadro");
2105   fail_unless( ASTNode_getType       (r) == AST_NAME_AVOGADRO, NULL );
2106   fail_unless( ASTNode_getNumChildren(r) ==   0, NULL );
2107   ASTNode_free(r);
2108 
2109   L3ParserSettings settings;
2110   settings.setParseAvogadroCsymbol(L3P_AVOGADRO_IS_NAME);
2111 
2112   r = SBML_parseL3FormulaWithSettings("avogadro", &settings);
2113   fail_unless( ASTNode_getType       (r) == AST_NAME, NULL );
2114   fail_unless( !strcmp(ASTNode_getName(r), "avogadro") , NULL );
2115   fail_unless( ASTNode_getNumChildren(r) == 0  , NULL );
2116   ASTNode_free(r);
2117 
2118   settings.setParseAvogadroCsymbol(L3P_AVOGADRO_IS_CSYMBOL);
2119 
2120   r = SBML_parseL3FormulaWithSettings("avogadro", &settings);
2121   fail_unless( ASTNode_getType       (r) == AST_NAME_AVOGADRO, NULL );
2122   fail_unless( ASTNode_getNumChildren(r) ==   0, NULL );
2123   ASTNode_free(r);
2124   // SBML_deleteL3Parser();
2125 }
2126 END_TEST
2127 
2128 
START_TEST(test_SBML_parseL3Formula_unitssettings)2129 START_TEST (test_SBML_parseL3Formula_unitssettings)
2130 {
2131   ASTNode_t *r = SBML_parseL3Formula("4 mL");
2132   char * error;
2133   char * units;
2134 
2135   fail_unless( ASTNode_getType       (r) == AST_INTEGER, NULL );
2136   fail_unless( ASTNode_getInteger    (r) ==   4, NULL );
2137   units = ASTNode_getUnits(r);
2138   fail_unless( !strcmp(units, "mL"), NULL );
2139   safe_free(units);
2140   fail_unless( ASTNode_getNumChildren(r) ==   0, NULL );
2141   ASTNode_free(r);
2142 
2143   L3ParserSettings settings;
2144   settings.setParseUnits(L3P_NO_UNITS);
2145   r = SBML_parseL3FormulaWithSettings("4 mL", &settings);
2146   error = SBML_getLastParseL3Error();
2147   fail_unless(r == NULL, NULL);
2148   fail_unless( !strcmp(error, "Error when parsing input '4 mL' at position 4:  The ability to associate units with numbers has been disabled."), NULL );
2149   safe_free(error);
2150 
2151   settings.setParseUnits(L3P_PARSE_UNITS);
2152   r = SBML_parseL3FormulaWithSettings("4 mL", &settings);
2153   fail_unless( ASTNode_getType       (r) == AST_INTEGER, NULL );
2154   fail_unless( ASTNode_getInteger    (r) ==   4, NULL );
2155   units = ASTNode_getUnits(r);
2156   fail_unless( !strcmp(units, "mL"), NULL );
2157   safe_free(units);
2158   fail_unless( ASTNode_getNumChildren(r) ==   0, NULL );
2159   ASTNode_free(r);
2160 
2161   // SBML_deleteL3Parser();
2162 }
2163 END_TEST
2164 
2165 
START_TEST(test_SBML_parseL3Formula_capssettings1)2166 START_TEST (test_SBML_parseL3Formula_capssettings1)
2167 {
2168   //Default:
2169   ASTNode_t *r = SBML_parseL3Formula("SqRt(3)");
2170 
2171   fail_unless( ASTNode_getType       (r) == AST_FUNCTION_ROOT, NULL );
2172   fail_unless( ASTNode_getNumChildren(r) == 2  , NULL );
2173 
2174   ASTNode_t *c = ASTNode_getLeftChild(r);
2175 
2176   fail_unless( ASTNode_getType       (c) == AST_INTEGER, NULL );
2177   fail_unless( ASTNode_getInteger    (c) == 2, NULL );
2178   fail_unless( ASTNode_getNumChildren(c) == 0, NULL );
2179 
2180   c = ASTNode_getRightChild(r);
2181 
2182   fail_unless( ASTNode_getType       (c) == AST_INTEGER, NULL );
2183   fail_unless( ASTNode_getInteger    (c) == 3, NULL );
2184   fail_unless( ASTNode_getNumChildren(c) == 0, NULL );
2185 
2186   ASTNode_free(r);
2187 
2188   //Explicit noncaseless
2189   L3ParserSettings settings;
2190   settings.setComparisonCaseSensitivity(L3P_COMPARE_BUILTINS_CASE_SENSITIVE);
2191   r = SBML_parseL3FormulaWithSettings("SqRt(3)", &settings);
2192 
2193   fail_unless( ASTNode_getType       (r) == AST_FUNCTION, NULL );
2194   fail_unless( !strcmp(ASTNode_getName(r), "SqRt") , NULL );
2195   fail_unless( ASTNode_getNumChildren(r) == 1  , NULL );
2196 
2197   c = ASTNode_getLeftChild(r);
2198 
2199   fail_unless( ASTNode_getType       (c) == AST_INTEGER, NULL );
2200   fail_unless( ASTNode_getInteger    (c) == 3, NULL );
2201   fail_unless( ASTNode_getNumChildren(c) == 0, NULL );
2202 
2203   ASTNode_free(r);
2204 
2205   //Explicit noncaseless
2206   settings.setComparisonCaseSensitivity(L3P_COMPARE_BUILTINS_CASE_INSENSITIVE);
2207   r = SBML_parseL3FormulaWithSettings("SqRt(3)", &settings);
2208 
2209   fail_unless( ASTNode_getType       (r) == AST_FUNCTION_ROOT, NULL );
2210   fail_unless( ASTNode_getNumChildren(r) == 2  , NULL );
2211 
2212   c = ASTNode_getLeftChild(r);
2213 
2214   fail_unless( ASTNode_getType       (c) == AST_INTEGER, NULL );
2215   fail_unless( ASTNode_getInteger    (c) == 2, NULL );
2216   fail_unless( ASTNode_getNumChildren(c) == 0, NULL );
2217 
2218   c = ASTNode_getRightChild(r);
2219 
2220   fail_unless( ASTNode_getType       (c) == AST_INTEGER, NULL );
2221   fail_unless( ASTNode_getInteger    (c) == 3, NULL );
2222   fail_unless( ASTNode_getNumChildren(c) == 0, NULL );
2223 
2224   ASTNode_free(r);
2225 }
2226 END_TEST
2227 
2228 
START_TEST(test_SBML_parseL3Formula_capssettings2)2229 START_TEST (test_SBML_parseL3Formula_capssettings2)
2230 {
2231   //Default:
2232   ASTNode_t *r = SBML_parseL3Formula("PI");
2233 
2234   fail_unless( ASTNode_getType       (r) == AST_CONSTANT_PI, NULL );
2235   fail_unless( ASTNode_getNumChildren(r) == 0  , NULL );
2236 
2237   ASTNode_free(r);
2238 
2239   //Explicit noncaseless
2240   L3ParserSettings settings;
2241   settings.setComparisonCaseSensitivity(L3P_COMPARE_BUILTINS_CASE_SENSITIVE);
2242   r = SBML_parseL3FormulaWithSettings("PI", &settings);
2243 
2244   fail_unless( ASTNode_getType       (r) == AST_NAME, NULL );
2245   fail_unless( !strcmp(ASTNode_getName(r), "PI") , NULL );
2246   fail_unless( ASTNode_getNumChildren(r) == 0  , NULL );
2247 
2248   ASTNode_free(r);
2249 
2250   //Explicit noncaseless
2251   settings.setComparisonCaseSensitivity(L3P_COMPARE_BUILTINS_CASE_INSENSITIVE);
2252   r = SBML_parseL3FormulaWithSettings("PI", &settings);
2253 
2254   fail_unless( ASTNode_getType       (r) == AST_CONSTANT_PI, NULL );
2255   fail_unless( ASTNode_getNumChildren(r) == 0  , NULL );
2256 
2257   ASTNode_free(r);
2258 }
2259 END_TEST
2260 
2261 
START_TEST(test_SBML_parseL3Formula_capssettings3)2262 START_TEST (test_SBML_parseL3Formula_capssettings3)
2263 {
2264   //Default:
2265   ASTNode_t *r = SBML_parseL3Formula("ArcSinH(3)");
2266 
2267   fail_unless( ASTNode_getType       (r) == AST_FUNCTION_ARCSINH, NULL );
2268   fail_unless( ASTNode_getNumChildren(r) == 1  , NULL );
2269 
2270   ASTNode_t *c = ASTNode_getLeftChild(r);
2271 
2272   fail_unless( ASTNode_getType       (c) == AST_INTEGER, NULL );
2273   fail_unless( ASTNode_getInteger    (c) == 3, NULL );
2274   fail_unless( ASTNode_getNumChildren(c) == 0, NULL );
2275 
2276   ASTNode_free(r);
2277 
2278   //Explicit noncaseless
2279   L3ParserSettings settings;
2280   settings.setComparisonCaseSensitivity(L3P_COMPARE_BUILTINS_CASE_SENSITIVE);
2281   r = SBML_parseL3FormulaWithSettings("ArcSinH(3)", &settings);
2282 
2283   fail_unless( ASTNode_getType       (r) == AST_FUNCTION, NULL );
2284   fail_unless( !strcmp(ASTNode_getName(r), "ArcSinH") , NULL );
2285   fail_unless( ASTNode_getNumChildren(r) == 1  , NULL );
2286 
2287   c = ASTNode_getLeftChild(r);
2288 
2289   fail_unless( ASTNode_getType       (c) == AST_INTEGER, NULL );
2290   fail_unless( ASTNode_getInteger    (c) == 3, NULL );
2291   fail_unless( ASTNode_getNumChildren(c) == 0, NULL );
2292 
2293   ASTNode_free(r);
2294 
2295   //Explicit noncaseless
2296   settings.setComparisonCaseSensitivity(L3P_COMPARE_BUILTINS_CASE_INSENSITIVE);
2297   r = SBML_parseL3FormulaWithSettings("ArcSinH(3)", &settings);
2298 
2299   fail_unless( ASTNode_getType       (r) == AST_FUNCTION_ARCSINH, NULL );
2300   fail_unless( ASTNode_getNumChildren(r) == 1  , NULL );
2301 
2302   c = ASTNode_getLeftChild(r);
2303 
2304   fail_unless( ASTNode_getType       (c) == AST_INTEGER, NULL );
2305   fail_unless( ASTNode_getInteger    (c) == 3, NULL );
2306   fail_unless( ASTNode_getNumChildren(c) == 0, NULL );
2307 
2308   ASTNode_free(r);
2309 }
2310 END_TEST
2311 
2312 
START_TEST(test_SBML_parseL3Formula_power)2313 START_TEST (test_SBML_parseL3Formula_power)
2314 {
2315   ASTNode_t *r = SBML_parseL3Formula("pow(1.1, 3)");
2316 
2317   fail_unless( ASTNode_getType       (r) == AST_POWER, NULL );
2318   fail_unless( ASTNode_getNumChildren(r) == 2  , NULL );
2319 
2320   ASTNode_t *c = ASTNode_getLeftChild(r);
2321 
2322   fail_unless( ASTNode_getType       (c) == AST_REAL, NULL );
2323   fail_unless( ASTNode_getReal       (c) == 1.1, NULL );
2324   fail_unless( ASTNode_getNumChildren(c) == 0, NULL );
2325 
2326   c = ASTNode_getRightChild(r);
2327 
2328   fail_unless( ASTNode_getType       (c) == AST_INTEGER, NULL );
2329   fail_unless( ASTNode_getInteger    (c) == 3, NULL );
2330   fail_unless( ASTNode_getNumChildren(c) == 0, NULL );
2331 
2332   ASTNode_free(r);
2333 
2334   r = SBML_parseL3Formula("Power(1.1, 3)");
2335 
2336   fail_unless( ASTNode_getType       (r) == AST_POWER, NULL );
2337   fail_unless( ASTNode_getNumChildren(r) == 2  , NULL );
2338 
2339   c = ASTNode_getLeftChild(r);
2340 
2341   fail_unless( ASTNode_getType       (c) == AST_REAL, NULL );
2342   fail_unless( ASTNode_getReal       (c) == 1.1, NULL );
2343   fail_unless( ASTNode_getNumChildren(c) == 0, NULL );
2344 
2345   c = ASTNode_getRightChild(r);
2346 
2347   fail_unless( ASTNode_getType       (c) == AST_INTEGER, NULL );
2348   fail_unless( ASTNode_getInteger    (c) == 3, NULL );
2349   fail_unless( ASTNode_getNumChildren(c) == 0, NULL );
2350 
2351   ASTNode_free(r);
2352   // SBML_deleteL3Parser();
2353 
2354 }
2355 END_TEST
2356 
2357 
START_TEST(test_SBML_parseL3Formula_longint)2358 START_TEST (test_SBML_parseL3Formula_longint)
2359 {
2360   ASTNode_t *r = SBML_parseL3Formula("166112956810631");
2361 
2362   fail_unless( ASTNode_getType       (r) == AST_REAL, NULL );
2363   fail_unless( ASTNode_getReal       (r) == 166112956810631.0, NULL );
2364   fail_unless( ASTNode_getNumChildren(r) == 0  , NULL );
2365 
2366   ASTNode_free(r);
2367 
2368   // SBML_deleteL3Parser();
2369 }
2370 END_TEST
2371 
2372 
START_TEST(test_SBML_parseL3Formula_longdecimal)2373 START_TEST (test_SBML_parseL3Formula_longdecimal)
2374 {
2375   ASTNode_t *r = SBML_parseL3Formula("0.00166112956810631");
2376 
2377   fail_unless( ASTNode_getType       (r) == AST_REAL, NULL );
2378   fail_unless( ASTNode_getReal       (r) == 0.00166112956810631, NULL );
2379   fail_unless( ASTNode_getNumChildren(r) == 0  , NULL );
2380 
2381   ASTNode_free(r);
2382 
2383   // SBML_deleteL3Parser();
2384 }
2385 END_TEST
2386 
2387 
START_TEST(test_SBML_parseL3Formula_longnumberparen)2388 START_TEST (test_SBML_parseL3Formula_longnumberparen)
2389 {
2390   ASTNode_t *r = SBML_parseL3Formula("(0.00166112956810631)");
2391 
2392   fail_unless( ASTNode_getType       (r) == AST_REAL, NULL );
2393   fail_unless( ASTNode_getReal       (r) == 0.00166112956810631, NULL );
2394   fail_unless( ASTNode_getNumChildren(r) == 0  , NULL );
2395 
2396   ASTNode_free(r);
2397 
2398   // SBML_deleteL3Parser();
2399 }
2400 END_TEST
2401 
2402 
START_TEST(test_SBML_parseL3Formula_crazylong)2403 START_TEST (test_SBML_parseL3Formula_crazylong)
2404 {
2405   ASTNode_t *r = SBML_parseL3Formula("(1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890)");
2406 
2407   if (r==NULL)
2408   {
2409     char * error = SBML_getLastParseL3Error();
2410     fail_unless( !strcmp(error, "Error when parsing input '(1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890)' at position 312:  syntax error, unexpected end of string"), NULL);
2411     safe_free(error);
2412   }
2413   else {
2414     fail_unless( ASTNode_getType(r)             == AST_REAL, NULL );
2415     fail_unless( util_isInf(ASTNode_getReal(r)) ==  1, NULL );
2416     fail_unless( ASTNode_getNumChildren(r)      ==  0, NULL );
2417 
2418     ASTNode_free(r);
2419   }
2420 
2421   // SBML_deleteL3Parser();
2422 }
2423 END_TEST
2424 
2425 
START_TEST(test_SBML_parseL3Formula_easunit)2426 START_TEST (test_SBML_parseL3Formula_easunit)
2427 {
2428   ASTNode_t *r = SBML_parseL3Formula("1.01e");
2429 
2430   fail_unless( ASTNode_getType       (r) == AST_REAL, NULL );
2431   fail_unless( ASTNode_getReal       (r) == 1.01, NULL );
2432   fail_unless( ASTNode_getNumChildren(r) == 0  , NULL );
2433   char * units = ASTNode_getUnits(r);
2434   fail_unless( !strcmp(units, "e"), NULL );
2435   safe_free(units);
2436 
2437   ASTNode_free(r);
2438   // SBML_deleteL3Parser();
2439 
2440 }
2441 END_TEST
2442 
2443 
START_TEST(test_SBML_parseL3Formula_easunitparen)2444 START_TEST (test_SBML_parseL3Formula_easunitparen)
2445 {
2446   ASTNode_t *r = SBML_parseL3Formula("(1.01e)");
2447 
2448   fail_unless( ASTNode_getType       (r) == AST_REAL, NULL );
2449   fail_unless( ASTNode_getReal       (r) == 1.01, NULL );
2450   fail_unless( ASTNode_getNumChildren(r) == 0  , NULL );
2451   char * units = ASTNode_getUnits(r);
2452   fail_unless( !strcmp(units, "e"), NULL );
2453   safe_free(units);
2454 
2455   ASTNode_free(r);
2456   // SBML_deleteL3Parser();
2457 }
2458 END_TEST
2459 
2460 
START_TEST(test_SBML_parseL3Formula_easunitint)2461 START_TEST (test_SBML_parseL3Formula_easunitint)
2462 {
2463   ASTNode_t *r = SBML_parseL3Formula("101e");
2464 
2465   fail_unless( ASTNode_getType       (r) == AST_INTEGER, NULL );
2466   fail_unless( ASTNode_getInteger    (r) == 101, NULL );
2467   fail_unless( ASTNode_getNumChildren(r) == 0  , NULL );
2468   char * units = ASTNode_getUnits(r);
2469   fail_unless( !strcmp(units, "e"), NULL );
2470   safe_free(units);
2471 
2472   ASTNode_free(r);
2473   // SBML_deleteL3Parser();
2474 }
2475 END_TEST
2476 
2477 
START_TEST(test_SBML_parseL3Formula_ergunit)2478 START_TEST (test_SBML_parseL3Formula_ergunit)
2479 {
2480   ASTNode_t *r = SBML_parseL3Formula("101erg");
2481 
2482   fail_unless( ASTNode_getType       (r) == AST_INTEGER, NULL );
2483   fail_unless( ASTNode_getInteger    (r) == 101, NULL );
2484   fail_unless( ASTNode_getNumChildren(r) == 0  , NULL );
2485   char * units = ASTNode_getUnits(r);
2486   fail_unless( !strcmp(units, "erg"), NULL );
2487   safe_free(units);
2488 
2489   ASTNode_free(r);
2490   // SBML_deleteL3Parser();
2491 }
2492 END_TEST
2493 
2494 
START_TEST(test_SBML_parseL3Formula_longinterg)2495 START_TEST (test_SBML_parseL3Formula_longinterg)
2496 {
2497   ASTNode_t *r = SBML_parseL3Formula("166112956810631erg");
2498 
2499   fail_unless( ASTNode_getType       (r) == AST_REAL, NULL );
2500   fail_unless( ASTNode_getReal       (r) == 166112956810631.0, NULL );
2501   fail_unless( ASTNode_getNumChildren(r) == 0  , NULL );
2502   char * units = ASTNode_getUnits(r);
2503   fail_unless( !strcmp(units, "erg"), NULL );
2504   safe_free(units);
2505 
2506   ASTNode_free(r);
2507   // SBML_deleteL3Parser();
2508 }
2509 END_TEST
2510 
2511 
START_TEST(test_SBML_parseL3Formula_longdecimalerg)2512 START_TEST (test_SBML_parseL3Formula_longdecimalerg)
2513 {
2514   ASTNode_t *r = SBML_parseL3Formula("0.00166112956810631erg");
2515 
2516   fail_unless( ASTNode_getType       (r) == AST_REAL, NULL );
2517   fail_unless( ASTNode_getReal       (r) == 0.00166112956810631, NULL );
2518   fail_unless( ASTNode_getNumChildren(r) == 0  , NULL );
2519   char * units = ASTNode_getUnits(r);
2520   fail_unless( !strcmp(units, "erg"), NULL );
2521   safe_free(units);
2522 
2523   ASTNode_free(r);
2524   // SBML_deleteL3Parser();
2525 }
2526 END_TEST
2527 
2528 
START_TEST(test_SBML_parseL3Formula_longnumberparenerg)2529 START_TEST (test_SBML_parseL3Formula_longnumberparenerg)
2530 {
2531   ASTNode_t *r = SBML_parseL3Formula("(0.00166112956810631erg)");
2532 
2533   fail_unless( ASTNode_getType       (r) == AST_REAL, NULL );
2534   fail_unless( ASTNode_getReal       (r) == 0.00166112956810631, NULL );
2535   fail_unless( ASTNode_getNumChildren(r) == 0  , NULL );
2536   char * units = ASTNode_getUnits(r);
2537   fail_unless( !strcmp(units, "erg"), NULL );
2538   safe_free(units);
2539 
2540   ASTNode_free(r);
2541   // SBML_deleteL3Parser();
2542 }
2543 END_TEST
2544 
2545 
START_TEST(test_SBML_parseL3Formula_crazylongerg)2546 START_TEST (test_SBML_parseL3Formula_crazylongerg)
2547 {
2548   ASTNode_t *r = SBML_parseL3Formula("(1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890erg)");
2549 
2550   if (r==NULL)
2551   {
2552     char * error = SBML_getLastParseL3Error();
2553     fail_unless( !strcmp(error, "Error when parsing input '(1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890erg)' at position 311:  syntax error, unexpected end of string"), NULL);
2554     safe_free(error);
2555   }
2556   else {
2557     fail_unless( ASTNode_getType(r)             == AST_REAL, NULL );
2558     fail_unless( util_isInf(ASTNode_getReal(r)) ==  1, NULL );
2559     fail_unless( ASTNode_getNumChildren(r)      ==  0, NULL );
2560     char * units = ASTNode_getUnits(r);
2561     fail_unless( !strcmp(units, "erg"), NULL );
2562     safe_free(units);
2563 
2564     ASTNode_free(r);
2565   }
2566   // SBML_deleteL3Parser();
2567 }
2568 END_TEST
2569 
2570 
START_TEST(test_SBML_parseL3Formula_wrongnum)2571 START_TEST (test_SBML_parseL3Formula_wrongnum)
2572 {
2573   ASTNode_t *r = SBML_parseL3Formula("1.2.4");
2574 
2575   fail_unless(r == NULL, NULL);
2576   char * error = SBML_getLastParseL3Error();
2577   fail_unless( !strcmp(error, "Error when parsing input '1.2.4' at position 5:  syntax error, unexpected number"), NULL);
2578   safe_free(error);
2579   // SBML_deleteL3Parser();
2580 }
2581 END_TEST
2582 
2583 
START_TEST(test_SBML_parseL3Formula_wrongnum2)2584 START_TEST (test_SBML_parseL3Formula_wrongnum2)
2585 {
2586   ASTNode_t *r = SBML_parseL3Formula("1.2.");
2587 
2588   fail_unless(r == NULL, NULL);
2589   char * error = SBML_getLastParseL3Error();
2590   fail_unless( !strcmp(error, "Error when parsing input '1.2.' at position 4:  syntax error, unexpected $undefined"), NULL);
2591   safe_free(error);
2592   // SBML_deleteL3Parser();
2593 }
2594 END_TEST
2595 
2596 
START_TEST(test_SBML_parseL3Formula_lambda1)2597 START_TEST (test_SBML_parseL3Formula_lambda1)
2598 {
2599   ASTNode_t *r = SBML_parseL3Formula("lambda(3.3)");
2600 
2601   fail_unless( ASTNode_getType       (r) == AST_LAMBDA, NULL );
2602   fail_unless( ASTNode_getNumChildren(r) == 1  , NULL );
2603 
2604   ASTNode_t *c = ASTNode_getLeftChild(r);
2605 
2606   fail_unless( ASTNode_getType       (c) == AST_REAL, NULL );
2607   fail_unless( ASTNode_getReal       (c) == 3.3, NULL );
2608   fail_unless( ASTNode_getNumChildren(c) == 0, NULL );
2609 
2610   ASTNode_free(r);
2611   // SBML_deleteL3Parser();
2612 }
2613 END_TEST
2614 
2615 
START_TEST(test_SBML_parseL3Formula_lambda2)2616 START_TEST (test_SBML_parseL3Formula_lambda2)
2617 {
2618   ASTNode_t *r = SBML_parseL3Formula("lambda(x,x^3)");
2619   ASTNode_t *c;
2620 
2621 
2622   fail_unless( ASTNode_getType(r) == AST_LAMBDA , NULL );
2623   fail_unless( ASTNode_getNumChildren(r) == 2     , NULL );
2624 
2625   c = ASTNode_getLeftChild(r);
2626 
2627   fail_unless( ASTNode_getType       (c) == AST_NAME, NULL );
2628   fail_unless( !strcmp(ASTNode_getName(c), "x") , NULL );
2629   fail_unless( ASTNode_getNumChildren(c) == 0     , NULL );
2630 
2631   c = ASTNode_getRightChild(r);
2632 
2633   fail_unless( ASTNode_getType       (c) == AST_POWER, NULL );
2634   fail_unless( ASTNode_getNumChildren(c) == 2     , NULL );
2635 
2636   c = ASTNode_getLeftChild(c);
2637 
2638   fail_unless( ASTNode_getType       (c) == AST_NAME, NULL );
2639   fail_unless( !strcmp(ASTNode_getName(c), "x") , NULL );
2640   fail_unless( ASTNode_getNumChildren(c) == 0     , NULL );
2641 
2642   c = ASTNode_getRightChild(r->getRightChild());
2643 
2644   fail_unless( ASTNode_getType       (c) == AST_INTEGER, NULL );
2645   fail_unless( ASTNode_getInteger    (c) == 3, NULL );
2646   fail_unless( ASTNode_getNumChildren(c) == 0, NULL );
2647 
2648 
2649   ASTNode_free(r);
2650   // SBML_deleteL3Parser();
2651 }
2652 END_TEST
2653 
2654 
START_TEST(test_SBML_parseL3Formula_lambda3)2655 START_TEST (test_SBML_parseL3Formula_lambda3)
2656 {
2657   ASTNode_t *r = SBML_parseL3Formula("lambda(x, y, x+y)");
2658   ASTNode_t *c;
2659 
2660 
2661   fail_unless( ASTNode_getType(r) == AST_LAMBDA , NULL );
2662   fail_unless( ASTNode_getNumChildren(r) == 3     , NULL );
2663 
2664   c = ASTNode_getChild(r, 0);
2665 
2666   fail_unless( ASTNode_getType       (c) == AST_NAME, NULL );
2667   fail_unless( !strcmp(ASTNode_getName(c), "x") , NULL );
2668   fail_unless( ASTNode_getNumChildren(c) == 0     , NULL );
2669 
2670   c = ASTNode_getChild(r, 1);
2671 
2672   fail_unless( ASTNode_getType       (c) == AST_NAME, NULL );
2673   fail_unless( !strcmp(ASTNode_getName(c), "y") , NULL );
2674   fail_unless( ASTNode_getNumChildren(c) == 0     , NULL );
2675 
2676   c = ASTNode_getChild(r, 2);
2677 
2678   fail_unless( ASTNode_getType       (c) == AST_PLUS, NULL );
2679   fail_unless( ASTNode_getNumChildren(c) == 2     , NULL );
2680 
2681   c = ASTNode_getLeftChild(c);
2682 
2683   fail_unless( ASTNode_getType       (c) == AST_NAME, NULL );
2684   fail_unless( !strcmp(ASTNode_getName(c), "x") , NULL );
2685   fail_unless( ASTNode_getNumChildren(c) == 0     , NULL );
2686 
2687   c = ASTNode_getRightChild(r->getChild(2));
2688 
2689   fail_unless( ASTNode_getType       (c) == AST_NAME, NULL );
2690   fail_unless( !strcmp(ASTNode_getName(c), "y") , NULL );
2691   fail_unless( ASTNode_getNumChildren(c) == 0, NULL );
2692 
2693 
2694   ASTNode_free(r);
2695   // SBML_deleteL3Parser();
2696 }
2697 END_TEST
2698 
2699 
START_TEST(test_SBML_parseL3Formula_lambda4)2700 START_TEST (test_SBML_parseL3Formula_lambda4)
2701 {
2702   ASTNode_t *r = SBML_parseL3Formula("lambda(x,NaN)");
2703   ASTNode_t *c;
2704 
2705 
2706   fail_unless( ASTNode_getType(r) == AST_LAMBDA , NULL );
2707   fail_unless( ASTNode_getNumChildren(r) == 2     , NULL );
2708 
2709   c = ASTNode_getLeftChild(r);
2710 
2711   fail_unless( ASTNode_getType       (c) == AST_NAME, NULL );
2712   fail_unless( !strcmp(ASTNode_getName(c), "x") , NULL );
2713   fail_unless( ASTNode_getNumChildren(c) == 0     , NULL );
2714 
2715   c = ASTNode_getRightChild(r);
2716 
2717   fail_unless( ASTNode_getType(c)        == AST_REAL, NULL );
2718   fail_unless( util_isNaN(ASTNode_getReal(c)) ==  1, NULL );
2719   fail_unless( ASTNode_getNumChildren(c) ==  0, NULL );
2720 
2721 
2722   ASTNode_free(r);
2723   // SBML_deleteL3Parser();
2724 }
2725 END_TEST
2726 
2727 
START_TEST(test_SBML_parseL3Formula_lambdaerr)2728 START_TEST (test_SBML_parseL3Formula_lambdaerr)
2729 {
2730   ASTNode_t *r = SBML_parseL3Formula("lambda()");
2731 
2732   fail_unless(r == NULL, NULL);
2733   char * error = SBML_getLastParseL3Error();
2734   fail_unless( !strcmp(error, "Error when parsing input 'lambda()' at position 8:  The function 'lambda' takes at least one argument, but none were found."), NULL);
2735   safe_free(error);
2736   // SBML_deleteL3Parser();
2737 }
2738 END_TEST
2739 
2740 
START_TEST(test_SBML_parseL3Formula_sqrterr)2741 START_TEST (test_SBML_parseL3Formula_sqrterr)
2742 {
2743   ASTNode_t *r = SBML_parseL3Formula("sqrt(x,y)");
2744 
2745   fail_unless(r == NULL, NULL);
2746   char * error = SBML_getLastParseL3Error();
2747   fail_unless( !strcmp(error, "Error when parsing input 'sqrt(x,y)' at position 9:  The function 'sqrt' takes exactly one argument."), NULL);
2748   safe_free(error);
2749   // SBML_deleteL3Parser();
2750 }
2751 END_TEST
2752 
2753 
START_TEST(test_SBML_parseL3Formula_precedence1)2754 START_TEST (test_SBML_parseL3Formula_precedence1)
2755 {
2756   ASTNode_t *r = SBML_parseL3Formula("-2^4");
2757   ASTNode_t *c;
2758 
2759 
2760 
2761   fail_unless( ASTNode_getType       (r) == AST_MINUS, NULL );
2762   fail_unless( ASTNode_getCharacter  (r) == '-', NULL );
2763   fail_unless( ASTNode_getNumChildren(r) == 1  , NULL );
2764 
2765   c = ASTNode_getLeftChild(r);
2766 
2767   fail_unless( ASTNode_getType       (c) == AST_POWER, NULL );
2768   fail_unless( ASTNode_getCharacter  (c) == '^', NULL );
2769   fail_unless( ASTNode_getNumChildren(c) == 2, NULL );
2770 
2771   c = ASTNode_getLeftChild(c);
2772 
2773   fail_unless( ASTNode_getType       (c) == AST_INTEGER, NULL );
2774   fail_unless( ASTNode_getInteger    (c) == 2, NULL );
2775   fail_unless( ASTNode_getNumChildren(c) == 0, NULL );
2776 
2777   c = ASTNode_getRightChild( ASTNode_getLeftChild(r) );
2778 
2779   fail_unless( ASTNode_getType       (c) == AST_INTEGER, NULL );
2780   fail_unless( ASTNode_getInteger    (c) == 4, NULL );
2781   fail_unless( ASTNode_getNumChildren(c) == 0, NULL );
2782 
2783   ASTNode_free(r);
2784   // SBML_deleteL3Parser();
2785 }
2786 END_TEST
2787 
2788 
START_TEST(test_SBML_parseL3Formula_precedence2)2789 START_TEST (test_SBML_parseL3Formula_precedence2)
2790 {
2791   ASTNode_t *r = SBML_parseL3Formula("!a+b");
2792   ASTNode_t *c;
2793 
2794 
2795 
2796   fail_unless( ASTNode_getType       (r) == AST_PLUS, NULL );
2797   fail_unless( ASTNode_getCharacter  (r) == '+', NULL );
2798   fail_unless( ASTNode_getNumChildren(r) == 2  , NULL );
2799 
2800   c = ASTNode_getLeftChild(r);
2801 
2802   fail_unless( ASTNode_getType       (c) == AST_LOGICAL_NOT, NULL );
2803   fail_unless( ASTNode_getNumChildren(c) == 1, NULL );
2804 
2805   c = ASTNode_getLeftChild(c);
2806 
2807   fail_unless( ASTNode_getType       (c) == AST_NAME, NULL );
2808   fail_unless( !strcmp(ASTNode_getName(c), "a"), NULL );
2809   fail_unless( ASTNode_getNumChildren(c) == 0, NULL );
2810 
2811   c = ASTNode_getRightChild(r);
2812 
2813   fail_unless( ASTNode_getType       (c) == AST_NAME, NULL );
2814   fail_unless( !strcmp(ASTNode_getName(c), "b"), NULL );
2815   fail_unless( ASTNode_getNumChildren(c) == 0, NULL );
2816 
2817   ASTNode_free(r);
2818   // SBML_deleteL3Parser();
2819 }
2820 END_TEST
2821 
2822 
2823 
2824 
START_TEST(test_SBML_parseL3Formula_combinedRelational_allLT)2825 START_TEST (test_SBML_parseL3Formula_combinedRelational_allLT)
2826 {
2827   ASTNode_t *r = SBML_parseL3Formula("x < y < z");
2828 
2829   fail_unless( ASTNode_getType        (r) == AST_RELATIONAL_LT);
2830   fail_unless( ASTNode_getNumChildren (r) == 3   );
2831 
2832   ASTNode_t *c = ASTNode_getChild(r, 0);
2833 
2834   fail_unless( ASTNode_getType        (c) == AST_NAME);
2835   fail_unless( !strcmp(ASTNode_getName(c), "x"));
2836   fail_unless( ASTNode_getNumChildren (c) == 0);
2837 
2838   c = ASTNode_getChild(r, 1);
2839 
2840   fail_unless( ASTNode_getType        (c) == AST_NAME);
2841   fail_unless( !strcmp(ASTNode_getName(c), "y"));
2842   fail_unless( ASTNode_getNumChildren(c) == 0 );
2843 
2844   c = ASTNode_getChild(r, 2);
2845 
2846   fail_unless( ASTNode_getType        (c) == AST_NAME);
2847   fail_unless( !strcmp(ASTNode_getName(c), "z"));
2848   fail_unless( ASTNode_getNumChildren(c) == 0 );
2849 
2850   ASTNode_free(r);
2851 }
2852 END_TEST
2853 
2854 
START_TEST(test_SBML_parseL3Formula_combinedRelational_allGT)2855 START_TEST (test_SBML_parseL3Formula_combinedRelational_allGT)
2856 {
2857   ASTNode_t *r = SBML_parseL3Formula("x > y > z");
2858 
2859   fail_unless( ASTNode_getType        (r) == AST_RELATIONAL_GT);
2860   fail_unless( ASTNode_getNumChildren (r) == 3   );
2861 
2862   ASTNode_t *c = ASTNode_getChild(r, 0);
2863 
2864   fail_unless( ASTNode_getType        (c) == AST_NAME);
2865   fail_unless( !strcmp(ASTNode_getName(c), "x"));
2866   fail_unless( ASTNode_getNumChildren (c) == 0);
2867 
2868   c = ASTNode_getChild(r, 1);
2869 
2870   fail_unless( ASTNode_getType        (c) == AST_NAME);
2871   fail_unless( !strcmp(ASTNode_getName(c), "y"));
2872   fail_unless( ASTNode_getNumChildren(c) == 0 );
2873 
2874   c = ASTNode_getChild(r, 2);
2875 
2876   fail_unless( ASTNode_getType        (c) == AST_NAME);
2877   fail_unless( !strcmp(ASTNode_getName(c), "z"));
2878   fail_unless( ASTNode_getNumChildren(c) == 0 );
2879 
2880   ASTNode_free(r);
2881 }
2882 END_TEST
2883 
2884 
START_TEST(test_SBML_parseL3Formula_combinedRelational_allLEQ)2885 START_TEST (test_SBML_parseL3Formula_combinedRelational_allLEQ)
2886 {
2887   ASTNode_t *r = SBML_parseL3Formula("x <= y <= z");
2888 
2889   fail_unless( ASTNode_getType        (r) == AST_RELATIONAL_LEQ);
2890   fail_unless( ASTNode_getNumChildren (r) == 3   );
2891 
2892   ASTNode_t *c = ASTNode_getChild(r, 0);
2893 
2894   fail_unless( ASTNode_getType        (c) == AST_NAME);
2895   fail_unless( !strcmp(ASTNode_getName(c), "x"));
2896   fail_unless( ASTNode_getNumChildren (c) == 0);
2897 
2898   c = ASTNode_getChild(r, 1);
2899 
2900   fail_unless( ASTNode_getType        (c) == AST_NAME);
2901   fail_unless( !strcmp(ASTNode_getName(c), "y"));
2902   fail_unless( ASTNode_getNumChildren(c) == 0 );
2903 
2904   c = ASTNode_getChild(r, 2);
2905 
2906   fail_unless( ASTNode_getType        (c) == AST_NAME);
2907   fail_unless( !strcmp(ASTNode_getName(c), "z"));
2908   fail_unless( ASTNode_getNumChildren(c) == 0 );
2909 
2910   ASTNode_free(r);
2911 }
2912 END_TEST
2913 
2914 
START_TEST(test_SBML_parseL3Formula_combinedRelational_allGEQ)2915 START_TEST (test_SBML_parseL3Formula_combinedRelational_allGEQ)
2916 {
2917   ASTNode_t *r = SBML_parseL3Formula("x >= y >= z");
2918 
2919   fail_unless( ASTNode_getType        (r) == AST_RELATIONAL_GEQ);
2920   fail_unless( ASTNode_getNumChildren (r) == 3   );
2921 
2922   ASTNode_t *c = ASTNode_getChild(r, 0);
2923 
2924   fail_unless( ASTNode_getType        (c) == AST_NAME);
2925   fail_unless( !strcmp(ASTNode_getName(c), "x"));
2926   fail_unless( ASTNode_getNumChildren (c) == 0);
2927 
2928   c = ASTNode_getChild(r, 1);
2929 
2930   fail_unless( ASTNode_getType        (c) == AST_NAME);
2931   fail_unless( !strcmp(ASTNode_getName(c), "y"));
2932   fail_unless( ASTNode_getNumChildren(c) == 0 );
2933 
2934   c = ASTNode_getChild(r, 2);
2935 
2936   fail_unless( ASTNode_getType        (c) == AST_NAME);
2937   fail_unless( !strcmp(ASTNode_getName(c), "z"));
2938   fail_unless( ASTNode_getNumChildren(c) == 0 );
2939 
2940   ASTNode_free(r);
2941 }
2942 END_TEST
2943 
2944 
START_TEST(test_SBML_parseL3Formula_combinedRelational_allEQ)2945 START_TEST (test_SBML_parseL3Formula_combinedRelational_allEQ)
2946 {
2947   ASTNode_t *r = SBML_parseL3Formula("x == y == z");
2948 
2949   fail_unless( ASTNode_getType        (r) == AST_RELATIONAL_EQ);
2950   fail_unless( ASTNode_getNumChildren (r) == 3   );
2951 
2952   ASTNode_t *c = ASTNode_getChild(r, 0);
2953 
2954   fail_unless( ASTNode_getType        (c) == AST_NAME);
2955   fail_unless( !strcmp(ASTNode_getName(c), "x"));
2956   fail_unless( ASTNode_getNumChildren (c) == 0);
2957 
2958   c = ASTNode_getChild(r, 1);
2959 
2960   fail_unless( ASTNode_getType        (c) == AST_NAME);
2961   fail_unless( !strcmp(ASTNode_getName(c), "y"));
2962   fail_unless( ASTNode_getNumChildren(c) == 0 );
2963 
2964   c = ASTNode_getChild(r, 2);
2965 
2966   fail_unless( ASTNode_getType        (c) == AST_NAME);
2967   fail_unless( !strcmp(ASTNode_getName(c), "z"));
2968   fail_unless( ASTNode_getNumChildren(c) == 0 );
2969 
2970   ASTNode_free(r);
2971 }
2972 END_TEST
2973 
2974 
START_TEST(test_SBML_parseL3Formula_combinedRelational_allNEQ)2975 START_TEST (test_SBML_parseL3Formula_combinedRelational_allNEQ)
2976 {
2977   ASTNode_t *r = SBML_parseL3Formula("x != y != z");
2978 
2979   fail_unless( ASTNode_getType        (r) == AST_LOGICAL_AND);
2980   fail_unless( ASTNode_getNumChildren (r) == 2   );
2981 
2982   ASTNode_t *c = ASTNode_getChild(r, 0);
2983   fail_unless( ASTNode_getType        (c) == AST_RELATIONAL_NEQ);
2984 
2985   ASTNode_t *c2 = ASTNode_getChild(c, 0);
2986   fail_unless( ASTNode_getType        (c2) == AST_NAME);
2987   fail_unless( !strcmp(ASTNode_getName(c2), "x"));
2988   fail_unless( ASTNode_getNumChildren (c2) == 0);
2989 
2990   c2 = ASTNode_getChild(c, 1);
2991   fail_unless( ASTNode_getType        (c2) == AST_NAME);
2992   fail_unless( !strcmp(ASTNode_getName(c2), "y"));
2993   fail_unless( ASTNode_getNumChildren(c2) == 0 );
2994 
2995   c = ASTNode_getChild(r, 1);
2996   fail_unless( ASTNode_getType        (c) == AST_RELATIONAL_NEQ);
2997 
2998   c2 = ASTNode_getChild(c, 0);
2999   fail_unless( ASTNode_getType        (c2) == AST_NAME);
3000   fail_unless( !strcmp(ASTNode_getName(c2), "y"));
3001   fail_unless( ASTNode_getNumChildren (c2) == 0);
3002 
3003   c2 = ASTNode_getChild(c, 1);
3004   fail_unless( ASTNode_getType        (c2) == AST_NAME);
3005   fail_unless( !strcmp(ASTNode_getName(c2), "z"));
3006   fail_unless( ASTNode_getNumChildren(c2) == 0 );
3007 
3008 
3009   ASTNode_free(r);
3010 }
3011 END_TEST
3012 
3013 
START_TEST(test_SBML_parseL3Formula_combinedRelational_mixed1)3014 START_TEST (test_SBML_parseL3Formula_combinedRelational_mixed1)
3015 {
3016   ASTNode_t *r = SBML_parseL3Formula("x < y <= z");
3017 
3018   fail_unless( ASTNode_getType        (r) == AST_LOGICAL_AND);
3019   fail_unless( ASTNode_getNumChildren (r) == 2   );
3020 
3021   ASTNode_t *c = ASTNode_getChild(r, 0);
3022   fail_unless( ASTNode_getType        (c) == AST_RELATIONAL_LT);
3023 
3024   ASTNode_t *c2 = ASTNode_getChild(c, 0);
3025   fail_unless( ASTNode_getType        (c2) == AST_NAME);
3026   fail_unless( !strcmp(ASTNode_getName(c2), "x"));
3027   fail_unless( ASTNode_getNumChildren (c2) == 0);
3028 
3029   c2 = ASTNode_getChild(c, 1);
3030   fail_unless( ASTNode_getType        (c2) == AST_NAME);
3031   fail_unless( !strcmp(ASTNode_getName(c2), "y"));
3032   fail_unless( ASTNode_getNumChildren(c2) == 0 );
3033 
3034   c = ASTNode_getChild(r, 1);
3035   fail_unless( ASTNode_getType        (c) == AST_RELATIONAL_LEQ);
3036 
3037   c2 = ASTNode_getChild(c, 0);
3038   fail_unless( ASTNode_getType        (c2) == AST_NAME);
3039   fail_unless( !strcmp(ASTNode_getName(c2), "y"));
3040   fail_unless( ASTNode_getNumChildren (c2) == 0);
3041 
3042   c2 = ASTNode_getChild(c, 1);
3043   fail_unless( ASTNode_getType        (c2) == AST_NAME);
3044   fail_unless( !strcmp(ASTNode_getName(c2), "z"));
3045   fail_unless( ASTNode_getNumChildren(c2) == 0 );
3046 
3047 
3048   ASTNode_free(r);
3049 }
3050 END_TEST
3051 
3052 
START_TEST(test_SBML_parseL3Formula_combinedRelational_mixed2)3053 START_TEST (test_SBML_parseL3Formula_combinedRelational_mixed2)
3054 {
3055   ASTNode_t *r = SBML_parseL3Formula("x > y < z");
3056 
3057   fail_unless( ASTNode_getType        (r) == AST_LOGICAL_AND);
3058   fail_unless( ASTNode_getNumChildren (r) == 2   );
3059 
3060   ASTNode_t *c = ASTNode_getChild(r, 0);
3061   fail_unless( ASTNode_getType        (c) == AST_RELATIONAL_GT);
3062 
3063   ASTNode_t *c2 = ASTNode_getChild(c, 0);
3064   fail_unless( ASTNode_getType        (c2) == AST_NAME);
3065   fail_unless( !strcmp(ASTNode_getName(c2), "x"));
3066   fail_unless( ASTNode_getNumChildren (c2) == 0);
3067 
3068   c2 = ASTNode_getChild(c, 1);
3069   fail_unless( ASTNode_getType        (c2) == AST_NAME);
3070   fail_unless( !strcmp(ASTNode_getName(c2), "y"));
3071   fail_unless( ASTNode_getNumChildren(c2) == 0 );
3072 
3073   c = ASTNode_getChild(r, 1);
3074   fail_unless( ASTNode_getType        (c) == AST_RELATIONAL_LT);
3075 
3076   c2 = ASTNode_getChild(c, 0);
3077   fail_unless( ASTNode_getType        (c2) == AST_NAME);
3078   fail_unless( !strcmp(ASTNode_getName(c2), "y"));
3079   fail_unless( ASTNode_getNumChildren (c2) == 0);
3080 
3081   c2 = ASTNode_getChild(c, 1);
3082   fail_unless( ASTNode_getType        (c2) == AST_NAME);
3083   fail_unless( !strcmp(ASTNode_getName(c2), "z"));
3084   fail_unless( ASTNode_getNumChildren(c2) == 0 );
3085 
3086 
3087   ASTNode_free(r);
3088 }
3089 END_TEST
3090 
3091 
START_TEST(test_SBML_parseL3Formula_combinedRelational_allLT_many)3092 START_TEST (test_SBML_parseL3Formula_combinedRelational_allLT_many)
3093 {
3094   ASTNode_t *r = SBML_parseL3Formula("x < y < z < p < d < q");
3095 
3096   fail_unless( ASTNode_getType        (r) == AST_RELATIONAL_LT);
3097   fail_unless( ASTNode_getNumChildren (r) == 6   );
3098 
3099   ASTNode_t *c = ASTNode_getChild(r, 0);
3100 
3101   fail_unless( ASTNode_getType        (c) == AST_NAME);
3102   fail_unless( !strcmp(ASTNode_getName(c), "x"));
3103   fail_unless( ASTNode_getNumChildren (c) == 0);
3104 
3105   c = ASTNode_getChild(r, 1);
3106 
3107   fail_unless( ASTNode_getType        (c) == AST_NAME);
3108   fail_unless( !strcmp(ASTNode_getName(c), "y"));
3109   fail_unless( ASTNode_getNumChildren(c) == 0 );
3110 
3111   c = ASTNode_getChild(r, 2);
3112 
3113   fail_unless( ASTNode_getType        (c) == AST_NAME);
3114   fail_unless( !strcmp(ASTNode_getName(c), "z"));
3115   fail_unless( ASTNode_getNumChildren(c) == 0 );
3116 
3117   c = ASTNode_getChild(r, 3);
3118 
3119   fail_unless( ASTNode_getType        (c) == AST_NAME);
3120   fail_unless( !strcmp(ASTNode_getName(c), "p"));
3121   fail_unless( ASTNode_getNumChildren(c) == 0 );
3122 
3123   c = ASTNode_getChild(r, 4);
3124 
3125   fail_unless( ASTNode_getType        (c) == AST_NAME);
3126   fail_unless( !strcmp(ASTNode_getName(c), "d"));
3127   fail_unless( ASTNode_getNumChildren(c) == 0 );
3128 
3129   c = ASTNode_getChild(r, 5);
3130 
3131   fail_unless( ASTNode_getType        (c) == AST_NAME);
3132   fail_unless( !strcmp(ASTNode_getName(c), "q"));
3133   fail_unless( ASTNode_getNumChildren(c) == 0 );
3134 
3135   ASTNode_free(r);
3136 }
3137 END_TEST
3138 
3139 
START_TEST(test_SBML_parseL3Formula_combinedRelational_mixed_many1)3140 START_TEST (test_SBML_parseL3Formula_combinedRelational_mixed_many1)
3141 {
3142   ASTNode_t *r = SBML_parseL3Formula("x < y <= z <= p");
3143 
3144   fail_unless( ASTNode_getType        (r) == AST_LOGICAL_AND);
3145   fail_unless( ASTNode_getNumChildren (r) == 2   );
3146 
3147   ASTNode_t *c = ASTNode_getChild(r, 0);
3148   fail_unless( ASTNode_getType        (c) == AST_RELATIONAL_LT);
3149   fail_unless( ASTNode_getNumChildren (c) == 2   );
3150 
3151   ASTNode_t *c2 = ASTNode_getChild(c, 0);
3152   fail_unless( ASTNode_getType        (c2) == AST_NAME);
3153   fail_unless( !strcmp(ASTNode_getName(c2), "x"));
3154   fail_unless( ASTNode_getNumChildren (c2) == 0);
3155 
3156   c2 = ASTNode_getChild(c, 1);
3157   fail_unless( ASTNode_getType        (c2) == AST_NAME);
3158   fail_unless( !strcmp(ASTNode_getName(c2), "y"));
3159   fail_unless( ASTNode_getNumChildren(c2) == 0 );
3160 
3161   c = ASTNode_getChild(r, 1);
3162   fail_unless( ASTNode_getType        (c) == AST_RELATIONAL_LEQ);
3163   fail_unless( ASTNode_getNumChildren (c) == 3   );
3164 
3165   c2 = ASTNode_getChild(c, 0);
3166   fail_unless( ASTNode_getType        (c2) == AST_NAME);
3167   fail_unless( !strcmp(ASTNode_getName(c2), "y"));
3168   fail_unless( ASTNode_getNumChildren (c2) == 0);
3169 
3170   c2 = ASTNode_getChild(c, 1);
3171   fail_unless( ASTNode_getType        (c2) == AST_NAME);
3172   fail_unless( !strcmp(ASTNode_getName(c2), "z"));
3173   fail_unless( ASTNode_getNumChildren(c2) == 0 );
3174 
3175   c2 = ASTNode_getChild(c, 2);
3176   fail_unless( ASTNode_getType        (c2) == AST_NAME);
3177   fail_unless( !strcmp(ASTNode_getName(c2), "p"));
3178   fail_unless( ASTNode_getNumChildren(c2) == 0 );
3179 
3180 
3181   ASTNode_free(r);
3182 }
3183 END_TEST
3184 
3185 
START_TEST(test_SBML_parseL3Formula_combinedRelational_mixed_many2)3186 START_TEST (test_SBML_parseL3Formula_combinedRelational_mixed_many2)
3187 {
3188   ASTNode_t *r = SBML_parseL3Formula("x < y < z <= p");
3189 
3190   fail_unless( ASTNode_getType        (r) == AST_LOGICAL_AND);
3191   fail_unless( ASTNode_getNumChildren (r) == 2   );
3192 
3193   ASTNode_t *c = ASTNode_getChild(r, 0);
3194   fail_unless( ASTNode_getType        (c) == AST_RELATIONAL_LT);
3195   fail_unless( ASTNode_getNumChildren (c) == 3   );
3196 
3197   ASTNode_t *c2 = ASTNode_getChild(c, 0);
3198   fail_unless( ASTNode_getType        (c2) == AST_NAME);
3199   fail_unless( !strcmp(ASTNode_getName(c2), "x"));
3200   fail_unless( ASTNode_getNumChildren (c2) == 0);
3201 
3202   c2 = ASTNode_getChild(c, 1);
3203   fail_unless( ASTNode_getType        (c2) == AST_NAME);
3204   fail_unless( !strcmp(ASTNode_getName(c2), "y"));
3205   fail_unless( ASTNode_getNumChildren(c2) == 0 );
3206 
3207   c2 = ASTNode_getChild(c, 2);
3208   fail_unless( ASTNode_getType        (c2) == AST_NAME);
3209   fail_unless( !strcmp(ASTNode_getName(c2), "z"));
3210   fail_unless( ASTNode_getNumChildren(c2) == 0 );
3211 
3212   c = ASTNode_getChild(r, 1);
3213   fail_unless( ASTNode_getType        (c) == AST_RELATIONAL_LEQ);
3214   fail_unless( ASTNode_getNumChildren (c) == 2   );
3215 
3216   c2 = ASTNode_getChild(c, 0);
3217   fail_unless( ASTNode_getType        (c2) == AST_NAME);
3218   fail_unless( !strcmp(ASTNode_getName(c2), "z"));
3219   fail_unless( ASTNode_getNumChildren(c2) == 0 );
3220 
3221   c2 = ASTNode_getChild(c, 1);
3222   fail_unless( ASTNode_getType        (c2) == AST_NAME);
3223   fail_unless( !strcmp(ASTNode_getName(c2), "p"));
3224   fail_unless( ASTNode_getNumChildren(c2) == 0 );
3225 
3226 
3227   ASTNode_free(r);
3228 }
3229 END_TEST
3230 
3231 
START_TEST(test_SBML_parseL3Formula_combinedRelational_mixed_many3)3232 START_TEST (test_SBML_parseL3Formula_combinedRelational_mixed_many3)
3233 {
3234   ASTNode_t *r = SBML_parseL3Formula("x < y < z <= p <= d");
3235 
3236   fail_unless( ASTNode_getType        (r) == AST_LOGICAL_AND);
3237   fail_unless( ASTNode_getNumChildren (r) == 2   );
3238 
3239   ASTNode_t *c = ASTNode_getChild(r, 0);
3240   fail_unless( ASTNode_getType        (c) == AST_RELATIONAL_LT);
3241   fail_unless( ASTNode_getNumChildren (c) == 3   );
3242 
3243   ASTNode_t *c2 = ASTNode_getChild(c, 0);
3244   fail_unless( ASTNode_getType        (c2) == AST_NAME);
3245   fail_unless( !strcmp(ASTNode_getName(c2), "x"));
3246   fail_unless( ASTNode_getNumChildren (c2) == 0);
3247 
3248   c2 = ASTNode_getChild(c, 1);
3249   fail_unless( ASTNode_getType        (c2) == AST_NAME);
3250   fail_unless( !strcmp(ASTNode_getName(c2), "y"));
3251   fail_unless( ASTNode_getNumChildren(c2) == 0 );
3252 
3253   c2 = ASTNode_getChild(c, 2);
3254   fail_unless( ASTNode_getType        (c2) == AST_NAME);
3255   fail_unless( !strcmp(ASTNode_getName(c2), "z"));
3256   fail_unless( ASTNode_getNumChildren(c2) == 0 );
3257 
3258   c = ASTNode_getChild(r, 1);
3259   fail_unless( ASTNode_getType        (c) == AST_RELATIONAL_LEQ);
3260   fail_unless( ASTNode_getNumChildren (c) == 3   );
3261 
3262   c2 = ASTNode_getChild(c, 0);
3263   fail_unless( ASTNode_getType        (c2) == AST_NAME);
3264   fail_unless( !strcmp(ASTNode_getName(c2), "z"));
3265   fail_unless( ASTNode_getNumChildren(c2) == 0 );
3266 
3267   c2 = ASTNode_getChild(c, 1);
3268   fail_unless( ASTNode_getType        (c2) == AST_NAME);
3269   fail_unless( !strcmp(ASTNode_getName(c2), "p"));
3270   fail_unless( ASTNode_getNumChildren(c2) == 0 );
3271 
3272   c2 = ASTNode_getChild(c, 2);
3273   fail_unless( ASTNode_getType        (c2) == AST_NAME);
3274   fail_unless( !strcmp(ASTNode_getName(c2), "d"));
3275   fail_unless( ASTNode_getNumChildren(c2) == 0 );
3276 
3277 
3278   ASTNode_free(r);
3279 }
3280 END_TEST
3281 
3282 
START_TEST(test_SBML_parseL3Formula_combinedRelational_mixed_many4)3283 START_TEST (test_SBML_parseL3Formula_combinedRelational_mixed_many4)
3284 {
3285   ASTNode_t *r = SBML_parseL3Formula("x < y <= z <= p == q");
3286 
3287   fail_unless( ASTNode_getType        (r) == AST_LOGICAL_AND);
3288   fail_unless( ASTNode_getNumChildren (r) == 3   );
3289 
3290   ASTNode_t *c = ASTNode_getChild(r, 0);
3291   fail_unless( ASTNode_getType        (c) == AST_RELATIONAL_LT);
3292   fail_unless( ASTNode_getNumChildren (c) == 2   );
3293 
3294   ASTNode_t *c2 = ASTNode_getChild(c, 0);
3295   fail_unless( ASTNode_getType        (c2) == AST_NAME);
3296   fail_unless( !strcmp(ASTNode_getName(c2), "x"));
3297   fail_unless( ASTNode_getNumChildren (c2) == 0);
3298 
3299   c2 = ASTNode_getChild(c, 1);
3300   fail_unless( ASTNode_getType        (c2) == AST_NAME);
3301   fail_unless( !strcmp(ASTNode_getName(c2), "y"));
3302   fail_unless( ASTNode_getNumChildren(c2) == 0 );
3303 
3304   c = ASTNode_getChild(r, 1);
3305   fail_unless( ASTNode_getType        (c) == AST_RELATIONAL_LEQ);
3306   fail_unless( ASTNode_getNumChildren (c) == 3   );
3307 
3308   c2 = ASTNode_getChild(c, 0);
3309   fail_unless( ASTNode_getType        (c2) == AST_NAME);
3310   fail_unless( !strcmp(ASTNode_getName(c2), "y"));
3311   fail_unless( ASTNode_getNumChildren (c2) == 0);
3312 
3313   c2 = ASTNode_getChild(c, 1);
3314   fail_unless( ASTNode_getType        (c2) == AST_NAME);
3315   fail_unless( !strcmp(ASTNode_getName(c2), "z"));
3316   fail_unless( ASTNode_getNumChildren(c2) == 0 );
3317 
3318   c2 = ASTNode_getChild(c, 2);
3319   fail_unless( ASTNode_getType        (c2) == AST_NAME);
3320   fail_unless( !strcmp(ASTNode_getName(c2), "p"));
3321   fail_unless( ASTNode_getNumChildren(c2) == 0 );
3322 
3323   c = ASTNode_getChild(r, 2);
3324   fail_unless( ASTNode_getType        (c) == AST_RELATIONAL_EQ);
3325   fail_unless( ASTNode_getNumChildren (c) == 2   );
3326 
3327   c2 = ASTNode_getChild(c, 0);
3328   fail_unless( ASTNode_getType        (c2) == AST_NAME);
3329   fail_unless( !strcmp(ASTNode_getName(c2), "p"));
3330   fail_unless( ASTNode_getNumChildren (c2) == 0);
3331 
3332   c2 = ASTNode_getChild(c, 1);
3333   fail_unless( ASTNode_getType        (c2) == AST_NAME);
3334   fail_unless( !strcmp(ASTNode_getName(c2), "q"));
3335   fail_unless( ASTNode_getNumChildren(c2) == 0 );
3336 
3337 
3338   ASTNode_free(r);
3339 }
3340 END_TEST
3341 
3342 
START_TEST(test_SBML_parseL3Formula_combinedRelational_mixed_many5)3343 START_TEST (test_SBML_parseL3Formula_combinedRelational_mixed_many5)
3344 {
3345   ASTNode_t *r = SBML_parseL3Formula("x < y <= z == p >= q > r != s");
3346 
3347   fail_unless( ASTNode_getType        (r) == AST_LOGICAL_AND);
3348   fail_unless( ASTNode_getNumChildren (r) == 6   );
3349 
3350   ASTNode_t *c = ASTNode_getChild(r, 0);
3351   fail_unless( ASTNode_getType        (c) == AST_RELATIONAL_LT);
3352   fail_unless( ASTNode_getNumChildren (c) == 2   );
3353 
3354   ASTNode_t *c2 = ASTNode_getChild(c, 0);
3355   fail_unless( ASTNode_getType        (c2) == AST_NAME);
3356   fail_unless( !strcmp(ASTNode_getName(c2), "x"));
3357   fail_unless( ASTNode_getNumChildren (c2) == 0);
3358 
3359   c2 = ASTNode_getChild(c, 1);
3360   fail_unless( ASTNode_getType        (c2) == AST_NAME);
3361   fail_unless( !strcmp(ASTNode_getName(c2), "y"));
3362   fail_unless( ASTNode_getNumChildren(c2) == 0 );
3363 
3364   c = ASTNode_getChild(r, 1);
3365   fail_unless( ASTNode_getType        (c) == AST_RELATIONAL_LEQ);
3366   fail_unless( ASTNode_getNumChildren (c) == 2   );
3367 
3368   c2 = ASTNode_getChild(c, 0);
3369   fail_unless( ASTNode_getType        (c2) == AST_NAME);
3370   fail_unless( !strcmp(ASTNode_getName(c2), "y"));
3371   fail_unless( ASTNode_getNumChildren (c2) == 0);
3372 
3373   c2 = ASTNode_getChild(c, 1);
3374   fail_unless( ASTNode_getType        (c2) == AST_NAME);
3375   fail_unless( !strcmp(ASTNode_getName(c2), "z"));
3376   fail_unless( ASTNode_getNumChildren(c2) == 0 );
3377 
3378   c = ASTNode_getChild(r, 2);
3379   fail_unless( ASTNode_getType        (c) == AST_RELATIONAL_EQ);
3380   fail_unless( ASTNode_getNumChildren (c) == 2   );
3381 
3382   c2 = ASTNode_getChild(c, 0);
3383   fail_unless( ASTNode_getType        (c2) == AST_NAME);
3384   fail_unless( !strcmp(ASTNode_getName(c2), "z"));
3385   fail_unless( ASTNode_getNumChildren (c2) == 0);
3386 
3387   c2 = ASTNode_getChild(c, 1);
3388   fail_unless( ASTNode_getType        (c2) == AST_NAME);
3389   fail_unless( !strcmp(ASTNode_getName(c2), "p"));
3390   fail_unless( ASTNode_getNumChildren(c2) == 0 );
3391 
3392   c = ASTNode_getChild(r, 3);
3393   fail_unless( ASTNode_getType        (c) == AST_RELATIONAL_GEQ);
3394   fail_unless( ASTNode_getNumChildren (c) == 2   );
3395 
3396   c2 = ASTNode_getChild(c, 0);
3397   fail_unless( ASTNode_getType        (c2) == AST_NAME);
3398   fail_unless( !strcmp(ASTNode_getName(c2), "p"));
3399   fail_unless( ASTNode_getNumChildren (c2) == 0);
3400 
3401   c2 = ASTNode_getChild(c, 1);
3402   fail_unless( ASTNode_getType        (c2) == AST_NAME);
3403   fail_unless( !strcmp(ASTNode_getName(c2), "q"));
3404   fail_unless( ASTNode_getNumChildren(c2) == 0 );
3405 
3406   c = ASTNode_getChild(r, 4);
3407   fail_unless( ASTNode_getType        (c) == AST_RELATIONAL_GT);
3408   fail_unless( ASTNode_getNumChildren (c) == 2   );
3409 
3410   c2 = ASTNode_getChild(c, 0);
3411   fail_unless( ASTNode_getType        (c2) == AST_NAME);
3412   fail_unless( !strcmp(ASTNode_getName(c2), "q"));
3413   fail_unless( ASTNode_getNumChildren (c2) == 0);
3414 
3415   c2 = ASTNode_getChild(c, 1);
3416   fail_unless( ASTNode_getType        (c2) == AST_NAME);
3417   fail_unless( !strcmp(ASTNode_getName(c2), "r"));
3418   fail_unless( ASTNode_getNumChildren(c2) == 0 );
3419 
3420   c = ASTNode_getChild(r, 5);
3421   fail_unless( ASTNode_getType        (c) == AST_RELATIONAL_NEQ);
3422   fail_unless( ASTNode_getNumChildren (c) == 2   );
3423 
3424   c2 = ASTNode_getChild(c, 0);
3425   fail_unless( ASTNode_getType        (c2) == AST_NAME);
3426   fail_unless( !strcmp(ASTNode_getName(c2), "r"));
3427   fail_unless( ASTNode_getNumChildren (c2) == 0);
3428 
3429   c2 = ASTNode_getChild(c, 1);
3430   fail_unless( ASTNode_getType        (c2) == AST_NAME);
3431   fail_unless( !strcmp(ASTNode_getName(c2), "s"));
3432   fail_unless( ASTNode_getNumChildren(c2) == 0 );
3433 
3434 
3435   ASTNode_free(r);
3436 }
3437 END_TEST
3438 
START_TEST(test_SBML_parseL3Formula_l3v2_functions)3439 START_TEST (test_SBML_parseL3Formula_l3v2_functions)
3440 {
3441   ASTNode_t *r = SBML_parseL3Formula("rateOf(x)");
3442   fail_unless( ASTNode_getType       (r) == AST_FUNCTION_RATE_OF, NULL );
3443   fail_unless( ASTNode_getNumChildren(r) == 1  , NULL );
3444   ASTNode_free(r);
3445 
3446   r = SBML_parseL3Formula("max(x,y,z)");
3447   fail_unless( ASTNode_getType       (r) == AST_FUNCTION_MAX, NULL );
3448   fail_unless( ASTNode_getNumChildren(r) == 3  , NULL );
3449   ASTNode_free(r);
3450 
3451   r = SBML_parseL3Formula("min(x)");
3452   fail_unless( ASTNode_getType       (r) == AST_FUNCTION_MIN, NULL );
3453   fail_unless( ASTNode_getNumChildren(r) == 1  , NULL );
3454   ASTNode_free(r);
3455 
3456   r = SBML_parseL3Formula("implies(x,y)");
3457   fail_unless( ASTNode_getType       (r) == AST_LOGICAL_IMPLIES, NULL );
3458   fail_unless( ASTNode_getNumChildren(r) == 2  , NULL );
3459   ASTNode_free(r);
3460 
3461   r = SBML_parseL3Formula("rem(a,b)");
3462   fail_unless( ASTNode_getType       (r) == AST_FUNCTION_REM, NULL );
3463   fail_unless( ASTNode_getNumChildren(r) == 2  , NULL );
3464   ASTNode_free(r);
3465 
3466   r = SBML_parseL3Formula("quotient(x,y)");
3467   fail_unless( ASTNode_getType       (r) == AST_FUNCTION_QUOTIENT, NULL );
3468   fail_unless( ASTNode_getNumChildren(r) == 2  , NULL );
3469   ASTNode_free(r);
3470 }
3471 END_TEST
3472 
3473 
START_TEST(test_SBML_parseL3Formula_l3v2_functions_generic)3474 START_TEST (test_SBML_parseL3Formula_l3v2_functions_generic)
3475 {
3476 	L3ParserSettings l3ps;
3477 	l3ps.setParseL3v2Functions(L3P_PARSE_L3V2_FUNCTIONS_AS_GENERIC);
3478 
3479 	ASTNode_t *r = SBML_parseL3FormulaWithSettings("rateOf(x)", &l3ps);
3480 	fail_unless( ASTNode_getType       (r) == AST_FUNCTION, NULL );
3481 	fail_unless( ASTNode_getNumChildren(r) == 1  , NULL );
3482 	ASTNode_free(r);
3483 
3484 	r = SBML_parseL3FormulaWithSettings("max(x,y,z)", &l3ps);
3485 	fail_unless( ASTNode_getType       (r) == AST_FUNCTION, NULL );
3486 	fail_unless( ASTNode_getNumChildren(r) == 3  , NULL );
3487 	ASTNode_free(r);
3488 
3489 	r = SBML_parseL3FormulaWithSettings("min(x)", &l3ps);
3490 	fail_unless( ASTNode_getType       (r) == AST_FUNCTION, NULL );
3491 	fail_unless( ASTNode_getNumChildren(r) == 1  , NULL );
3492 	ASTNode_free(r);
3493 
3494 	r = SBML_parseL3FormulaWithSettings("implies(x,y)", &l3ps);
3495 	fail_unless( ASTNode_getType       (r) == AST_FUNCTION, NULL );
3496 	fail_unless( ASTNode_getNumChildren(r) == 2  , NULL );
3497 	ASTNode_free(r);
3498 
3499 	r = SBML_parseL3FormulaWithSettings("rem(a,b)", &l3ps);
3500 	fail_unless( ASTNode_getType       (r) == AST_FUNCTION, NULL );
3501 	fail_unless( ASTNode_getNumChildren(r) == 2  , NULL );
3502 	ASTNode_free(r);
3503 
3504 	r = SBML_parseL3FormulaWithSettings("quotient(x,y)", &l3ps);
3505 	fail_unless( ASTNode_getType       (r) == AST_FUNCTION, NULL );
3506 	fail_unless( ASTNode_getNumChildren(r) == 2  , NULL );
3507 	ASTNode_free(r);
3508 }
3509 END_TEST
3510 
3511 
START_TEST(test_SBML_parseL3Formula_named_lambda_arguments1)3512 START_TEST(test_SBML_parseL3Formula_named_lambda_arguments1)
3513 {
3514   ASTNode_t *r = SBML_parseL3Formula("lambda(time, time+2)");
3515   fail_unless(ASTNode_getType(r) == AST_LAMBDA, NULL);
3516   fail_unless(ASTNode_getNumChildren(r) == 2, NULL);
3517   ASTNode_t *c = ASTNode_getChild(r, 0);
3518   fail_unless(ASTNode_getType(c) == AST_NAME);
3519   fail_unless(!strcmp(ASTNode_getName(c), "time"));
3520   fail_unless(c->getDefinitionURLString() == "");
3521 
3522   c = ASTNode_getChild(r, 1);
3523   fail_unless(ASTNode_getType(c) == AST_PLUS);
3524   ASTNode_t *c2 = ASTNode_getChild(c, 0);
3525   fail_unless(ASTNode_getType(c2) == AST_NAME);
3526   fail_unless(!strcmp(ASTNode_getName(c2), "time"));
3527   fail_unless(c2->getDefinitionURLString() == "");
3528   c2 = ASTNode_getChild(c, 1);
3529   fail_unless(ASTNode_getType(c2) == AST_INTEGER);
3530   fail_unless(ASTNode_getValue(c2) == 2);
3531 
3532   ASTNode_free(r);
3533 
3534 }
3535 END_TEST
3536 
3537 
START_TEST(test_SBML_parseL3Formula_named_lambda_arguments2)3538 START_TEST(test_SBML_parseL3Formula_named_lambda_arguments2)
3539 {
3540   ASTNode_t *r = SBML_parseL3Formula("lambda(time, avogadro, time+avogadro)");
3541   fail_unless(ASTNode_getType(r) == AST_LAMBDA, NULL);
3542   fail_unless(ASTNode_getNumChildren(r) == 3, NULL);
3543 
3544   ASTNode_t *c = ASTNode_getChild(r, 0);
3545   fail_unless(ASTNode_getType(c) == AST_NAME);
3546   fail_unless(!strcmp(ASTNode_getName(c), "time"));
3547   fail_unless(c->getDefinitionURLString() == "");
3548 
3549   c = ASTNode_getChild(r, 1);
3550   fail_unless(ASTNode_getType(c) == AST_NAME);
3551   fail_unless(!strcmp(ASTNode_getName(c), "avogadro"));
3552   fail_unless(c->getDefinitionURLString() == "");
3553 
3554   c = ASTNode_getChild(r, 2);
3555   fail_unless(ASTNode_getType(c) == AST_PLUS);
3556   ASTNode_t *c2 = ASTNode_getChild(c, 0);
3557   fail_unless(ASTNode_getType(c2) == AST_NAME);
3558   fail_unless(!strcmp(ASTNode_getName(c2), "time"));
3559   fail_unless(c2->getDefinitionURLString() == "");
3560   c2 = ASTNode_getChild(c, 1);
3561   fail_unless(ASTNode_getType(c2) == AST_NAME);
3562   fail_unless(!strcmp(ASTNode_getName(c2), "avogadro"));
3563   fail_unless(c2->getDefinitionURLString() == "");
3564 
3565   ASTNode_free(r);
3566 
3567 }
3568 END_TEST
3569 
3570 
START_TEST(test_SBML_parseL3Formula_named_lambda_arguments3)3571 START_TEST(test_SBML_parseL3Formula_named_lambda_arguments3)
3572 {
3573   ASTNode_t *r = SBML_parseL3Formula("lambda(true, false, true+false)");
3574   fail_unless(ASTNode_getType(r) == AST_LAMBDA, NULL);
3575   fail_unless(ASTNode_getNumChildren(r) == 3, NULL);
3576 
3577   ASTNode_t *c = ASTNode_getChild(r, 0);
3578   fail_unless(ASTNode_getType(c) == AST_NAME);
3579   fail_unless(!strcmp(ASTNode_getName(c), "true"));
3580   fail_unless(c->getDefinitionURLString() == "");
3581 
3582   c = ASTNode_getChild(r, 1);
3583   fail_unless(ASTNode_getType(c) == AST_NAME);
3584   fail_unless(!strcmp(ASTNode_getName(c), "false"));
3585   fail_unless(c->getDefinitionURLString() == "");
3586 
3587   c = ASTNode_getChild(r, 2);
3588   fail_unless(ASTNode_getType(c) == AST_PLUS);
3589   ASTNode_t *c2 = ASTNode_getChild(c, 0);
3590   fail_unless(ASTNode_getType(c2) == AST_NAME);
3591   fail_unless(!strcmp(ASTNode_getName(c2), "true"));
3592   fail_unless(c2->getDefinitionURLString() == "");
3593   c2 = ASTNode_getChild(c, 1);
3594   fail_unless(ASTNode_getType(c2) == AST_NAME);
3595   fail_unless(!strcmp(ASTNode_getName(c2), "false"));
3596   fail_unless(c2->getDefinitionURLString() == "");
3597 
3598   ASTNode_free(r);
3599 
3600 }
3601 END_TEST
3602 
3603 
START_TEST(test_SBML_parseL3Formula_named_lambda_arguments4)3604 START_TEST(test_SBML_parseL3Formula_named_lambda_arguments4)
3605 {
3606   ASTNode_t *r = SBML_parseL3Formula("lambda(pi, exponentiale, pi+exponentiale)");
3607   fail_unless(ASTNode_getType(r) == AST_LAMBDA, NULL);
3608   fail_unless(ASTNode_getNumChildren(r) == 3, NULL);
3609 
3610   ASTNode_t *c = ASTNode_getChild(r, 0);
3611   fail_unless(ASTNode_getType(c) == AST_NAME);
3612   fail_unless(!strcmp(ASTNode_getName(c), "pi"));
3613   fail_unless(c->getDefinitionURLString() == "");
3614 
3615   c = ASTNode_getChild(r, 1);
3616   fail_unless(ASTNode_getType(c) == AST_NAME);
3617   fail_unless(!strcmp(ASTNode_getName(c), "exponentiale"));
3618   fail_unless(c->getDefinitionURLString() == "");
3619 
3620   c = ASTNode_getChild(r, 2);
3621   fail_unless(ASTNode_getType(c) == AST_PLUS);
3622   ASTNode_t *c2 = ASTNode_getChild(c, 0);
3623   fail_unless(ASTNode_getType(c2) == AST_NAME);
3624   fail_unless(!strcmp(ASTNode_getName(c2), "pi"));
3625   fail_unless(c2->getDefinitionURLString() == "");
3626   c2 = ASTNode_getChild(c, 1);
3627   fail_unless(ASTNode_getType(c2) == AST_NAME);
3628   fail_unless(!strcmp(ASTNode_getName(c2), "exponentiale"));
3629   fail_unless(c2->getDefinitionURLString() == "");
3630 
3631   ASTNode_free(r);
3632 
3633 }
3634 END_TEST
3635 
3636 
START_TEST(test_SBML_parseL3Formula_named_lambda_arguments5)3637 START_TEST(test_SBML_parseL3Formula_named_lambda_arguments5)
3638 {
3639   ASTNode_t *r = SBML_parseL3Formula("lambda(time, avogadro, true, false, pi, exponentiale, time+avogadro+true+false+pi+exponentiale)");
3640   fail_unless(ASTNode_getType(r) == AST_LAMBDA, NULL);
3641   fail_unless(ASTNode_getNumChildren(r) == 7, NULL);
3642 
3643   ASTNode_t *c = ASTNode_getChild(r, 0);
3644   fail_unless(ASTNode_getType(c) == AST_NAME);
3645   fail_unless(!strcmp(ASTNode_getName(c), "time"));
3646   fail_unless(c->getDefinitionURLString() == "");
3647 
3648   c = ASTNode_getChild(r, 1);
3649   fail_unless(ASTNode_getType(c) == AST_NAME);
3650   fail_unless(!strcmp(ASTNode_getName(c), "avogadro"));
3651   fail_unless(c->getDefinitionURLString() == "");
3652 
3653   c = ASTNode_getChild(r, 2);
3654   fail_unless(ASTNode_getType(c) == AST_NAME);
3655   fail_unless(!strcmp(ASTNode_getName(c), "true"));
3656   fail_unless(c->getDefinitionURLString() == "");
3657 
3658   c = ASTNode_getChild(r, 3);
3659   fail_unless(ASTNode_getType(c) == AST_NAME);
3660   fail_unless(!strcmp(ASTNode_getName(c), "false"));
3661   fail_unless(c->getDefinitionURLString() == "");
3662 
3663   c = ASTNode_getChild(r, 4);
3664   fail_unless(ASTNode_getType(c) == AST_NAME);
3665   fail_unless(!strcmp(ASTNode_getName(c), "pi"));
3666   fail_unless(c->getDefinitionURLString() == "");
3667 
3668   c = ASTNode_getChild(r, 5);
3669   fail_unless(ASTNode_getType(c) == AST_NAME);
3670   fail_unless(!strcmp(ASTNode_getName(c), "exponentiale"));
3671   fail_unless(c->getDefinitionURLString() == "");
3672 
3673   c = ASTNode_getChild(r, 6);
3674   fail_unless(ASTNode_getType(c) == AST_PLUS);
3675   fail_unless(ASTNode_getNumChildren(c) == 6, NULL);
3676   ASTNode_t *c2 = ASTNode_getChild(c, 0);
3677   fail_unless(ASTNode_getType(c2) == AST_NAME);
3678   fail_unless(!strcmp(ASTNode_getName(c2), "time"));
3679   fail_unless(c2->getDefinitionURLString() == "");
3680   c2 = ASTNode_getChild(c, 1);
3681   fail_unless(ASTNode_getType(c2) == AST_NAME);
3682   fail_unless(!strcmp(ASTNode_getName(c2), "avogadro"));
3683   fail_unless(c2->getDefinitionURLString() == "");
3684   c2 = ASTNode_getChild(c, 2);
3685   fail_unless(ASTNode_getType(c2) == AST_NAME);
3686   fail_unless(!strcmp(ASTNode_getName(c2), "true"));
3687   fail_unless(c2->getDefinitionURLString() == "");
3688   c2 = ASTNode_getChild(c, 3);
3689   fail_unless(ASTNode_getType(c2) == AST_NAME);
3690   fail_unless(!strcmp(ASTNode_getName(c2), "false"));
3691   fail_unless(c2->getDefinitionURLString() == "");
3692   c2 = ASTNode_getChild(c, 4);
3693   fail_unless(ASTNode_getType(c2) == AST_NAME);
3694   fail_unless(!strcmp(ASTNode_getName(c2), "pi"));
3695   fail_unless(c2->getDefinitionURLString() == "");
3696   c2 = ASTNode_getChild(c, 5);
3697   fail_unless(ASTNode_getType(c2) == AST_NAME);
3698   fail_unless(!strcmp(ASTNode_getName(c2), "exponentiale"));
3699   fail_unless(c2->getDefinitionURLString() == "");
3700 
3701   ASTNode_free(r);
3702 
3703 }
3704 END_TEST
3705 
3706 
START_TEST(test_SBML_parseL3Formula_named_lambda_arguments6)3707 START_TEST(test_SBML_parseL3Formula_named_lambda_arguments6)
3708 {
3709   ASTNode_t *r = SBML_parseL3Formula("lambda(time, time+pi)");
3710   fail_unless(ASTNode_getType(r) == AST_LAMBDA, NULL);
3711   fail_unless(ASTNode_getNumChildren(r) == 2, NULL);
3712 
3713   ASTNode_t *c = ASTNode_getChild(r, 0);
3714   fail_unless(ASTNode_getType(c) == AST_NAME);
3715   fail_unless(!strcmp(ASTNode_getName(c), "time"));
3716   fail_unless(c->getDefinitionURLString() == "");
3717 
3718   c = ASTNode_getChild(r, 1);
3719   fail_unless(ASTNode_getType(c) == AST_PLUS);
3720   ASTNode_t *c2 = ASTNode_getChild(c, 0);
3721   fail_unless(ASTNode_getType(c2) == AST_NAME);
3722   fail_unless(!strcmp(ASTNode_getName(c2), "time"));
3723   fail_unless(c2->getDefinitionURLString() == "");
3724   c2 = ASTNode_getChild(c, 1);
3725   fail_unless(ASTNode_getType(c2) == AST_CONSTANT_PI);
3726 
3727   ASTNode_free(r);
3728 
3729 }
3730 END_TEST
3731 
3732 
START_TEST(test_SBML_parseL3Formula_named_lambda_arguments7)3733 START_TEST(test_SBML_parseL3Formula_named_lambda_arguments7)
3734 {
3735   ASTNode_t *r = SBML_parseL3Formula("lambda(time+avogadro+true+false+pi+exponentiale)");
3736   fail_unless(ASTNode_getType(r) == AST_LAMBDA, NULL);
3737   fail_unless(ASTNode_getNumChildren(r) == 1, NULL);
3738 
3739   ASTNode_t *c = ASTNode_getChild(r, 0);
3740   fail_unless(ASTNode_getType(c) == AST_PLUS);
3741   fail_unless(ASTNode_getNumChildren(c) == 6, NULL);
3742   ASTNode_t *c2 = ASTNode_getChild(c, 0);
3743   fail_unless(ASTNode_getType(c2) == AST_NAME_TIME);
3744   c2 = ASTNode_getChild(c, 1);
3745   fail_unless(ASTNode_getType(c2) == AST_NAME_AVOGADRO);
3746   c2 = ASTNode_getChild(c, 2);
3747   fail_unless(ASTNode_getType(c2) == AST_CONSTANT_TRUE);
3748   c2 = ASTNode_getChild(c, 3);
3749   fail_unless(ASTNode_getType(c2) == AST_CONSTANT_FALSE);
3750   c2 = ASTNode_getChild(c, 4);
3751   fail_unless(ASTNode_getType(c2) == AST_CONSTANT_PI);
3752   c2 = ASTNode_getChild(c, 5);
3753   fail_unless(ASTNode_getType(c2) == AST_CONSTANT_E);
3754 
3755   ASTNode_free(r);
3756 
3757 }
3758 END_TEST
3759 
3760 
3761 Suite *
create_suite_L3FormulaParser(void)3762 create_suite_L3FormulaParser (void)
3763 {
3764   Suite *suite = suite_create("L3FormulaParser");
3765   TCase *tcase = tcase_create("L3FormulaParser");
3766 
3767   tcase_add_test( tcase, test_SBML_parseL3Formula_1       );
3768   tcase_add_test( tcase, test_SBML_parseL3Formula_2       );
3769   tcase_add_test( tcase, test_SBML_parseL3Formula_3       );
3770   tcase_add_test( tcase, test_SBML_parseL3Formula_4       );
3771   tcase_add_test( tcase, test_SBML_parseL3Formula_5       );
3772   tcase_add_test( tcase, test_SBML_parseL3Formula_6       );
3773   tcase_add_test( tcase, test_SBML_parseL3Formula_7       );
3774   tcase_add_test( tcase, test_SBML_parseL3Formula_8       );
3775   tcase_add_test( tcase, test_SBML_parseL3Formula_9       );
3776   tcase_add_test( tcase, test_SBML_parseL3Formula_10      );
3777   tcase_add_test( tcase, test_SBML_parseL3Formula_11      );
3778   tcase_add_test( tcase, test_SBML_parseL3Formula_12      );
3779   tcase_add_test( tcase, test_SBML_parseL3Formula_13      );
3780   tcase_add_test( tcase, test_SBML_parseL3Formula_14      );
3781   tcase_add_test( tcase, test_SBML_parseL3Formula_15      );
3782   tcase_add_test( tcase, test_SBML_parseL3Formula_16      );
3783   tcase_add_test( tcase, test_SBML_parseL3Formula_17      );
3784   tcase_add_test( tcase, test_SBML_parseL3Formula_18      );
3785   tcase_add_test( tcase, test_SBML_parseL3Formula_negInf  );
3786   tcase_add_test( tcase, test_SBML_parseL3Formula_negZero );
3787   tcase_add_test( tcase, test_SBML_parseL3Formula_e1      );
3788   tcase_add_test( tcase, test_SBML_parseL3Formula_e2      );
3789   tcase_add_test( tcase, test_SBML_parseL3Formula_e3      );
3790   tcase_add_test( tcase, test_SBML_parseL3Formula_e4      );
3791   tcase_add_test( tcase, test_SBML_parseL3Formula_e5      );
3792   tcase_add_test( tcase, test_SBML_parseL3Formula_rational1);
3793   tcase_add_test( tcase, test_SBML_parseL3Formula_rational2);
3794   tcase_add_test( tcase, test_SBML_parseL3Formula_rational3);
3795   tcase_add_test( tcase, test_SBML_parseL3Formula_rational4);
3796   tcase_add_test( tcase, test_SBML_parseL3Formula_rational5);
3797   tcase_add_test( tcase, test_SBML_parseL3Formula_rational6);
3798   tcase_add_test( tcase, test_SBML_parseL3Formula_rational7);
3799   tcase_add_test( tcase, test_SBML_parseL3Formula_constants1);
3800   tcase_add_test( tcase, test_SBML_parseL3Formula_constants2);
3801   tcase_add_test( tcase, test_SBML_parseL3Formula_constants3);
3802   tcase_add_test( tcase, test_SBML_parseL3Formula_constants4);
3803   tcase_add_test( tcase, test_SBML_parseL3Formula_constants5);
3804   tcase_add_test( tcase, test_SBML_parseL3Formula_constants6);
3805   tcase_add_test( tcase, test_SBML_parseL3Formula_constants7);
3806   tcase_add_test( tcase, test_SBML_parseL3Formula_constants8);
3807   tcase_add_test( tcase, test_SBML_parseL3Formula_constants9);
3808   tcase_add_test( tcase, test_SBML_parseL3Formula_constants10);
3809   tcase_add_test( tcase, test_SBML_parseL3Formula_constants11);
3810   tcase_add_test( tcase, test_SBML_parseL3Formula_constants12);
3811   tcase_add_test(tcase, test_SBML_parseL3Formula_modulo);
3812   tcase_add_test(tcase, test_SBML_parseL3Formula_modulo2);
3813   tcase_add_test(tcase, test_SBML_parseL3Formula_modulo3);
3814   tcase_add_test(tcase, test_SBML_parseL3Formula_l3v2functions);
3815   tcase_add_test(tcase, test_SBML_parseL3Formula_l3v2functions2);
3816   tcase_add_test(tcase, test_SBML_parseL3Formula_l3v2functions3);
3817   tcase_add_test(tcase, test_SBML_parseL3Formula_oddMathML1);
3818   tcase_add_test( tcase, test_SBML_parseL3Formula_oddMathML2);
3819   tcase_add_test( tcase, test_SBML_parseL3Formula_oddMathML3);
3820   tcase_add_test( tcase, test_SBML_parseL3Formula_oddMathML4);
3821   tcase_add_test( tcase, test_SBML_parseL3Formula_oddMathML5);
3822   tcase_add_test( tcase, test_SBML_parseL3Formula_modelPresent1);
3823   tcase_add_test( tcase, test_SBML_parseL3Formula_modelPresent2);
3824   tcase_add_test( tcase, test_SBML_parseL3Formula_modelPresent3);
3825   tcase_add_test( tcase, test_SBML_parseL3Formula_modelPresent4);
3826   tcase_add_test( tcase, test_SBML_parseL3Formula_modelPresent5);
3827   tcase_add_test( tcase, test_SBML_parseL3Formula_modelPresent6);
3828   tcase_add_test( tcase, test_SBML_parseL3Formula_modelPresent7);
3829   tcase_add_test( tcase, test_SBML_parseL3Formula_arguments);
3830   tcase_add_test( tcase, test_SBML_parseL3Formula_logic1);
3831   tcase_add_test( tcase, test_SBML_parseL3Formula_logic2);
3832   tcase_add_test( tcase, test_SBML_parseL3Formula_precedence);
3833   tcase_add_test( tcase, test_SBML_parseL3Formula_parselogsettings);
3834   tcase_add_test( tcase, test_SBML_parseL3Formula_collapseminussettings1);
3835   tcase_add_test( tcase, test_SBML_parseL3Formula_collapseminussettings2);
3836   tcase_add_test( tcase, test_SBML_parseL3Formula_collapseminussettings3);
3837   tcase_add_test( tcase, test_SBML_parseL3Formula_collapseminussettings4);
3838   tcase_add_test( tcase, test_SBML_parseL3Formula_collapseminussettings5);
3839   tcase_add_test( tcase, test_SBML_parseL3Formula_unaryPlus);
3840   tcase_add_test( tcase, test_SBML_parseL3Formula_avogadrosettings);
3841   tcase_add_test( tcase, test_SBML_parseL3Formula_unitssettings);
3842   tcase_add_test( tcase, test_SBML_parseL3Formula_capssettings1);
3843   tcase_add_test( tcase, test_SBML_parseL3Formula_capssettings2);
3844   tcase_add_test( tcase, test_SBML_parseL3Formula_capssettings3);
3845   tcase_add_test( tcase, test_SBML_parseL3Formula_power);
3846   tcase_add_test( tcase, test_SBML_parseL3Formula_longint);
3847   tcase_add_test( tcase, test_SBML_parseL3Formula_longdecimal);
3848   tcase_add_test( tcase, test_SBML_parseL3Formula_longnumberparen);
3849   tcase_add_test( tcase, test_SBML_parseL3Formula_crazylong);
3850   tcase_add_test( tcase, test_SBML_parseL3Formula_easunit);
3851   tcase_add_test( tcase, test_SBML_parseL3Formula_easunitparen);
3852   tcase_add_test( tcase, test_SBML_parseL3Formula_easunitint);
3853   tcase_add_test( tcase, test_SBML_parseL3Formula_ergunit);
3854   tcase_add_test( tcase, test_SBML_parseL3Formula_longinterg);
3855   tcase_add_test( tcase, test_SBML_parseL3Formula_longdecimalerg);
3856   tcase_add_test( tcase, test_SBML_parseL3Formula_longnumberparenerg);
3857   tcase_add_test( tcase, test_SBML_parseL3Formula_crazylongerg);
3858   tcase_add_test( tcase, test_SBML_parseL3Formula_wrongnum);
3859   tcase_add_test( tcase, test_SBML_parseL3Formula_wrongnum2);
3860   tcase_add_test( tcase, test_SBML_parseL3Formula_lambda1);
3861   tcase_add_test( tcase, test_SBML_parseL3Formula_lambda2);
3862   tcase_add_test( tcase, test_SBML_parseL3Formula_lambda3);
3863   tcase_add_test( tcase, test_SBML_parseL3Formula_lambda4);
3864   tcase_add_test( tcase, test_SBML_parseL3Formula_lambdaerr);
3865   tcase_add_test( tcase, test_SBML_parseL3Formula_sqrterr);
3866   tcase_add_test( tcase, test_SBML_parseL3Formula_precedence1);
3867   tcase_add_test( tcase, test_SBML_parseL3Formula_precedence2);
3868   tcase_add_test( tcase, test_SBML_parseL3Formula_combinedRelational_allLT);
3869   tcase_add_test( tcase, test_SBML_parseL3Formula_combinedRelational_allGT);
3870   tcase_add_test( tcase, test_SBML_parseL3Formula_combinedRelational_allLEQ);
3871   tcase_add_test( tcase, test_SBML_parseL3Formula_combinedRelational_allGEQ);
3872   tcase_add_test( tcase, test_SBML_parseL3Formula_combinedRelational_allEQ);
3873   tcase_add_test( tcase, test_SBML_parseL3Formula_combinedRelational_allNEQ);
3874   tcase_add_test( tcase, test_SBML_parseL3Formula_combinedRelational_mixed1);
3875   tcase_add_test( tcase, test_SBML_parseL3Formula_combinedRelational_mixed2);
3876   tcase_add_test( tcase, test_SBML_parseL3Formula_combinedRelational_allLT_many);
3877   tcase_add_test( tcase, test_SBML_parseL3Formula_combinedRelational_mixed_many1);
3878   tcase_add_test( tcase, test_SBML_parseL3Formula_combinedRelational_mixed_many2);
3879   tcase_add_test( tcase, test_SBML_parseL3Formula_combinedRelational_mixed_many3);
3880   tcase_add_test( tcase, test_SBML_parseL3Formula_combinedRelational_mixed_many4);
3881   tcase_add_test( tcase, test_SBML_parseL3Formula_combinedRelational_mixed_many5);
3882   tcase_add_test( tcase, test_SBML_parseL3Formula_l3v2_functions);
3883   tcase_add_test( tcase, test_SBML_parseL3Formula_l3v2_functions_generic);
3884   tcase_add_test(tcase, test_SBML_parseL3Formula_named_lambda_arguments1);
3885   tcase_add_test(tcase, test_SBML_parseL3Formula_named_lambda_arguments2);
3886   tcase_add_test(tcase, test_SBML_parseL3Formula_named_lambda_arguments3);
3887   tcase_add_test(tcase, test_SBML_parseL3Formula_named_lambda_arguments4);
3888   tcase_add_test(tcase, test_SBML_parseL3Formula_named_lambda_arguments5);
3889   tcase_add_test(tcase, test_SBML_parseL3Formula_named_lambda_arguments6);
3890   tcase_add_test(tcase, test_SBML_parseL3Formula_named_lambda_arguments7);
3891 
3892 
3893   suite_add_tcase(suite, tcase);
3894 
3895   return suite;
3896 }
3897 
3898 #if __cplusplus
3899 CK_CPPEND
3900 #endif
3901