MRPT  2.0.3
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 }
std::string to_string(T v)
Just like std::to_string(), but with an overloaded version for std::string arguments.
Definition: format.h:36
std::string std::string format(std::string_view fmt, ARGS &&... args)
Definition: format.h:26
TEST(FormatTest, LargeStrings)
EXPECT_EQ(out.image_pair_was_used.size(), NUM_IMGS)



Page generated by Doxygen 1.8.14 for MRPT 2.0.3 Git: 8e9e8af54 Wed May 13 17:41:24 2020 +0200 at miƩ may 13 17:55:54 CEST 2020