@@ -33,7 +33,7 @@ static std::string relativePathOf(const std::string &filenamestr) {
33
33
}
34
34
}
35
35
36
- static int writeTest (const string &filename, NXaccess create_code) {
36
+ static void writeTest (const string &filename, NXaccess create_code) {
37
37
NeXus::File file (filename, create_code);
38
38
// create group
39
39
file.makeGroup (" entry" , " NXentry" , true );
@@ -55,21 +55,21 @@ static int writeTest(const string &filename, NXaccess create_code) {
55
55
56
56
// 1d uint8 array
57
57
vector<uint8_t > i1_array;
58
- for (size_t i = 0 ; i < 4 ; i++) {
58
+ for (uint8_t i = 0 ; i < 4 ; i++) {
59
59
i1_array.push_back (static_cast <uint8_t >(i + 1 ));
60
60
}
61
61
file.writeData (" i1_data" , i1_array);
62
62
63
63
// 1d int16 array
64
64
vector<int16_t > i2_array;
65
- for (size_t i = 0 ; i < 4 ; i++) {
66
- i2_array.push_back (1000 * (i + 1 ));
65
+ for (int16_t i = 0 ; i < 4 ; i++) {
66
+ i2_array.push_back (static_cast < int16_t >( 1000 * (i + 1 ) ));
67
67
}
68
68
file.writeData (" i2_data" , i2_array);
69
69
70
70
// 1d int32 data
71
71
vector<int32_t > i4_array;
72
- for (size_t i = 0 ; i < 4 ; i++) {
72
+ for (int32_t i = 0 ; i < 4 ; i++) {
73
73
i4_array.push_back (1000000 * (i + 1 ));
74
74
}
75
75
file.writeData (" i4_data" , i4_array);
@@ -204,8 +204,6 @@ static int writeTest(const string &filename, NXaccess create_code) {
204
204
file.makeLink (glink);
205
205
file.makeNamedLink (" renLinkGroup" , glink);
206
206
file.makeNamedLink (" renLinkData" , link);
207
-
208
- return 0 ;
209
207
}
210
208
211
209
template <typename NumT> string toString (const vector<NumT> &data) {
@@ -469,10 +467,10 @@ int testLoadPath(const string &filename) {
469
467
}
470
468
}
471
469
472
- int testExternal (const string &fileext, NXaccess create_code) {
473
- string filename (" nxext_cpp" + fileext);
474
- string exturl1 (" nxfile://data/dmc01" + fileext + " #entry1" );
475
- string exturl2 (" nxfile://data/dmc02" + fileext + " #entry1" );
470
+ void testExternal (const string &fileext, NXaccess create_code) {
471
+ const string filename (" nxext_cpp" + fileext);
472
+ const string exturl1 (" nxfile://data/dmc01" + fileext + " #entry1" );
473
+ const string exturl2 (" nxfile://data/dmc02" + fileext + " #entry1" );
476
474
477
475
// create the external link
478
476
NeXus::File fileout (filename, create_code);
@@ -492,8 +490,6 @@ int testExternal(const string &fileext, NXaccess create_code) {
492
490
cout << " Second file time: " << filein.getStrData () << endl;
493
491
filein.openPath (" /" );
494
492
cout << " entry1 external URL = " << filein.isExternalGroup (" entry1" , " NXentry" ) << endl;
495
-
496
- return 0 ;
497
493
}
498
494
499
495
int testTypeMap (const std::string &fname) {
@@ -538,9 +534,11 @@ int main(int argc, char **argv) {
538
534
extfile_ext = " .hdf" ;
539
535
}
540
536
541
- if (int result = writeTest (filename, nx_creation_code)) {
542
- cout << " writeTest failed" << endl;
543
- return result;
537
+ try {
538
+ writeTest (filename, nx_creation_code);
539
+ } catch (const std::runtime_error &e) {
540
+ cout << " writeTest failed:\n " << e.what () << endl;
541
+ return 1 ;
544
542
}
545
543
if ((argc >= 2 ) && !strcmp (argv[1 ], " -q" )) {
546
544
return 0 ; //
@@ -559,9 +557,11 @@ int main(int argc, char **argv) {
559
557
}
560
558
561
559
// try external linking
562
- if (int result = testExternal (extfile_ext, nx_creation_code)) {
563
- cout << " testExternal failed" << endl;
564
- return result;
560
+ try {
561
+ testExternal (extfile_ext, nx_creation_code);
562
+ } catch (const std::runtime_error &e) {
563
+ cout << " testExternal failed:\n " << e.what () << endl;
564
+ return 1 ;
565
565
}
566
566
567
567
// test of typemap generation
0 commit comments