Audacity 3.2.0
Functions
StringUtilsTests.cpp File Reference
#include "StringUtils.h"
#include <catch2/catch.hpp>
Include dependency graph for StringUtilsTests.cpp:

Go to the source code of this file.

Functions

 TEST_CASE ("Join", "[StringUtils]")
 
 TEST_CASE ("IsPrefixed", "[StringUtils]")
 

Function Documentation

◆ TEST_CASE() [1/2]

TEST_CASE ( "IsPrefixed"  ,
""  [StringUtils] 
)

Definition at line 31 of file StringUtilsTests.cpp.

32{
33 SECTION("Empty prefix")
34 {
35 REQUIRE(IsPrefixed("test", ""));
36 }
37
38 SECTION("Empty string")
39 {
40 REQUIRE_FALSE(IsPrefixed("", "test"));
41 }
42
43 SECTION("Prefix longer than string")
44 {
45 REQUIRE_FALSE(IsPrefixed("test", "test1"));
46 }
47
48 SECTION("Prefix is not a prefix")
49 {
50 REQUIRE_FALSE(IsPrefixed("test", "abc"));
51 }
52
53 SECTION("Prefix is a prefix")
54 {
55 REQUIRE(IsPrefixed("test", "tes"));
56 }
57
58 SECTION("Prefix matches string")
59 {
60 REQUIRE(IsPrefixed("test", "test"));
61 }
62
63 SECTION("Case insensitive")
64 {
65 REQUIRE(IsPrefixedInsensitive("test", "TEST"));
66 }
67}
bool IsPrefixedInsensitive(const HayType &hay, const PrefixType &prefix)
Definition: StringUtils.h:146
bool IsPrefixed(const HayType &hay, const PrefixType &prefix)
Definition: StringUtils.h:129

References IsPrefixed(), and IsPrefixedInsensitive().

Here is the call graph for this function:

◆ TEST_CASE() [2/2]

TEST_CASE ( "Join"  ,
""  [StringUtils] 
)

Definition at line 10 of file StringUtilsTests.cpp.

11{
12 SECTION("Join empty container")
13 {
14 std::vector<std::string> container;
15 REQUIRE(Join(container, ",") == "");
16 }
17
18 SECTION("Join single item")
19 {
20 std::vector<std::string> container { "item" };
21 REQUIRE(Join(container, ",") == "item");
22 }
23
24 SECTION("Join multiple items")
25 {
26 std::vector<std::string> container { "item1", "item2", "item3" };
27 REQUIRE(Join(container, ",") == "item1,item2,item3");
28 }
29}
ResultType Join(const ContainerType< ResultType, Rest... > &container, const SeparatorType &separator)
Definition: StringUtils.h:52

References Join().

Here is the call graph for this function: