1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
2  * Copyright by The HDF Group.                                               *
3  * All rights reserved.                                                      *
4  *                                                                           *
5  * This file is part of HDF Products. The full HDF copyright                 *
6  * notice, including terms governing use, modification, and redistribution,  *
7  * is contained in the file, COPYING.  COPYING can be found at the root of   *
8  * the source code distribution tree. You can also access it online  at      *
9  * http://www.hdfgroup.org/products/licenses.html.  If you do not have       *
10  * access to the file, you may request a copy from help@hdfgroup.org.        *
11  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
12 
13 package test;
14 
15 import static org.junit.Assert.assertEquals;
16 import static org.junit.Assert.assertFalse;
17 import static org.junit.Assert.assertTrue;
18 import static org.junit.Assert.fail;
19 
20 import java.io.File;
21 
22 import hdf.hdflib.HDFLibrary;
23 import hdf.hdflib.HDFException;
24 import hdf.hdflib.HDFConstants;
25 
26 import org.junit.After;
27 import org.junit.Before;
28 import org.junit.Ignore;
29 import org.junit.Rule;
30 import org.junit.Test;
31 import org.junit.rules.TestName;
32 
33 /**
34  *
35  */
36 public class TestH4ANparams {
37     @Rule public TestName testname = new TestName();
38 
39     @Before
showTestName()40     public void showTestName() {
41         System.out.print(testname.getMethodName());
42     }
43 
44     @After
nextTestName()45     public void nextTestName() {
46         System.out.println();
47     }
48 
49     @Test(expected = HDFException.class)
testANstartIllegalId()50     public void testANstartIllegalId() throws Throwable {
51         HDFLibrary.ANstart(-1);
52     }
53 
54     @Test(expected = HDFException.class)
testANendIllegalId()55     public void testANendIllegalId() throws Throwable {
56         HDFLibrary.ANend(-1);
57     }
58 
59     @Test
testANendaccessIllegalId()60     public void testANendaccessIllegalId() throws Throwable {
61         //function does nothing
62         assertTrue(HDFLibrary.ANendaccess(-1));
63     }
64 
65     @Test(expected = HDFException.class)
testANfileinfoIllegalId()66     public void testANfileinfoIllegalId() throws Throwable {
67         int[] ids = {0, 0, 0, 0};
68         HDFLibrary.ANfileinfo(-1, ids);
69     }
70 
71     @Test(expected = NullPointerException.class)
testANfileinfoNull()72     public void testANfileinfoNull() throws Throwable {
73         HDFLibrary.ANfileinfo(0, null);
74     }
75 
76     @Test(expected = IllegalArgumentException.class)
testANfileinfoArgument()77     public void testANfileinfoArgument() throws Throwable {
78         int[] ids = {0, 0};
79         HDFLibrary.ANfileinfo(0, ids);
80     }
81 
82     @Test(expected = HDFException.class)
testANselectIllegalId()83     public void testANselectIllegalId() throws Throwable {
84         HDFLibrary.ANselect(-1, 0, 0);
85     }
86 
87     @Test(expected = HDFException.class)
testANnumannIllegalId()88     public void testANnumannIllegalId() throws Throwable {
89         short tag = 0;
90         short ref = 0;
91         HDFLibrary.ANnumann(-1, 0, tag, ref);
92     }
93 
94     @Test
testANatype2tagIllegalId()95     public void testANatype2tagIllegalId() throws Throwable {
96         assertEquals(HDFLibrary.ANatype2tag(-1), HDFConstants.DFTAG_NULL);
97     }
98 
99     @Test(expected = HDFException.class)
testANtag2atypeIllegalId()100     public void testANtag2atypeIllegalId() throws Throwable {
101         short anttype = -1;
102         HDFLibrary.ANtag2atype(anttype);
103     }
104 
105     @Test(expected = HDFException.class)
testANannlistIllegalId()106     public void testANannlistIllegalId() throws Throwable {
107         short tag = 0;
108         short ref = 0;
109         int[] ids = {0, 0, 0, 0};
110         HDFLibrary.ANannlist(-1, 0, tag, ref, ids);
111     }
112 
113     @Test(expected = NullPointerException.class)
testANannlistNull()114     public void testANannlistNull() throws Throwable {
115         short tag = 0;
116         short ref = 0;
117 
118         HDFLibrary.ANannlist(0, 0, tag, ref, null);
119     }
120 
121     @Test(expected = HDFException.class)
testANannlenIllegalId()122     public void testANannlenIllegalId() throws Throwable {
123         HDFLibrary.ANannlen(-1);
124     }
125 
126     @Test(expected = HDFException.class)
testANreadannIllegalId()127     public void testANreadannIllegalId() throws Throwable {
128         String[] str = {""};
129         HDFLibrary.ANreadann(-1, str, 0);
130     }
131 
132     @Test(expected = HDFException.class)
testANcreateIllegalId()133     public void testANcreateIllegalId() throws Throwable {
134         short tag = 0;
135         short ref = 0;
136         HDFLibrary.ANcreate(-1, tag, ref, 0);
137     }
138 
139     @Test(expected = HDFException.class)
testANcreatefIllegalId()140     public void testANcreatefIllegalId() throws Throwable {
141         HDFLibrary.ANcreatef(-1, 0);
142     }
143 
144     @Test(expected = HDFException.class)
testANget_tagrefIllegalId()145     public void testANget_tagrefIllegalId() throws Throwable {
146         short[] ref = {0, 0};
147         HDFLibrary.ANget_tagref(-1, 0, 0, ref);
148     }
149 
150     @Test(expected = NullPointerException.class)
testANget_tagrefNull()151     public void testANget_tagrefNull() throws Throwable {
152         HDFLibrary.ANget_tagref(0, 0, 0, null);
153     }
154 
155     @Test(expected = IllegalArgumentException.class)
testANget_tagrefArgument()156     public void testANget_tagrefArgument() throws Throwable {
157         short[] ref = {0};
158         HDFLibrary.ANget_tagref(0, 0, 0, ref);
159     }
160 
161     @Test(expected = HDFException.class)
testANid2tagrefIllegalId()162     public void testANid2tagrefIllegalId() throws Throwable {
163         short[] tag = {0, 0};
164         HDFLibrary.ANid2tagref(-1, tag);
165     }
166 
167     @Test(expected = NullPointerException.class)
testANid2tagrefNull()168     public void testANid2tagrefNull() throws Throwable {
169         HDFLibrary.ANid2tagref(0, null);
170     }
171 
172     @Test(expected = IllegalArgumentException.class)
testANid2tagrefArgument()173     public void testANid2tagrefArgument() throws Throwable {
174         short[] tag = {0};
175         HDFLibrary.ANid2tagref(0, tag);
176     }
177 
178     @Test(expected = HDFException.class)
testANtagref2idIllegalId()179     public void testANtagref2idIllegalId() throws Throwable {
180         short tag = 0;
181         short ref = 0;
182         HDFLibrary.ANtagref2id(-1, tag, ref);
183     }
184 
185     @Test(expected = HDFException.class)
testANwriteannIllegalId()186     public void testANwriteannIllegalId() throws Throwable {
187         String str = "";
188         HDFLibrary.ANwriteann(-1, str, 0);
189     }
190 
191     @Test(expected = NullPointerException.class)
testANwriteannNull()192     public void testANwriteannNull() throws Throwable {
193         HDFLibrary.ANwriteann(0, null, 0);
194     }
195 }
196