Tesseract
Motion Planning Environment
Loading...
Searching...
No Matches
Classes | Functions | Variables
resource_locator_unit.cpp File Reference
#include <tesseract_common/macros.h>
#include <gtest/gtest.h>
#include <iostream>
#include <fstream>
#include <tesseract_common/resource_locator.h>
#include <tesseract_common/types.h>
#include <tesseract_common/unit_test_utils.h>
Include dependency graph for resource_locator_unit.cpp:

Classes

class  TestResourceLocator
 Resource locator implementation using a provided function to locate file resources. More...
 

Functions

tesseract_common::fs::path file_path (__FILE__)
 
 EXPECT_TRUE (resource !=nullptr)
 
 EXPECT_TRUE (resource->isFile())
 
 EXPECT_EQ (resource->getUrl(), "package://tesseract_common/package.xml")
 
 EXPECT_EQ (tesseract_common::fs::path(resource->getFilePath()),(package_path/"package.xml"))
 
 EXPECT_FALSE (resource->getResourceContents().empty())
 
 EXPECT_TRUE (resource->getResourceContentStream() !=nullptr)
 
 EXPECT_TRUE (sub_resource !=nullptr)
 
 EXPECT_TRUE (sub_resource->isFile())
 
 EXPECT_EQ (sub_resource->getUrl(), "package://tesseract_common/colcon.pkg")
 
 EXPECT_EQ (tesseract_common::fs::path(sub_resource->getFilePath()),(package_path/"colcon.pkg"))
 
 EXPECT_FALSE (sub_resource->getResourceContents().empty())
 
 EXPECT_TRUE (sub_resource->getResourceContentStream() !=nullptr)
 
 EXPECT_TRUE (sub_resource_empty==nullptr)
 
 EXPECT_TRUE (resource_empty==nullptr)
 
 EXPECT_TRUE (resource_does_not_exist !=nullptr)
 
 EXPECT_TRUE (resource_does_not_exist->getResourceContents().empty())
 
 EXPECT_TRUE (resource_does_not_exist->getResourceContentStream()==nullptr)
 
 putenv (env_var.data())
 
 EXPECT_TRUE (byte_resource !=nullptr)
 
 EXPECT_FALSE (byte_resource->isFile())
 
 EXPECT_EQ (byte_resource->getUrl(), "package://tesseract_common/package.xml")
 
 EXPECT_TRUE (byte_resource->getFilePath().empty())
 
 EXPECT_FALSE (byte_resource->getResourceContents().empty())
 
 EXPECT_TRUE (byte_resource->getResourceContentStream() !=nullptr)
 
SimpleLocatedResource resource ("url", "file_path")
 
BytesResource resource ("url", { 1, 2, 3, 4, 5 })
 
int main (int argc, char **argv)
 

Variables

tesseract_common::fs::path package_path = file_path.parent_path().parent_path()
 
ResourceLocator::Ptr locator = std::make_shared<TestResourceLocator>()
 
Resource::Ptr resource = locator->locateResource("package://tesseract_common/package.xml")
 
Resource::Ptr sub_resource = resource->locateResource("colcon.pkg")
 
tesseract_common::Resource::Ptr sub_resource_empty = sub_resource->locateResource("")
 
tesseract_common::Resource::Ptr resource_empty = locator->locateResource("")
 
tesseract_common::Resource::Ptr resource_does_not_exist
 
std::string env_var = "TESSERACT_RESOURCE_PATH=" + package_path.string()
 
auto byte_resource
 

Function Documentation

◆ EXPECT_EQ() [1/5]

EXPECT_EQ ( byte_resource->  getUrl(),
"package://tesseract_common/package.xml"   
)

◆ EXPECT_EQ() [2/5]

EXPECT_EQ ( resource->  getUrl(),
"package://tesseract_common/package.xml"   
)

◆ EXPECT_EQ() [3/5]

EXPECT_EQ ( sub_resource->  getUrl(),
"package://tesseract_common/colcon.pkg"   
)

◆ EXPECT_EQ() [4/5]

EXPECT_EQ ( tesseract_common::fs::path(resource->getFilePath())  ,
(package_path/"package.xml")   
)

◆ EXPECT_EQ() [5/5]

EXPECT_EQ ( tesseract_common::fs::path(sub_resource->getFilePath())  ,
(package_path/"colcon.pkg")   
)

◆ EXPECT_FALSE() [1/4]

EXPECT_FALSE ( byte_resource->  getResourceContents).empty()

◆ EXPECT_FALSE() [2/4]

EXPECT_FALSE ( byte_resource->  isFile())

◆ EXPECT_FALSE() [3/4]

EXPECT_FALSE ( resource->  getResourceContents).empty()

◆ EXPECT_FALSE() [4/4]

EXPECT_FALSE ( sub_resource->  getResourceContents).empty()

◆ EXPECT_TRUE() [1/14]

EXPECT_TRUE ( byte_resource = nullptr)

◆ EXPECT_TRUE() [2/14]

EXPECT_TRUE ( byte_resource->  getFilePath).empty()

◆ EXPECT_TRUE() [3/14]

EXPECT_TRUE ( byte_resource->getResourceContentStream() !  = nullptr)

◆ EXPECT_TRUE() [4/14]

EXPECT_TRUE ( resource = nullptr)

◆ EXPECT_TRUE() [5/14]

EXPECT_TRUE ( resource->getResourceContentStream() !  = nullptr)

◆ EXPECT_TRUE() [6/14]

EXPECT_TRUE ( resource->  isFile())

◆ EXPECT_TRUE() [7/14]

EXPECT_TRUE ( resource_does_not_exist = nullptr)

◆ EXPECT_TRUE() [8/14]

EXPECT_TRUE ( resource_does_not_exist->  getResourceContents).empty()

◆ EXPECT_TRUE() [9/14]

EXPECT_TRUE ( resource_does_not_exist->  getResourceContentStream() = =nullptr)

◆ EXPECT_TRUE() [10/14]

EXPECT_TRUE ( resource_empty  = =nullptr)

◆ EXPECT_TRUE() [11/14]

EXPECT_TRUE ( sub_resource = nullptr)

◆ EXPECT_TRUE() [12/14]

EXPECT_TRUE ( sub_resource->getResourceContentStream() !  = nullptr)

◆ EXPECT_TRUE() [13/14]

EXPECT_TRUE ( sub_resource->  isFile())

◆ EXPECT_TRUE() [14/14]

EXPECT_TRUE ( sub_resource_empty  = =nullptr)

◆ file_path()

tesseract_common::fs::path file_path ( __FILE__  )
Initial value:
{
using namespace tesseract_common
Definition: allowed_collision_matrix.h:16

◆ main()

int main ( int  argc,
char **  argv 
)

◆ putenv()

putenv ( env_var.  data())

◆ resource() [1/2]

SimpleLocatedResource resource ( "url"  ,
"file_path"   
)

◆ resource() [2/2]

BytesResource resource ( "url"  ,
{ 1, 2, 3, 4, 5 }   
)

Variable Documentation

◆ byte_resource

auto byte_resource
Initial value:
= std::make_shared<BytesResource>(
"package://tesseract_common/package.xml", std::vector<uint8_t>({ 1, 2, 3, 4 }), resource)
Resource::Ptr resource
Definition: resource_locator_unit.cpp:59

◆ env_var

std::string env_var = "TESSERACT_RESOURCE_PATH=" + package_path.string()

◆ locator

ResourceLocator::Ptr locator = std::make_shared<TestResourceLocator>()

◆ package_path

tesseract_common::fs::path package_path = file_path.parent_path().parent_path()

◆ resource

Resource::Ptr resource = locator->locateResource("package://tesseract_common/package.xml")

◆ resource_does_not_exist

tesseract_common::Resource::Ptr resource_does_not_exist
Initial value:
= locator->locateResource("package://tesseract_common/"
"does_not_exist.txt")
ResourceLocator::Ptr locator
Definition: resource_locator_unit.cpp:57

◆ resource_empty

tesseract_common::Resource::Ptr resource_empty = locator->locateResource("")

◆ sub_resource

Resource::Ptr sub_resource = resource->locateResource("colcon.pkg")

◆ sub_resource_empty

tesseract_common::Resource::Ptr sub_resource_empty = sub_resource->locateResource("")