MRPT
2.0.4
format_unittest.cpp
Go to the documentation of this file.
1
/* +------------------------------------------------------------------------+
2
| Mobile Robot Programming Toolkit (MRPT) |
3
| https://www.mrpt.org/ |
4
| |
5
| Copyright (c) 2005-2020, Individual contributors, see AUTHORS file |
6
| See: https://www.mrpt.org/Authors - All rights reserved. |
7
| Released under BSD License. See: https://www.mrpt.org/License |
8
+------------------------------------------------------------------------+ */
9
10
#include <gtest/gtest.h>
11
#include <
mrpt/core/format.h
>
12
13
// Load data from constant file and check for exact match.
14
TEST
(FormatTest, LargeStrings)
15
{
16
std::string test_str;
17
const
size_t
test_str_len = 30000;
18
test_str.assign(test_str_len,
'A'
);
19
20
std::string s =
21
mrpt::format
(
"%u %s"
,
static_cast<
unsigned
int
>
(10), test_str.c_str());
22
23
const
size_t
out_str_len = s.size();
24
25
// If it works, out len must be that of the string, plus 3 from "10 "
26
EXPECT_EQ
(out_str_len, (test_str_len + 3));
27
}
28
29
TEST
(FormatTest, ToString)
30
{
31
EXPECT_EQ
(
mrpt::to_string
(
false
),
"false"
);
32
EXPECT_EQ
(
mrpt::to_string
(
true
),
"true"
);
33
}
TEST
TEST(FormatTest, LargeStrings)
Definition:
format_unittest.cpp:14
format.h
mrpt::to_string
std::string to_string(T v)
Just like std::to_string(), but with an overloaded version for std::string arguments.
Definition:
format.h:36
EXPECT_EQ
EXPECT_EQ(out.image_pair_was_used.size(), NUM_IMGS)
mrpt::format
std::string std::string format(std::string_view fmt, ARGS &&... args)
Definition:
format.h:26
Page generated by
Doxygen 1.8.17
for MRPT 2.0.4 at Sun Jul 19 15:15:43 UTC 2020