Tesseract
Motion Planning Environment
|
#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>
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 |
EXPECT_EQ | ( | byte_resource-> | getUrl(), |
"package://tesseract_common/package.xml" | |||
) |
EXPECT_EQ | ( | resource-> | getUrl(), |
"package://tesseract_common/package.xml" | |||
) |
EXPECT_EQ | ( | sub_resource-> | getUrl(), |
"package://tesseract_common/colcon.pkg" | |||
) |
EXPECT_EQ | ( | tesseract_common::fs::path(resource->getFilePath()) | , |
(package_path/"package.xml") | |||
) |
EXPECT_EQ | ( | tesseract_common::fs::path(sub_resource->getFilePath()) | , |
(package_path/"colcon.pkg") | |||
) |
EXPECT_FALSE | ( | byte_resource-> | getResourceContents).empty( | ) |
EXPECT_FALSE | ( | byte_resource-> | isFile() | ) |
EXPECT_FALSE | ( | resource-> | getResourceContents).empty( | ) |
EXPECT_FALSE | ( | sub_resource-> | getResourceContents).empty( | ) |
EXPECT_TRUE | ( | byte_resource ! | = nullptr | ) |
EXPECT_TRUE | ( | byte_resource-> | getFilePath).empty( | ) |
EXPECT_TRUE | ( | byte_resource->getResourceContentStream() ! | = nullptr | ) |
EXPECT_TRUE | ( | resource ! | = nullptr | ) |
EXPECT_TRUE | ( | resource->getResourceContentStream() ! | = nullptr | ) |
EXPECT_TRUE | ( | resource-> | isFile() | ) |
EXPECT_TRUE | ( | resource_does_not_exist ! | = nullptr | ) |
EXPECT_TRUE | ( | resource_does_not_exist-> | getResourceContents).empty( | ) |
EXPECT_TRUE | ( | resource_does_not_exist-> | getResourceContentStream() = =nullptr | ) |
EXPECT_TRUE | ( | resource_empty | = =nullptr | ) |
EXPECT_TRUE | ( | sub_resource ! | = nullptr | ) |
EXPECT_TRUE | ( | sub_resource->getResourceContentStream() ! | = nullptr | ) |
EXPECT_TRUE | ( | sub_resource-> | isFile() | ) |
EXPECT_TRUE | ( | sub_resource_empty | = =nullptr | ) |
tesseract_common::fs::path file_path | ( | __FILE__ | ) |
int main | ( | int | argc, |
char ** | argv | ||
) |
putenv | ( | env_var. | data() | ) |
SimpleLocatedResource resource | ( | "url" | , |
"file_path" | |||
) |
BytesResource resource | ( | "url" | , |
{ 1, 2, 3, 4, 5 } | |||
) |
auto byte_resource |
std::string env_var = "TESSERACT_RESOURCE_PATH=" + package_path.string() |
ResourceLocator::Ptr locator = std::make_shared<TestResourceLocator>() |
tesseract_common::fs::path package_path = file_path.parent_path().parent_path() |
Resource::Ptr resource = locator->locateResource("package://tesseract_common/package.xml") |
tesseract_common::Resource::Ptr resource_does_not_exist |
tesseract_common::Resource::Ptr resource_empty = locator->locateResource("") |
Resource::Ptr sub_resource = resource->locateResource("colcon.pkg") |
tesseract_common::Resource::Ptr sub_resource_empty = sub_resource->locateResource("") |