Skip to content

Commit 1b5ae3e

Browse files
ChristianTackeGSIfuhlig1
authored andcommitted
refactor(tests/geobase): Use valued variables
And simplify string initialization
1 parent 5268bc9 commit 1b5ae3e

2 files changed

Lines changed: 40 additions & 42 deletions

File tree

tests/geobase/tests_FairGeoSet.cxx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,13 @@ TEST_CASE("FairTestGeo")
7676
volu->setPoint(6, -20000., 20000., 20000.);
7777
volu->setPoint(7, -20000., -20000., 20000.);
7878

79-
auto masterNodes = std::make_unique<TList>();
80-
masterNodes->Add(new FairGeoNode(*volu));
79+
TList masterNodes{};
80+
masterNodes.Add(new FairGeoNode(*volu));
8181

8282
INFO("Master volume created");
8383

8484
FairTestGeo geo;
85-
geo.setMasterNodes(masterNodes.get());
85+
geo.setMasterNodes(&masterNodes);
8686
geo.setShapes(new FairGeoShapes());
8787

8888
// fairroot::tests::checkGeoSetNamingConventions(geo, "testdet", 10);

tests/geobase/tests_FairGeoShapes.cxx

Lines changed: 37 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,14 @@ TEST_CASE("FairGeoBasicShape")
3434
{
3535
FairGeoBasicShape shape;
3636

37-
check_FairGeoShape_Construction(shape, std::string{""}, 0, nullptr);
37+
check_FairGeoShape_Construction(shape, "", 0, nullptr);
3838
}
3939

4040
TEST_CASE("FairGeoAssembly")
4141
{
4242
FairGeoAssembly shape;
43-
std::unique_ptr<TArrayD> paramArray(new TArrayD(0));
44-
check_FairGeoShape_Construction(shape, std::string{"ASSEMBLY"}, 0, paramArray.get());
43+
TArrayD paramArray{0};
44+
check_FairGeoShape_Construction(shape, "ASSEMBLY", 0, &paramArray);
4545
}
4646

4747
TEST_CASE("FairGeoBrik")
@@ -62,11 +62,11 @@ TEST_CASE("FairGeoBrik")
6262
FairGeoVolume volume;
6363

6464
// Check if the constructor works as expected
65-
std::unique_ptr<TArrayD> paramArray{new TArrayD(numParams)};
66-
check_FairGeoShape_Construction(shape, std::string{"BOX "}, numPoints, paramArray.get());
65+
TArrayD paramArray{numParams};
66+
check_FairGeoShape_Construction(shape, "BOX ", numPoints, &paramArray);
6767

6868
// Check reading and writing from volume/shape parameters
69-
check_FairGeoShape_ReadWrite(shape, volume, std::string{"BOX"}, numPoints, parameters);
69+
check_FairGeoShape_ReadWrite(shape, volume, "BOX", numPoints, parameters);
7070
}
7171

7272
TEST_CASE("FairGeoCone")
@@ -92,11 +92,11 @@ TEST_CASE("FairGeoCone")
9292
FairGeoVolume volume;
9393

9494
// Check if the constructor works as expected
95-
std::unique_ptr<TArrayD> paramArray{new TArrayD(numParams)};
96-
check_FairGeoShape_Construction(shape, std::string{"CONE"}, numPoints, paramArray.get());
95+
TArrayD paramArray{numParams};
96+
check_FairGeoShape_Construction(shape, "CONE", numPoints, &paramArray);
9797

9898
// Check reading and writing from volume/shape parameters
99-
check_FairGeoShape_ReadWrite(shape, volume, std::string{"CONE"}, numPoints, parameters);
99+
check_FairGeoShape_ReadWrite(shape, volume, "CONE", numPoints, parameters);
100100
}
101101

102102
TEST_CASE("FairGeoCons")
@@ -121,11 +121,11 @@ TEST_CASE("FairGeoCons")
121121
FairGeoVolume volume;
122122

123123
// Check if the constructor works as expected
124-
std::unique_ptr<TArrayD> paramArray{new TArrayD(numParams)};
125-
check_FairGeoShape_Construction(shape, std::string{"CONS"}, numPoints, paramArray.get());
124+
TArrayD paramArray{numParams};
125+
check_FairGeoShape_Construction(shape, "CONS", numPoints, &paramArray);
126126

127127
// Check reading and writing from volume/shape parameters
128-
check_FairGeoShape_ReadWrite(shape, volume, std::string{"CONS"}, numPoints, parameters);
128+
check_FairGeoShape_ReadWrite(shape, volume, "CONS", numPoints, parameters);
129129
}
130130

131131
TEST_CASE("FairGeoEltu")
@@ -147,11 +147,11 @@ TEST_CASE("FairGeoEltu")
147147
FairGeoVolume volume;
148148

149149
// Check if the constructor works as expected
150-
std::unique_ptr<TArrayD> paramArray{new TArrayD(numParams)};
151-
check_FairGeoShape_Construction(shape, std::string{"ELTU"}, numPoints, paramArray.get());
150+
TArrayD paramArray{numParams};
151+
check_FairGeoShape_Construction(shape, "ELTU", numPoints, &paramArray);
152152

153153
// Check reading and writing from volume/shape parameters
154-
check_FairGeoShape_ReadWrite(shape, volume, std::string{"ELTU"}, numPoints, parameters);
154+
check_FairGeoShape_ReadWrite(shape, volume, "ELTU", numPoints, parameters);
155155
}
156156

157157
TEST_CASE("FairGeoPcon")
@@ -184,11 +184,10 @@ TEST_CASE("FairGeoPcon")
184184
// Check if the constructor works as expected
185185
// At construction the number of points and parameters are 0
186186
// The values are updated when reading the shape information
187-
std::unique_ptr<TArrayD> paramArray(nullptr);
188-
check_FairGeoShape_Construction(shape, std::string{"PCON"}, 0, paramArray.get());
187+
check_FairGeoShape_Construction(shape, "PCON", 0, nullptr);
189188

190189
// Check reading and writing from volume/shape parameters
191-
check_FairGeoShape_ReadWrite(shape, volume, std::string{"PCON"}, numPoints, parameters);
190+
check_FairGeoShape_ReadWrite(shape, volume, "PCON", numPoints, parameters);
192191
}
193192

194193
TEST_CASE("FairGeoPgon")
@@ -222,11 +221,10 @@ TEST_CASE("FairGeoPgon")
222221
// Check if the constructor works as expected
223222
// At construction the number of points and parameters are 0
224223
// The values are updated when reading the shape information
225-
std::unique_ptr<TArrayD> paramArray(nullptr);
226-
check_FairGeoShape_Construction(shape, std::string{"PGON"}, 0, paramArray.get());
224+
check_FairGeoShape_Construction(shape, "PGON", 0, nullptr);
227225

228226
// Check reading and writing from volume/shape parameters
229-
check_FairGeoShape_ReadWrite(shape, volume, std::string{"PGON"}, numPoints, parameters);
227+
check_FairGeoShape_ReadWrite(shape, volume, "PGON", numPoints, parameters);
230228
}
231229

232230
TEST_CASE("FairGeoSphe")
@@ -246,11 +244,11 @@ TEST_CASE("FairGeoSphe")
246244
FairGeoVolume volume;
247245

248246
// Check if the constructor works as expected
249-
std::unique_ptr<TArrayD> paramArray{new TArrayD(numParams)};
250-
check_FairGeoShape_Construction(shape, std::string{"SPHE"}, numPoints, paramArray.get());
247+
TArrayD paramArray{numParams};
248+
check_FairGeoShape_Construction(shape, "SPHE", numPoints, &paramArray);
251249

252250
// Check reading and writing from volume/shape parameters
253-
check_FairGeoShape_ReadWrite(shape, volume, std::string{"SPHE"}, numPoints, parameters);
251+
check_FairGeoShape_ReadWrite(shape, volume, "SPHE", numPoints, parameters);
254252
}
255253

256254
TEST_CASE("FairGeoTorus")
@@ -271,11 +269,11 @@ TEST_CASE("FairGeoTorus")
271269
FairGeoVolume volume;
272270

273271
// Check if the constructor works as expected
274-
std::unique_ptr<TArrayD> paramArray{new TArrayD(numParams)};
275-
check_FairGeoShape_Construction(shape, std::string{"TORUS"}, numPoints, paramArray.get());
272+
TArrayD paramArray{numParams};
273+
check_FairGeoShape_Construction(shape, "TORUS", numPoints, &paramArray);
276274

277275
// Check reading and writing from volume/shape parameters
278-
check_FairGeoShape_ReadWrite(shape, volume, std::string{"TORUS"}, numPoints, parameters);
276+
check_FairGeoShape_ReadWrite(shape, volume, "TORUS", numPoints, parameters);
279277
}
280278

281279
TEST_CASE("FairGeoTrap")
@@ -300,11 +298,11 @@ TEST_CASE("FairGeoTrap")
300298
FairGeoVolume volume;
301299

302300
// Check if the constructor works as expected
303-
std::unique_ptr<TArrayD> paramArray{new TArrayD(numParams)};
304-
check_FairGeoShape_Construction(shape, std::string{"TRAP"}, numPoints, paramArray.get());
301+
TArrayD paramArray{numParams};
302+
check_FairGeoShape_Construction(shape, "TRAP", numPoints, &paramArray);
305303

306304
// Check reading and writing from volume/shape parameters
307-
check_FairGeoShape_ReadWrite(shape, volume, std::string{"TRAP"}, numPoints, parameters);
305+
check_FairGeoShape_ReadWrite(shape, volume, "TRAP", numPoints, parameters);
308306
}
309307

310308
TEST_CASE("FairGeoTrd1")
@@ -334,11 +332,11 @@ TEST_CASE("FairGeoTrd1")
334332
FairGeoVolume volume;
335333

336334
// Check if the constructor works as expected
337-
std::unique_ptr<TArrayD> paramArray{new TArrayD(numParams)};
338-
check_FairGeoShape_Construction(shape, std::string{"TRD1"}, numPoints, paramArray.get());
335+
TArrayD paramArray{numParams};
336+
check_FairGeoShape_Construction(shape, "TRD1", numPoints, &paramArray);
339337

340338
// Check reading and writing from volume/shape parameters
341-
check_FairGeoShape_ReadWrite(shape, volume, std::string{"TRD1"}, numPoints, parameters);
339+
check_FairGeoShape_ReadWrite(shape, volume, "TRD1", numPoints, parameters);
342340
}
343341

344342
TEST_CASE("FairGeoTube")
@@ -360,11 +358,11 @@ TEST_CASE("FairGeoTube")
360358
FairGeoVolume volume;
361359

362360
// Check if the constructor works as expected
363-
std::unique_ptr<TArrayD> paramArray{new TArrayD(numParams)};
364-
check_FairGeoShape_Construction(shape, std::string{"TUBE"}, numPoints, paramArray.get());
361+
TArrayD paramArray{numParams};
362+
check_FairGeoShape_Construction(shape, "TUBE", numPoints, &paramArray);
365363

366364
// Check reading and writing from volume/shape parameters
367-
check_FairGeoShape_ReadWrite(shape, volume, std::string{"TUBE"}, numPoints, parameters);
365+
check_FairGeoShape_ReadWrite(shape, volume, "TUBE", numPoints, parameters);
368366
}
369367

370368
TEST_CASE("FairGeoTubs")
@@ -388,9 +386,9 @@ TEST_CASE("FairGeoTubs")
388386
FairGeoVolume volume;
389387

390388
// Check if the constructor works as expected
391-
std::unique_ptr<TArrayD> paramArray{new TArrayD(numParams)};
392-
check_FairGeoShape_Construction(shape, std::string{"TUBS"}, numPoints, paramArray.get());
389+
TArrayD paramArray{numParams};
390+
check_FairGeoShape_Construction(shape, "TUBS", numPoints, &paramArray);
393391

394392
// Check reading and writing from volume/shape parameters
395-
check_FairGeoShape_ReadWrite(shape, volume, std::string{"TUBS"}, numPoints, parameters);
393+
check_FairGeoShape_ReadWrite(shape, volume, "TUBS", numPoints, parameters);
396394
}

0 commit comments

Comments
 (0)