gtsam
inference
tests
testSymbol.cpp
Go to the documentation of this file.
1
/* ----------------------------------------------------------------------------
2
3
* GTSAM Copyright 2010, Georgia Tech Research Corporation,
4
* Atlanta, Georgia 30332-0415
5
* All Rights Reserved
6
* Authors: Frank Dellaert, et al. (see THANKS for the full author list)
7
8
* See LICENSE for the license information
9
10
* -------------------------------------------------------------------------- */
11
12
/*
13
* @file testSymbol.cpp
14
* @author Frank Dellaert
15
*/
16
17
#include <
gtsam/inference/Symbol.h
>
18
19
#include <
CppUnitLite/TestHarness.h
>
20
21
#include <sstream>
22
23
using namespace
std
;
24
using namespace
gtsam
;
25
26
/* ************************************************************************* */
27
// A custom (nonsensical) formatter.
28
string
symbolMyFormatter
(
Key
key
) {
29
return
"special"
;
30
}
31
32
TEST
(
Symbol
, Formatting) {
33
Symbol
symbol
(
'c'
, 3);
34
35
// use key_formatter with a function pointer
36
stringstream ss2;
37
ss2 <<
key_formatter
(
symbolMyFormatter
) <<
symbol
;
38
EXPECT
(
"special"
== ss2.str());
39
40
// use key_formatter with a function object.
41
stringstream ss3;
42
ss3 <<
key_formatter
(
MultiRobotKeyFormatter
) <<
symbol
;
43
EXPECT
(
"c3"
== ss3.str());
44
}
45
46
/* ************************************************************************* */
47
int
main
() {
48
TestResult
tr;
49
return
TestRegistry::runAllTests
(tr);
50
}
51
/* ************************************************************************* */
52
TestRegistry::runAllTests
static int runAllTests(TestResult &result)
Definition:
TestRegistry.cpp:27
EXPECT
#define EXPECT(condition)
Definition:
Test.h:150
TestHarness.h
main
int main()
Definition:
testSymbol.cpp:47
gtsam::MultiRobotKeyFormatter
static const gtsam::KeyFormatter MultiRobotKeyFormatter
Definition:
Key.h:60
TEST
TEST(Symbol, Formatting)
Definition:
testSymbol.cpp:32
gtsam::symbol
Key symbol(unsigned char c, std::uint64_t j)
Definition:
inference/Symbol.h:139
Symbol.h
TestResult
Definition:
TestResult.h:26
key
const gtsam::Symbol key('X', 0)
gtsam
traits
Definition:
SFMdata.h:40
std
Definition:
BFloat16.h:88
gtsam::key_formatter
Definition:
Key.h:78
symbolMyFormatter
string symbolMyFormatter(Key key)
Definition:
testSymbol.cpp:28
gtsam::Key
std::uint64_t Key
Integer nonlinear key type.
Definition:
types.h:97
gtsam::Symbol
Definition:
inference/Symbol.h:37
gtsam
Author(s):
autogenerated on Sat Nov 16 2024 04:08:45