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 }
GLdouble s
Definition: glext.h:3676
TEST(FormatTest, LargeStrings)
GLsizei const GLchar ** string
Definition: glext.h:4101
std::string format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.
Definition: format.cpp:16
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:30



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: 7d5e6d718 Fri Aug 24 01:51:28 2018 +0200 at lun nov 2 08:35:50 CET 2020