test-split.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 //#cmake:add-file ../../../common/utilities/string/split.h
5 
6 #include "common.h"
7 #include "../../../common/utilities/string/split.h"
8 
9 using namespace utilities::string;
10 
11 TEST_CASE("split_string_by_newline", "[string]")
12 {
13  // split size check
14  CHECK(split("" , '\n').size() == 0);
15  CHECK(split("abc", '\n').size() == 1);
16  CHECK(split("abc\nabc", '\n').size() == 2);
17  CHECK(split("a\nbc\nabc", '\n').size() == 3);
18  CHECK(split("a\nbc\nabc\n", '\n').size() == 3);
19  CHECK(split("1-12-123-1234", '-').size() == 4);
20 
21  CHECK(split("a\nbc\nabc", '\n')[0] == "a");
22  CHECK(split("a\nbc\nabc", '\n')[1] == "bc");
23  CHECK(split("a\nbc\nabc", '\n')[2] == "abc");
24  CHECK(split("a\nbc\nabc\n", '\n')[2] == "abc");
25 
26 
27  CHECK(split("1-12-123-1234", '-')[0] == "1");
28  CHECK(split("1-12-123-1234", '-')[1] == "12");
29  CHECK(split("1-12-123-1234", '-')[2] == "123");
30  CHECK(split("1-12-123-1234", '-')[3] == "1234");
31 }
GLsizeiptr size
TEST_CASE("split_string_by_newline","[string]")
Definition: test-split.cpp:11
std::vector< std::string > split(const std::string &str, char delimiter)
Definition: split.h:26
#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