Macros | Functions
canonical_string_test.cc File Reference
#include "boost/test/unit_test.hpp"
#include "cetlib/canonical_string.h"

Go to the source code of this file.

Macros

#define BOOST_TEST_MODULE(canonical_string_t)
 

Functions

 BOOST_AUTO_TEST_CASE (is_single_quoted_string_t)
 
 BOOST_AUTO_TEST_CASE (is_double_quoted_string_t)
 
void becomes (std::string const &input, std::string const &wanted)
 
std::string dquoted (std::string const &s)
 
std::string squoted (std::string const &s)
 
 BOOST_AUTO_TEST_CASE (canonical_string_t)
 

Macro Definition Documentation

#define BOOST_TEST_MODULE (   canonical_string_t)

Definition at line 1 of file canonical_string_test.cc.

Function Documentation

void becomes ( std::string const &  input,
std::string const &  wanted 
)

Definition at line 30 of file canonical_string_test.cc.

31 {
33  BOOST_TEST(cet::canonical_string(input, result),
34  "canonical_result returns false on input: '" << input << "'");
35  BOOST_TEST(result == wanted);
36 }
static QCString result
std::string string
Definition: nybbler.cc:12
static int input(void)
Definition: code.cpp:15695
bool canonical_string(std::string const &str, std::string &result)
BOOST_AUTO_TEST_CASE ( is_single_quoted_string_t  )

Definition at line 10 of file canonical_string_test.cc.

11 {
12  BOOST_TEST(is_single_quoted_string("'3'")); // '3'
13  BOOST_TEST(!is_single_quoted_string("\"3\"")); // "3"
14  BOOST_TEST(!is_single_quoted_string("'3',")); // '3',
15  BOOST_TEST(!is_single_quoted_string(",'3'")); // ,'3'
16  BOOST_TEST(is_single_quoted_string("'\\\'")); // '\\\'
17 }
bool is_single_quoted_string(std::string const &str)
BOOST_AUTO_TEST_CASE ( is_double_quoted_string_t  )

Definition at line 19 of file canonical_string_test.cc.

20 {
21  BOOST_TEST(is_double_quoted_string("\"3\"")); // "3"
22  BOOST_TEST(!is_double_quoted_string("'3'")); // '3'
23  BOOST_TEST(!is_double_quoted_string("\"3\",")); // "3",
24  BOOST_TEST(!is_double_quoted_string(",\"3\"")); // ,"3"
25  // Controversial:
26  BOOST_TEST(is_double_quoted_string("\"\\\"")); // "\"
27 }
bool is_double_quoted_string(std::string const &str)
BOOST_AUTO_TEST_CASE ( canonical_string_t  )

Definition at line 50 of file canonical_string_test.cc.

51 {
52  becomes("a", dquoted("a"));
53  becomes(squoted("a"), dquoted("a"));
54  becomes(dquoted("a"), dquoted("a"));
55  {
57  BOOST_TEST(!canonical_string("", result),
58  "canonical_string() should return false on empty input.");
59  }
60  becomes(squoted("\n"), dquoted("\\n"));
61  becomes(dquoted("\n"), dquoted("\\n"));
62  becomes(squoted("\\"), dquoted("\\\\"));
63  becomes(dquoted("\\"), dquoted("\\\\"));
64  becomes(squoted("\\\\"), dquoted("\\\\\\\\"));
65  becomes(dquoted("\\\\"), dquoted("\\\\"));
66 
67  becomes(squoted("\t\'\""), dquoted("\\t\\\'\\\""));
68  becomes(dquoted("\t\'\""), dquoted("\\t\\\'\\\""));
69 }
void becomes(std::string const &input, std::string const &wanted)
static QCString result
std::string dquoted(std::string const &s)
std::string string
Definition: nybbler.cc:12
bool canonical_string(std::string const &str, std::string &result)
std::string squoted(std::string const &s)
std::string dquoted ( std::string const &  s)

Definition at line 39 of file canonical_string_test.cc.

40 {
41  return '"' + s + '"';
42 }
static QCString * s
Definition: config.cpp:1042
std::string squoted ( std::string const &  s)

Definition at line 45 of file canonical_string_test.cc.

46 {
47  return '\'' + s + '\'';
48 }
static QCString * s
Definition: config.cpp:1042