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.HDFChunkInfo; 25 import hdf.hdflib.HDFConstants; 26 27 import org.junit.After; 28 import org.junit.Before; 29 import org.junit.Ignore; 30 import org.junit.Rule; 31 import org.junit.Test; 32 import org.junit.rules.TestName; 33 34 public class TestH4VSparams { 35 @Rule public TestName testname = new TestName(); 36 37 @Before showTestName()38 public void showTestName() { 39 System.out.print(testname.getMethodName()); 40 } 41 42 @After nextTestName()43 public void nextTestName() { 44 System.out.println(); 45 } 46 47 @Test(expected = NullPointerException.class) testVSQuerycountNullNRecords()48 public void testVSQuerycountNullNRecords() throws Throwable { 49 HDFLibrary.VSQuerycount(0, null); 50 } 51 52 @Test(expected = HDFException.class) testVSQuerycountIllegalId()53 public void testVSQuerycountIllegalId() throws Throwable { 54 HDFLibrary.VSQuerycount(-1, new int[] { 0 }); 55 } 56 57 @Test(expected = IllegalArgumentException.class) testVSQuerycountIllegalArgument()58 public void testVSQuerycountIllegalArgument() throws Throwable { 59 HDFLibrary.VSQuerycount(0, new int[] { }); 60 } 61 62 @Test(expected = NullPointerException.class) testVSQueryfieldsNullFields()63 public void testVSQueryfieldsNullFields() throws Throwable { 64 HDFLibrary.VSQueryfields(0, null); 65 } 66 67 @Test(expected = HDFException.class) testVSQueryfieldsIllegalId()68 public void testVSQueryfieldsIllegalId() throws Throwable { 69 HDFLibrary.VSQueryfields(-1, new String[1]); 70 } 71 72 @Test(expected = IllegalArgumentException.class) testVSQueryfieldsIllegalArgument()73 public void testVSQueryfieldsIllegalArgument() throws Throwable { 74 HDFLibrary.VSQueryfields(0, new String[0]); 75 } 76 77 @Test(expected = NullPointerException.class) testVSQueryinterlaceNullInterlace()78 public void testVSQueryinterlaceNullInterlace() throws Throwable { 79 HDFLibrary.VSQueryinterlace(0, null); 80 } 81 82 @Test(expected = HDFException.class) testVSQueryinterlaceIllegalId()83 public void testVSQueryinterlaceIllegalId() throws Throwable { 84 HDFLibrary.VSQueryinterlace(-1, new int[1]); 85 } 86 87 @Test(expected = IllegalArgumentException.class) testVSQueryinterlaceIllegalArgument()88 public void testVSQueryinterlaceIllegalArgument() throws Throwable { 89 HDFLibrary.VSQueryinterlace(0, new int[0]); 90 } 91 92 @Test(expected = NullPointerException.class) testVSQuerynameNullVDataName()93 public void testVSQuerynameNullVDataName() throws Throwable { 94 HDFLibrary.VSQueryname(0, null); 95 } 96 97 @Test(expected = HDFException.class) testVSQuerynameIllegalId()98 public void testVSQuerynameIllegalId() throws Throwable { 99 HDFLibrary.VSQueryname(-1, new String[1]); 100 } 101 102 @Test(expected = IllegalArgumentException.class) testVSQuerynameIllegalArgument()103 public void testVSQuerynameIllegalArgument() throws Throwable { 104 HDFLibrary.VSQueryname(0, new String[0]); 105 } 106 107 // @Test(expected = HDFException.class) 108 // public void testVSQueryrefIllegalId() throws Throwable { 109 // HDFLibrary.VSQueryref(-1); 110 // } 111 112 // @Test(expected = HDFException.class) 113 // public void testVSQuerytagIllegalId() throws Throwable { 114 // HDFLibrary.VSQuerytag(-1); 115 // } 116 117 @Test(expected = NullPointerException.class) testVSQueryvsizeNullVDataSize()118 public void testVSQueryvsizeNullVDataSize() throws Throwable { 119 HDFLibrary.VSQueryvsize(0, null); 120 } 121 122 @Test(expected = HDFException.class) testVSQueryvsizeIllegalId()123 public void testVSQueryvsizeIllegalId() throws Throwable { 124 HDFLibrary.VSQueryvsize(-1, new int[1]); 125 } 126 127 @Test(expected = IllegalArgumentException.class) testVSQueryvsizeIllegalArgument()128 public void testVSQueryvsizeIllegalArgument() throws Throwable { 129 HDFLibrary.VSQueryvsize(0, new int[0]); 130 } 131 132 @Test(expected = NullPointerException.class) testVSattachNullAccess()133 public void testVSattachNullAccess() throws Throwable { 134 HDFLibrary.VSattach(0, 0, null); 135 } 136 137 @Test(expected = HDFException.class) testVSattachIllegalId()138 public void testVSattachIllegalId() throws Throwable { 139 HDFLibrary.VSattach(-1, 0, "w"); 140 } 141 142 @Test(expected = HDFException.class) testVSattachIllegalReg()143 public void testVSattachIllegalReg() throws Throwable { 144 HDFLibrary.VSattach(0, -1, "w"); 145 } 146 147 // @Test(expected = HDFException.class) 148 // public void testVSdetachIllegalId() throws Throwable { 149 // HDFLibrary.VSdetach(-1); 150 // } 151 152 // @Test(expected = HDFException.class) 153 // public void testVSgetidIllegalId() throws Throwable { 154 // HDFLibrary.VSgetid(-1, 0); 155 // } 156 157 // @Test(expected = HDFException.class) 158 // public void testVSgetidIllegalRef() throws Throwable { 159 // HDFLibrary.VSgetid(0, -1); 160 // } 161 162 @Test(expected = NullPointerException.class) testVSgetclassNullClassName()163 public void testVSgetclassNullClassName() throws Throwable { 164 HDFLibrary.VSgetclass(0, null); 165 } 166 167 @Test(expected = HDFException.class) testVSgetclassIllegalId()168 public void testVSgetclassIllegalId() throws Throwable { 169 HDFLibrary.VSgetclass(-1, new String[1]); 170 } 171 172 @Test(expected = NullPointerException.class) testVSgetnameNullName()173 public void testVSgetnameNullName() throws Throwable { 174 HDFLibrary.VSgetname(0, null); 175 } 176 177 @Test(expected = HDFException.class) testVSgetnameIllegalId()178 public void testVSgetnameIllegalId() throws Throwable { 179 HDFLibrary.VSgetname(-1, new String[1]); 180 } 181 182 // @Test(expected = HDFException.class) 183 // public void testVSeltsIllegalId() throws Throwable { 184 // HDFLibrary.VSelts(-1); 185 // } 186 187 @Test(expected = NullPointerException.class) testVSfdefineNullFieldName()188 public void testVSfdefineNullFieldName() throws Throwable { 189 HDFLibrary.VSfdefine(0, null, 0, 0); 190 } 191 192 @Test(expected = HDFException.class) testVSfdefineIllegalId()193 public void testVSfdefineIllegalId() throws Throwable { 194 HDFLibrary.VSfdefine(-1, "", 0, 0); 195 } 196 197 @Test(expected = NullPointerException.class) testVSfexistNullFields()198 public void testVSfexistNullFields() throws Throwable { 199 HDFLibrary.VSfexist(0, null); 200 } 201 202 @Test(expected = HDFException.class) testVSfexistIllegalId()203 public void testVSfexistIllegalId() throws Throwable { 204 HDFLibrary.VSfexist(-1, ""); 205 } 206 207 @Test(expected = NullPointerException.class) testVSfindNullVDataName()208 public void testVSfindNullVDataName() throws Throwable { 209 HDFLibrary.VSfind(0, null); 210 } 211 212 // @Test(expected = HDFException.class) 213 // public void testVSfindIllegalId() throws Throwable { 214 // HDFLibrary.VSfind(-1, ""); 215 // } 216 217 @Test(expected = HDFException.class) testVSsetblocksizeIllegalId()218 public void testVSsetblocksizeIllegalId() throws Throwable { 219 HDFLibrary.VSsetblocksize(-1, 0); 220 } 221 222 @Test(expected = HDFException.class) testVSsetnumblocksIllegalId()223 public void testVSsetnumblocksIllegalId() throws Throwable { 224 HDFLibrary.VSsetnumblocks(-1, 0); 225 } 226 227 @Test(expected = NullPointerException.class) testVSgetfieldsNullFieldName()228 public void testVSgetfieldsNullFieldName() throws Throwable { 229 HDFLibrary.VSgetfields(0, null); 230 } 231 232 @Test(expected = HDFException.class) testVSgetfieldsIllegalId()233 public void testVSgetfieldsIllegalId() throws Throwable { 234 HDFLibrary.VSgetfields(-1, new String[1]); 235 } 236 237 // @Test(expected = HDFException.class) 238 // public void testVSgetinterlaceIllegalId() throws Throwable { 239 // HDFLibrary.VSgetinterlace(-1); 240 // } 241 242 @Test(expected = NullPointerException.class) testVSinquireNullIArgs()243 public void testVSinquireNullIArgs() throws Throwable { 244 HDFLibrary.VSinquire(0, null, new String[2]); 245 } 246 247 @Test(expected = NullPointerException.class) testVSinquireNullSArgs()248 public void testVSinquireNullSArgs() throws Throwable { 249 HDFLibrary.VSinquire(0, new int[3], null); 250 } 251 252 @Test(expected = HDFException.class) testVSinquireIllegalId()253 public void testVSinquireIllegalId() throws Throwable { 254 HDFLibrary.VSinquire(-1, new int[3], new String[2]); 255 } 256 257 @Test(expected = IllegalArgumentException.class) testVSinquireIllegalIArgs()258 public void testVSinquireIllegalIArgs() throws Throwable { 259 HDFLibrary.VSinquire(0, new int[1], new String[2]); 260 } 261 262 @Test(expected = IllegalArgumentException.class) testVSinquireIllegalSArgs()263 public void testVSinquireIllegalSArgs() throws Throwable { 264 HDFLibrary.VSinquire(0, new int[3], new String[1]); 265 } 266 267 @Test(expected = NullPointerException.class) testVSloneNullRefArray()268 public void testVSloneNullRefArray() throws Throwable { 269 HDFLibrary.VSlone(0, null, 0); 270 } 271 272 // @Test(expected = HDFException.class) 273 // public void testVSloneIllegalId() throws Throwable { 274 // HDFLibrary.VSlone(-1, new int[10], 0); 275 // } 276 277 @Test(expected = NullPointerException.class) testVSreadNullDataBuffer()278 public void testVSreadNullDataBuffer() throws Throwable { 279 HDFLibrary.VSread(0, null, 0, 0); 280 } 281 282 // @Test(expected = HDFException.class) 283 // public void testVSreadIllegalId() throws Throwable { 284 // HDFLibrary.VSread(-1, new byte[] { }, 0, 0); 285 // } 286 287 // @Test(expected = HDFException.class) 288 // public void testVSseekIllegalId() throws Throwable { 289 // HDFLibrary.VSseek(-1, 0); 290 // } 291 292 @Test(expected = NullPointerException.class) testVSsetfieldsNullFields()293 public void testVSsetfieldsNullFields() throws Throwable { 294 HDFLibrary.VSsetfields(0, null); 295 } 296 297 @Test(expected = HDFException.class) testVSsetfieldsIllegalId()298 public void testVSsetfieldsIllegalId() throws Throwable { 299 HDFLibrary.VSsetfields(-1, ""); 300 } 301 302 @Test(expected = HDFException.class) testVSsetinterlaceIllegalId()303 public void testVSsetinterlaceIllegalId() throws Throwable { 304 HDFLibrary.VSsetinterlace(-1, 0); 305 } 306 307 @Test(expected = NullPointerException.class) testVSsizeofNullFields()308 public void testVSsizeofNullFields() throws Throwable { 309 HDFLibrary.VSsizeof(0, null); 310 } 311 312 @Test(expected = HDFException.class) testVSsizeofIllegalId()313 public void testVSsizeofIllegalId() throws Throwable { 314 HDFLibrary.VSsizeof(-1, ""); 315 } 316 317 @Test(expected = HDFException.class) testVSappendableIllegalVKey()318 public void testVSappendableIllegalVKey() throws Throwable { 319 HDFLibrary.VSappendable(-1, 0); 320 } 321 322 @Test(expected = NullPointerException.class) testVSfindclassNullClass()323 public void testVSfindclassNullClass() throws Throwable { 324 HDFLibrary.VSfindclass(0, null); 325 } 326 327 // @Test(expected = HDFException.class) 328 // public void testVSfindclassIllegalId() throws Throwable { 329 // HDFLibrary.VSfindclass(-1, ""); 330 // } 331 332 // @Test(expected = HDFException.class) 333 // public void testVSgetversionIllegalVKey() throws Throwable { 334 // HDFLibrary.VSgetversion(-1); 335 // } 336 337 @Test(expected = NullPointerException.class) testVSsetclassNullClass()338 public void testVSsetclassNullClass() throws Throwable { 339 HDFLibrary.VSsetclass(0, null); 340 } 341 342 @Test(expected = HDFException.class) testVSsetclassIllegalId()343 public void testVSsetclassIllegalId() throws Throwable { 344 HDFLibrary.VSsetclass(-1, ""); 345 } 346 347 @Test(expected = NullPointerException.class) testVSsetexternalfileNullFilename()348 public void testVSsetexternalfileNullFilename() throws Throwable { 349 HDFLibrary.VSsetexternalfile(0, null, 0); 350 } 351 352 @Test(expected = HDFException.class) testVSsetexternalfileIllegalVKey()353 public void testVSsetexternalfileIllegalVKey() throws Throwable { 354 HDFLibrary.VSsetexternalfile(-1, "", 0); 355 } 356 357 @Test(expected = NullPointerException.class) testVSsetnameNullVDataName()358 public void testVSsetnameNullVDataName() throws Throwable { 359 HDFLibrary.VSsetname(0, null); 360 } 361 362 @Test(expected = HDFException.class) testVSsetnameIllegalId()363 public void testVSsetnameIllegalId() throws Throwable { 364 HDFLibrary.VSsetname(-1, ""); 365 } 366 367 @Test(expected = NullPointerException.class) testVSwriteNullDataBuffer()368 public void testVSwriteNullDataBuffer() throws Throwable { 369 HDFLibrary.VSwrite(0, null, 0, 0); 370 } 371 372 @Test(expected = HDFException.class) testVSwriteIllegalId()373 public void testVSwriteIllegalId() throws Throwable { 374 HDFLibrary.VSwrite(-1, new byte[] { }, 0, 0); 375 } 376 377 @Test(expected = NullPointerException.class) testVSattrinfoNullName()378 public void testVSattrinfoNullName() throws Throwable { 379 HDFLibrary.VSattrinfo(0, 0, 0, null, new int[3]); 380 } 381 382 @Test(expected = NullPointerException.class) testVSattrinfoNullArgs()383 public void testVSattrinfoNullArgs() throws Throwable { 384 HDFLibrary.VSattrinfo(0, 0, 0, new String[1], null); 385 } 386 387 @Test(expected = HDFException.class) testVSattrinfoIllegalId()388 public void testVSattrinfoIllegalId() throws Throwable { 389 HDFLibrary.VSattrinfo(-1, 0, 0, new String[1], new int[3]); 390 } 391 392 @Test(expected = IllegalArgumentException.class) testVSattrinfoIllegalNameArgument()393 public void testVSattrinfoIllegalNameArgument() throws Throwable { 394 HDFLibrary.VSattrinfo(0, 0, 0, new String[0], new int[3]); 395 } 396 397 @Test(expected = IllegalArgumentException.class) testVSattrinfoIllegalAttributeArgs()398 public void testVSattrinfoIllegalAttributeArgs() throws Throwable { 399 HDFLibrary.VSattrinfo(0, 0, 0, new String[1], new int[1]); 400 } 401 402 @Test(expected = NullPointerException.class) testVSfindexNullName()403 public void testVSfindexNullName() throws Throwable { 404 HDFLibrary.VSfindex(0, null, new int[1]); 405 } 406 407 @Test(expected = NullPointerException.class) testVSfindexNullIndexArray()408 public void testVSfindexNullIndexArray() throws Throwable { 409 HDFLibrary.VSfindex(0, "", null); 410 } 411 412 @Test(expected = HDFException.class) testVSfindexIllegalId()413 public void testVSfindexIllegalId() throws Throwable { 414 HDFLibrary.VSfindex(-1, "", new int[1]); 415 } 416 417 @Test(expected = NullPointerException.class) testVSfindattrNullName()418 public void testVSfindattrNullName() throws Throwable { 419 HDFLibrary.VSfindattr(0, 0, null); 420 } 421 422 @Test(expected = HDFException.class) testVSfindattrIllegalId()423 public void testVSfindattrIllegalId() throws Throwable { 424 HDFLibrary.VSfindattr(-1, 0, ""); 425 } 426 427 // @Test(expected = HDFException.class) 428 // public void testVSfnattrsIllegalId() throws Throwable { 429 // HDFLibrary.VSfnattrs(-1, 0); 430 // } 431 432 @Test(expected = NullPointerException.class) testVSgetattrNullData()433 public void testVSgetattrNullData() throws Throwable { 434 HDFLibrary.VSgetattr(0, 0, 0, null); 435 } 436 437 @Test(expected = HDFException.class) testVSgetattrIllegalId()438 public void testVSgetattrIllegalId() throws Throwable { 439 HDFLibrary.VSgetattr(-1, 0, 0, new byte[] { }); 440 } 441 442 // @Test(expected = HDFException.class) 443 // public void testVSisattrIllegalId() throws Throwable { 444 // HDFLibrary.VSisattr(-1); 445 // } 446 447 // @Test(expected = HDFException.class) 448 // public void testVSnattrsIllegalId() throws Throwable { 449 // HDFLibrary.VSnattrs(-1); 450 // } 451 452 @Test(expected = NullPointerException.class) testVSsetattrNullAttributeName()453 public void testVSsetattrNullAttributeName() throws Throwable { 454 HDFLibrary.VSsetattr(0, 0, null, 0, 0, new byte[] { }); 455 } 456 457 @Test(expected = NullPointerException.class) testVSsetattrNullAttributeName2()458 public void testVSsetattrNullAttributeName2() throws Throwable { 459 HDFLibrary.VSsetattr(0, 0, null, 0, 0, ""); 460 } 461 462 // @Test(expected = NullPointerException.class) 463 // public void testVSsetattrNullValues() throws Throwable { 464 // HDFLibrary.VSsetattr(0, 0, "", 0, 0, null); 465 // } 466 467 @Test(expected = HDFException.class) testVSsetattrIllegalId()468 public void testVSsetattrIllegalId() throws Throwable { 469 HDFLibrary.VSsetattr(-1, 0, "", 0, 0, new byte[] { }); 470 } 471 472 @Test(expected = HDFException.class) testVSsetattrIllegalId2()473 public void testVSsetattrIllegalId2() throws Throwable { 474 HDFLibrary.VSsetattr(-1, 0, "", 0, 0, ""); 475 } 476 } 477