@@ -62,10 +62,9 @@ sdf::SDFPtr InitSDF()
6262// ///////////////////////////////////////////////
6363TEST (Parser, ReusedSDFVersion)
6464{
65- std::string pathBase = PROJECT_SOURCE_PATH;
66- pathBase += " /test/sdf" ;
67- const std::string path17 = pathBase +" /model_link_relative_to.sdf" ;
68- const std::string path16 = pathBase +" /joint_complete.sdf" ;
65+ const auto path17 = sdf::testing::TestFile (
66+ " sdf" , " model_link_relative_to.sdf" );
67+ const auto path16 = sdf::testing::TestFile (" sdf" , " joint_complete.sdf" );
6968
7069 // Call readFile API that always converts
7170 sdf::SDFPtr sdf = InitSDF ();
@@ -85,9 +84,7 @@ TEST(Parser, ReusedSDFVersion)
8584// ///////////////////////////////////////////////
8685TEST (Parser, readFileConversions)
8786{
88- std::string pathBase = PROJECT_SOURCE_PATH;
89- pathBase += " /test/sdf" ;
90- const std::string path = pathBase +" /joint_complete.sdf" ;
87+ const auto path = sdf::testing::TestFile (" sdf" , " joint_complete.sdf" );
9188
9289 // Call readFile API that always converts
9390 {
@@ -346,16 +343,13 @@ TEST(Parser, addNestedModel)
346343// ///////////////////////////////////////////////
347344TEST (Parser, NameUniqueness)
348345{
349- std::string pathBase = PROJECT_SOURCE_PATH;
350- pathBase += " /test/sdf" ;
351-
352346 // These tests are copies of the ones in ign_TEST.cc but use direct calls to
353347 // name uniqueness validator functions instead of going through ign.
354348
355349 // Check an SDF file with sibling elements of the same type (world)
356350 // that have duplicate names.
357351 {
358- std::string path = pathBase + " / world_duplicate.sdf" ;
352+ const auto path = sdf::testing::TestFile ( " sdf " , " world_duplicate.sdf" ) ;
359353 sdf::SDFPtr sdf = InitSDF ();
360354 EXPECT_TRUE (sdf::readFile (path, sdf));
361355 EXPECT_FALSE (sdf::recursiveSameTypeUniqueNames (sdf->Root ()));
@@ -368,7 +362,8 @@ TEST(Parser, NameUniqueness)
368362 // Check an SDF file with sibling elements of different types (model, light)
369363 // that have duplicate names.
370364 {
371- std::string path = pathBase +" /world_sibling_same_names.sdf" ;
365+ const auto path = sdf::testing::TestFile (" sdf" ,
366+ " world_sibling_same_names.sdf" );
372367 sdf::SDFPtr sdf = InitSDF ();
373368 EXPECT_TRUE (sdf::readFile (path, sdf));
374369 EXPECT_FALSE (sdf::recursiveSiblingUniqueNames (sdf->Root ()));
@@ -381,7 +376,8 @@ TEST(Parser, NameUniqueness)
381376 // Check an SDF file with sibling elements of the same type (link)
382377 // that have duplicate names.
383378 {
384- std::string path = pathBase +" /model_duplicate_links.sdf" ;
379+ const auto path = sdf::testing::TestFile (" sdf" ,
380+ " model_duplicate_links.sdf" );
385381 sdf::SDFPtr sdf = InitSDF ();
386382 EXPECT_TRUE (sdf::readFile (path, sdf));
387383 EXPECT_FALSE (sdf::recursiveSameTypeUniqueNames (sdf->Root ()));
@@ -394,7 +390,8 @@ TEST(Parser, NameUniqueness)
394390 // Check an SDF file with sibling elements of the same type (joint)
395391 // that have duplicate names.
396392 {
397- std::string path = pathBase +" /model_duplicate_joints.sdf" ;
393+ const auto path = sdf::testing::TestFile (" sdf" ,
394+ " model_duplicate_joints.sdf" );
398395 sdf::SDFPtr sdf = InitSDF ();
399396 EXPECT_TRUE (sdf::readFile (path, sdf));
400397 EXPECT_FALSE (sdf::recursiveSameTypeUniqueNames (sdf->Root ()));
@@ -407,7 +404,8 @@ TEST(Parser, NameUniqueness)
407404 // Check an SDF file with sibling elements of different types (link, joint)
408405 // that have duplicate names.
409406 {
410- std::string path = pathBase +" /model_link_joint_same_name.sdf" ;
407+ const auto path = sdf::testing::TestFile (" sdf" ,
408+ " model_link_joint_same_name.sdf" );
411409 sdf::SDFPtr sdf = InitSDF ();
412410 EXPECT_TRUE (sdf::readFile (path, sdf));
413411 EXPECT_FALSE (sdf::recursiveSiblingUniqueNames (sdf->Root ()));
@@ -420,7 +418,8 @@ TEST(Parser, NameUniqueness)
420418 // Check an SDF file with sibling elements of the same type (collision)
421419 // that have duplicate names.
422420 {
423- std::string path = pathBase +" /link_duplicate_sibling_collisions.sdf" ;
421+ const auto path = sdf::testing::TestFile (" sdf" ,
422+ " link_duplicate_sibling_collisions.sdf" );
424423 sdf::SDFPtr sdf = InitSDF ();
425424 EXPECT_TRUE (sdf::readFile (path, sdf));
426425 EXPECT_FALSE (sdf::recursiveSameTypeUniqueNames (sdf->Root ()));
@@ -433,7 +432,8 @@ TEST(Parser, NameUniqueness)
433432 // Check an SDF file with sibling elements of the same type (visual)
434433 // that have duplicate names.
435434 {
436- std::string path = pathBase +" /link_duplicate_sibling_visuals.sdf" ;
435+ const auto path = sdf::testing::TestFile (" sdf" ,
436+ " link_duplicate_sibling_visuals.sdf" );
437437 sdf::SDFPtr sdf = InitSDF ();
438438 EXPECT_TRUE (sdf::readFile (path, sdf));
439439 EXPECT_FALSE (sdf::recursiveSiblingUniqueNames (sdf->Root ()));
@@ -446,7 +446,8 @@ TEST(Parser, NameUniqueness)
446446 // Check an SDF file with cousin elements of the same type (collision)
447447 // that have duplicate names. This is a valid file.
448448 {
449- std::string path = pathBase +" /link_duplicate_cousin_collisions.sdf" ;
449+ const auto path = sdf::testing::TestFile (" sdf" ,
450+ " link_duplicate_cousin_collisions.sdf" );
450451 sdf::SDFPtr sdf = InitSDF ();
451452 EXPECT_TRUE (sdf::readFile (path, sdf));
452453 EXPECT_TRUE (sdf::recursiveSameTypeUniqueNames (sdf->Root ()));
@@ -460,7 +461,8 @@ TEST(Parser, NameUniqueness)
460461 // Check an SDF file with cousin elements of the same type (visual)
461462 // that have duplicate names. This is a valid file.
462463 {
463- std::string path = pathBase +" /link_duplicate_cousin_visuals.sdf" ;
464+ const auto path = sdf::testing::TestFile (" sdf" ,
465+ " link_duplicate_cousin_visuals.sdf" );
464466 sdf::SDFPtr sdf = InitSDF ();
465467 EXPECT_TRUE (sdf::readFile (path, sdf));
466468 EXPECT_TRUE (sdf::recursiveSameTypeUniqueNames (sdf->Root ()));
0 commit comments