Loading...
Searching...
No Matches
util.h File Reference

Test utilities. More...

`#include <openvdb_ax/ast/AST.h>`
`#include <openvdb_ax/ast/PrintTree.h>`
`#include <openvdb_ax/ast/Parse.h>`
`#include <openvdb_ax/ast/Tokens.h>`
`#include <openvdb_ax/compiler/Logger.h>`
`#include <openvdb/Types.h>`
`#include <memory>`
`#include <vector>`
`#include <utility>`
`#include <string>`
`#include <type_traits>`
`#include <map>`

Go to the source code of this file.

## Namespaces

namespace | unittest_util

## Macros

#define | ERROR_MSG(Msg, Code)
#define | TEST_SYNTAX_PASSES(Tests)
#define | TEST_SYNTAX_FAILS(Tests)

## Typedefs

using | CodeTests = std::vector<std::pair<std::string, openvdb::ax::ast::Node::Ptr>>
using | ConfigMap = std::map<std::string, std::map<std::string, std::string>>

## Functions

void | replace (std::string &str, const std::string &oldStr, const std::string &newStr)
bool | compareLinearTrees (const std::vector< const openvdb::ax::ast::Node * > &a, const std::vector< const openvdb::ax::ast::Node * > &b, const bool allowEmpty=false)
std::vector< std::string > | nameSequence (const std::string &base, const size_t number)

## Detailed Description

Test utilities.

Author
  Nick Avramoussis

## Macro Definition Documentation

## ERROR_MSG

#define ERROR_MSG | ( |  | Msg,
|  |  | Code )

Value:
Msg + std::string(": \"") + Code + std::string("\"")

## TEST_SYNTAX_FAILS

#define TEST_SYNTAX_FAILS | ( |  | Tests | ) |

Value:
{ \
openvdb::ax::Logger logger([](const std::string&) {});\
for (const auto& test : Tests) { \
logger.clear();\
const std::string& code = test.first; \
openvdb::ax::ast::Tree::ConstPtr tree = openvdb::ax::ast::parse(code.c_str(), logger);\
CPPUNIT_ASSERT_MESSAGE(ERROR_MSG("Expected parsing error", code), !tree && logger.hasError()); \
} \
} \
ERROR_MSG
#define ERROR_MSG(Msg, Code)
Definition util.h:28

## TEST_SYNTAX_PASSES

#define TEST_SYNTAX_PASSES | ( |  | Tests | ) |

Value:
{ \
openvdb::ax::Logger logger;\
for (const auto& test : Tests) { \
logger.clear();\
const std::string& code = test.first; \
openvdb::ax::ast::Tree::ConstPtr tree = openvdb::ax::ast::parse(code.c_str(), logger);\
std::stringstream str; \
CPPUNIT_ASSERT_MESSAGE(ERROR_MSG("Unexpected parsing error(s)\n", str.str()), tree && !logger.hasError()); \
} \
} \