Ticket #3074: TestAssert.mo

File TestAssert.mo, 915 bytes (added by Francesco Casella, 10 years ago)

Library with test cases

Line 
1package TestAssert
2 model M
3 Real x = 0;
4 equation
5 assert(x < 10, "Variable x is too big");
6 assert(x < 5, "Variable x is probably too big", AssertionLevel.warning);
7 end M;
8
9 model TestWarningConstant
10 M m1(x = 3);
11 M m2(x = 4);
12 M m3(x = 6);
13 equation
14
15 end TestWarningConstant;
16
17 model TestWarningVariable
18 M m1(x = 3 * time);
19 M m2(x = 4 * time);
20 M m3(x = 6 * time);
21 equation
22
23 end TestWarningVariable;
24
25 model TestWarningRecurring
26 M m1(x = 3 * time);
27 M m2(x = 4 * time);
28 M m3(x = 6 * sin(6.28 * time));
29 equation
30
31 end TestWarningRecurring;
32
33 model TestErrorConstant
34 M m1(x = 4);
35 M m2(x = 20);
36 M m3(x = 2);
37 equation
38
39 end TestErrorConstant;
40
41 model TestErrorVariable
42 M m1(x = 4 * time);
43 M m2(x = 20 * time);
44 M m3(x = 2 * time);
45 equation
46
47 end TestErrorVariable;
48end TestAssert;