test-trim-newlines.cpp
Go to the documentation of this file.
1 // License: Apache 2.0. See LICENSE file in root directory.
2 // Copyright(c) 2020 Intel Corporation. All Rights Reserved.
3 
4 #include "common.h"
5 #include "../common/utilities/string/trim-newlines.h"
6 
7 using namespace utilities::string;
8 
9 TEST_CASE( "trim-newlines", "[string]" )
10 {
11  // No changes because nothing behind
12  CHECK( trim_newlines( "" ) == "" );
13  CHECK( trim_newlines( "\n" ) == "\n" );
14 
15  // Put something behind...
16  CHECK( trim_newlines( "a" ) == "a" );
17  CHECK( trim_newlines( "\na" ) == "\na" );
18  CHECK( trim_newlines( " \n " ) == "\n " );
19  CHECK( trim_newlines( "a\n" ) == "a\n" ); // nothing in front
20  CHECK( trim_newlines( "a\nb" ) == "a b" );
21  CHECK( trim_newlines( "a \nb" ) == "a b" ); // remove spaces at EOL
22 
23  // Multiple NLs should not get removed
24  CHECK( trim_newlines( "a\n\nb" ) == "a\n\nb" );
25  CHECK( trim_newlines( "a\n\n \nb" ) == "a\n\n\nb" );
26 
27  // Colons followed by NL should stay
28  CHECK( trim_newlines( "line 1.\nline 2" ) == "line 1. line 2" );
29  CHECK( trim_newlines( "line 1:\nline 2" ) == "line 1:\nline 2" );
30  CHECK( trim_newlines( "line 1: \nline 2" ) == "line 1:\nline 2" );
31 }
TEST_CASE("trim-newlines","[string]")
std::string trim_newlines(std::string text)
Definition: trim-newlines.h:29
#define CHECK(condition)


librealsense2
Author(s): Sergey Dorodnicov , Doron Hirshberg , Mark Horn , Reagan Lopez , Itay Carpis
autogenerated on Mon May 3 2021 02:50:11