Merge pull request #572 from borglab/feature/symbol-alternative-names
Add alternativeName() for symbolsrelease/4.3a0
commit
0857dd1474
|
|
@ -164,8 +164,16 @@ inline Key Y(std::uint64_t j) { return Symbol('y', j); }
|
|||
inline Key Z(std::uint64_t j) { return Symbol('z', j); }
|
||||
}
|
||||
|
||||
/** Generates symbol shorthands with alternative names different than the
|
||||
* one-letter predefined ones. */
|
||||
class SymbolGenerator {
|
||||
const char c_;
|
||||
public:
|
||||
SymbolGenerator(const char c) : c_(c) {}
|
||||
Symbol operator()(const std::uint64_t j) const { return Symbol(c_, j); }
|
||||
};
|
||||
|
||||
/// traits
|
||||
template<> struct traits<Symbol> : public Testable<Symbol> {};
|
||||
|
||||
} // \ namespace gtsam
|
||||
|
||||
|
|
|
|||
|
|
@ -40,6 +40,25 @@ TEST(Key, KeySymbolConversion) {
|
|||
EXPECT(assert_equal(original, actual))
|
||||
}
|
||||
|
||||
/* ************************************************************************* */
|
||||
TEST(Key, SymbolGenerator) {
|
||||
const auto x1 = gtsam::symbol_shorthand::X(1);
|
||||
const auto v1 = gtsam::symbol_shorthand::V(1);
|
||||
const auto a1 = gtsam::symbol_shorthand::A(1);
|
||||
|
||||
const auto Z = gtsam::SymbolGenerator('x');
|
||||
const auto DZ = gtsam::SymbolGenerator('v');
|
||||
const auto DDZ = gtsam::SymbolGenerator('a');
|
||||
|
||||
const auto z1 = Z(1);
|
||||
const auto dz1 = DZ(1);
|
||||
const auto ddz1 = DDZ(1);
|
||||
|
||||
EXPECT(assert_equal(x1, z1));
|
||||
EXPECT(assert_equal(v1, dz1));
|
||||
EXPECT(assert_equal(a1, ddz1));
|
||||
}
|
||||
|
||||
/* ************************************************************************* */
|
||||
template<int KeySize>
|
||||
Key KeyTestValue();
|
||||
|
|
@ -106,4 +125,3 @@ int main() {
|
|||
return TestRegistry::runAllTests(tr);
|
||||
}
|
||||
/* ************************************************************************* */
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue