Main MRPT website
>
C++ reference for MRPT 1.9.9
format_unittest.cpp
Go to the documentation of this file.
1
/* +------------------------------------------------------------------------+
2
| Mobile Robot Programming Toolkit (MRPT) |
3
| http://www.mrpt.org/ |
4
| |
5
| Copyright (c) 2005-2018, Individual contributors, see AUTHORS file |
6
| See: http://www.mrpt.org/Authors - All rights reserved. |
7
| Released under BSD License. See details in http://www.mrpt.org/License |
8
+------------------------------------------------------------------------+ */
9
10
#include <
mrpt/core/format.h
>
11
#include <gtest/gtest.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
s
GLdouble s
Definition:
glext.h:3676
format.h
mrpt::to_string
std::string std::string to_string(T v)
Just like std::to_string(), but with an overloaded version for std::string arguments.
Definition:
format.h:27
mrpt::format
std::string format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.
Definition:
format.cpp:16
string
GLsizei const GLchar ** string
Definition:
glext.h:4101
Page generated by
Doxygen 1.8.17
for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at miƩ 12 jul 2023 10:03:34 CEST