File: test_StringManip.cpp

package info (click to toggle)
rkcommon 1.14.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,276 kB
  • sloc: cpp: 33,504; sh: 31; makefile: 13
file content (49 lines) | stat: -rw-r--r-- 1,181 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// Copyright 2009 Intel Corporation
// SPDX-License-Identifier: Apache-2.0

#include "../catch.hpp"

#include "rkcommon/utility/StringManip.h"

TEST_CASE("longestBeginningMatch() correctness", "[StringManip]")
{
  std::string input1 = "0123456";
  std::string input2 = "01234";

  auto output = rkcommon::utility::longestBeginningMatch(input1, input2);
  REQUIRE(output == "01234");
}

TEST_CASE("beginsWith() correctness", "[StringManip]")
{
  std::string input = "0123456";

  REQUIRE(rkcommon::utility::beginsWith(input, "012"));
  REQUIRE(!rkcommon::utility::beginsWith(input, "12"));
}

TEST_CASE("split() correctness", "[StringManip]")
{
  std::string input = "str0,str1,str2";

  auto output = rkcommon::utility::split(input, ',');
  REQUIRE(output[0] == "str0");
  REQUIRE(output[1] == "str1");
  REQUIRE(output[2] == "str2");
}

TEST_CASE("lowerCase() correctness", "[StringManip]")
{
  std::string input = "ABCd";

  auto output = rkcommon::utility::lowerCase(input);
  REQUIRE(output == "abcd");
}

TEST_CASE("upperCase() correctness", "[StringManip]")
{
  std::string input = "abcD";

  auto output = rkcommon::utility::upperCase(input);
  REQUIRE(output == "ABCD");
}