Skip to content

Commit 5eab84d

Browse files
Fixed tests for XML and HDF4
The tests were failing due to a change in the attribute interface. close #426
1 parent bac0c65 commit 5eab84d

1 file changed

Lines changed: 34 additions & 19 deletions

File tree

test/napi_test_cpp.cxx

Lines changed: 34 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -227,35 +227,50 @@ string toString(const vector<NumT> & data) {
227227
return result.str();
228228
}
229229

230+
string get_extension(const string &filename)
231+
{
232+
int dot_pos = filename.find('.');
233+
return string(filename,dot_pos);
234+
}
235+
230236
int readTest(const string & filename) {
231237
const string SDS("SDS");
232238
// top level file information
233239
NeXus::File file(filename);
240+
241+
string file_extension = get_extension(filename);
234242
cout << "NXinquirefile found: " << relativePathOf(file.inquireFile()) << endl;
235-
vector<NeXus::AttrInfo> attr_infos = file.getAttrInfos();
236-
cout << "Number of global attributes: " << attr_infos.size() << endl;
237-
for (vector<NeXus::AttrInfo>::iterator it = attr_infos.begin();
238-
it != attr_infos.end(); it++) {
239-
if (it->name != "file_time" && it->name != "HDF_version" && it->name != "HDF5_Version" && it->name != "XML_version") {
240-
cout << " " << it->name << " = ";
241-
if (it->type == NeXus::CHAR) {
242-
cout << file.getStrAttr(*it);
243+
vector<NeXus::AttrInfo> attr_infos;
244+
if(file_extension==".h5")
245+
{
246+
attr_infos = file.getAttrInfos();
247+
cout << "Number of global attributes: " << attr_infos.size() << endl;
248+
for (vector<NeXus::AttrInfo>::iterator it = attr_infos.begin();
249+
it != attr_infos.end(); it++) {
250+
if (it->name != "file_time" && it->name != "HDF_version" && it->name != "HDF5_Version" && it->name != "XML_version") {
251+
cout << " " << it->name << " = ";
252+
if (it->type == NeXus::CHAR) {
253+
cout << file.getStrAttr(*it);
254+
}
255+
cout << endl;
243256
}
244-
cout << endl;
245-
}
257+
}
246258
}
247259

248260
// check group attributes
249261
file.openGroup("entry", "NXentry");
250-
attr_infos = file.getAttrInfos();
251-
cout << "Number of group attributes: " << attr_infos.size() << endl;
252-
for (vector<NeXus::AttrInfo>::iterator it = attr_infos.begin();
253-
it != attr_infos.end(); it++) {
254-
cout << " " << it->name << " = ";
255-
if (it->type == NeXus::CHAR) {
256-
cout << file.getStrAttr(*it);
257-
}
258-
cout << endl;
262+
if(file_extension==".h5")
263+
{
264+
attr_infos = file.getAttrInfos();
265+
cout << "Number of group attributes: " << attr_infos.size() << endl;
266+
for (vector<NeXus::AttrInfo>::iterator it = attr_infos.begin();
267+
it != attr_infos.end(); it++) {
268+
cout << " " << it->name << " = ";
269+
if (it->type == NeXus::CHAR) {
270+
cout << file.getStrAttr(*it);
271+
}
272+
cout << endl;
273+
}
259274
}
260275

261276
// print out the entry level fields

0 commit comments

Comments
 (0)