1 package org.djunits.unit;
2
3 import static org.junit.Assert.assertTrue;
4
5 import java.lang.reflect.Field;
6
7 import org.junit.Assert;
8 import org.junit.Test;
9
10
11
12
13
14
15
16
17
18
19
20
21 public class DefinesSITest
22 {
23
24
25
26 @SuppressWarnings("rawtypes")
27 @Test
28 public final void definesSI()
29 {
30 for (String className : Unit.STANDARD_UNITS)
31 {
32 if (className.endsWith("SIUnit") || className.endsWith("LinearUnit") || className.contains("Money"))
33 {
34 continue;
35 }
36
37 Class c;
38 try
39 {
40 c = Class.forName("org.djunits.unit." + className);
41 }
42 catch (Exception exception)
43 {
44 Assert.fail("Class org.djunits.unit." + className + " could not be loaded");
45 return;
46 }
47
48 Field[] fields = c.getDeclaredFields();
49 boolean foundSI = false;
50 for (Field f : fields)
51 {
52
53 if (f.getName().equals("SI") || f.getName().equals("BASE"))
54 {
55 foundSI = true;
56 }
57 }
58 assertTrue("Class " + className + " does not declare field SI or BASE", foundSI);
59 }
60 }
61 }