Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
utilities.cpp File Reference
#include <boost/test/unit_test.hpp>
#include <iostream>
#include <string>
#include <websocketpp/utilities.hpp>
Include dependency graph for utilities.cpp:

Go to the source code of this file.

Macros

#define BOOST_TEST_MODULE   utility
 

Functions

 BOOST_AUTO_TEST_CASE (substr_found)
 
 BOOST_AUTO_TEST_CASE (substr_found_ci)
 
 BOOST_AUTO_TEST_CASE (substr_not_found)
 
 BOOST_AUTO_TEST_CASE (to_lower)
 
 BOOST_AUTO_TEST_CASE (string_replace_all)
 

Macro Definition Documentation

◆ BOOST_TEST_MODULE

#define BOOST_TEST_MODULE   utility

Definition at line 28 of file utilities.cpp.

Function Documentation

◆ BOOST_AUTO_TEST_CASE() [1/5]

BOOST_AUTO_TEST_CASE ( string_replace_all )

Definition at line 65 of file utilities.cpp.

65 {
66 std::string source = "foo \"bar\" baz";
67 std::string dest = "foo \\\"bar\\\" baz";
68
70 BOOST_CHECK_EQUAL(string_replace_all(source,"\"","\\\""),dest);
71}
std::string string_replace_all(std::string subject, std::string const &search, std::string const &replace)
Replace all occurrances of a substring with another.
const CharType(& source)[N]
Definition pointer.h:1204
Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [2/5]

BOOST_AUTO_TEST_CASE ( substr_found )

Definition at line 38 of file utilities.cpp.

38 {
39 std::string haystack = "abc123";
40 std::string needle = "abc";
41
42 BOOST_CHECK(websocketpp::utility::ci_find_substr(haystack,needle) ==haystack.begin());
43}
T::const_iterator ci_find_substr(T const &haystack, T const &needle, std::locale const &loc=std::locale())
Find substring (case insensitive)
Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [3/5]

BOOST_AUTO_TEST_CASE ( substr_found_ci )

Definition at line 45 of file utilities.cpp.

45 {
46 std::string haystack = "abc123";
47 std::string needle = "aBc";
48
49 BOOST_CHECK(websocketpp::utility::ci_find_substr(haystack,needle) ==haystack.begin());
50}
Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [4/5]

BOOST_AUTO_TEST_CASE ( substr_not_found )

Definition at line 52 of file utilities.cpp.

52 {
53 std::string haystack = "abd123";
54 std::string needle = "abcd";
55
56 BOOST_CHECK(websocketpp::utility::ci_find_substr(haystack,needle) == haystack.end());
57}
Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [5/5]

BOOST_AUTO_TEST_CASE ( to_lower )

Definition at line 59 of file utilities.cpp.

59 {
60 std::string in = "AbCd";
61
62 BOOST_CHECK_EQUAL(websocketpp::utility::to_lower(in), "abcd");
63}
std::string to_lower(std::string const &in)
Convert a string to lowercase.
Here is the call graph for this function: