1// =============================================================================
2// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3// Copyright (C) 2012 - SCILAB ENTERPRISES - Simon GARESTE
4//
5//  This file is distributed under the same license as the Scilab package.
6// =============================================================================
7//
8// <-- CLI SHELL MODE -->
9
10msgerr = msprintf(gettext("%s: Wrong number of input argument(s): %d to %d expected.\n"),"h5rm", 1, 2);
11assert_checkerror("h5rm()", msgerr, 77);
12msgerr = msprintf(gettext("%s: Wrong type for input argument #%d: string or H5Object expected.\n"), "h5rm", 1);
13assert_checkerror("h5rm(42)", msgerr, 999);
14msgerr = msprintf(gettext("%s: Wrong number of input arguments: %d expected.\n"),"h5rm", 2);
15assert_checkerror("h5rm(""42"")", msgerr, 999);
16msgerr = msprintf(gettext("%s: %s\n"), "h5rm", msprintf(gettext("Invalid hdf5 file: %s."), "42"));
17assert_checkerror("h5rm(""42"",""42"")", msgerr, 999);
18
19
20a = h5open(TMPDIR + "/test.h5", "a");
21names = "Group_" + string(1:10);
22h5group(a, names)
23names = "Group_" + string(2:10);
24h5rm(a,"Group_1");
25assert_checkequal(a.root.Groups,gsort(names',"g",'i'));
26halfnames = "Group_" + string(2:2:10);
27oppositehalfnames = "Group_" + string(3:2:10);
28h5rm(a,halfnames);
29assert_checkequal(a.root.Groups,gsort(oppositehalfnames',"g",'i'));
30msgerr = msprintf(gettext("%s: %s\n"), "h5rm", msprintf(gettext("The name doesn''t exist: %s."), "failingtest"));
31assert_checkerror('h5rm(a,""failingtest"")', msgerr, 999);
32msgerr = msprintf(gettext("%s: %s\n"), "h5rm", gettext("Cannot remove a file."));
33assert_checkerror('h5rm(a)', msgerr, 999);
34msgerr = msprintf(gettext("%s: %s\n"), "h5rm", gettext("Cannot remove root element."));
35assert_checkerror('h5rm(a.root)', msgerr, 999);
36msgerr = msprintf(gettext("%s: Wrong type for input argument #%d: string or H5Object expected.\n"), "h5rm", 1);
37assert_checkerror('h5rm(a.root.Groups)', msgerr, 999);
38
39h5write(a.root.Group_3, "Dset_1", [1 2 ; 3 4]);
40h5ln(a, "Hard_Link", "/Group_3/Dset_1", %t);
41h5rm(a,"Hard_Link");
42msgerr = msprintf(gettext("%s: Error in retrieving field content:\n%s\n"), "%H5Object_e", msprintf(gettext("Invalid field: %s"), "Hard_Link"));
43assert_checkerror('a.root.Hard_Link', msgerr, 999);
44h5rm(a,"/Group_3/Dset_1");
45msgerr = msprintf(gettext("%s: Error in retrieving field content:\n%s\n"), "%H5Object_e", msprintf(gettext("Invalid field: %s"), "Dset_1"));
46assert_checkerror('a.root.Group_3.Dset_1', msgerr, 999);
47
48h5ln(a,"Soft_Link",".Group_1/Dset_1");
49msgerr = msprintf(gettext("%s: Error in retrieving field content:\n%s\n"), "%H5Object_e", msprintf(gettext("Invalid field: %s"), "Soft_Link"));
50assert_checkerror('h5rm(a,a.root.Soft_Link)', msgerr, 999);
51h5rm(a,a.root.Softs);
52assert_checkequal(a.root.Softs,[]);
53h5write(a.root.Group_3, "Dset_1", [1 2 ; 3 4]);
54h5ln(a,"Soft_Link",".Group_3/Dset_1");
55
56h5close(a);
57