All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Macros | Functions
ParsingToolkit_test.cc File Reference

Unit test for utilities in ParsingToolkit.h More...

#include "icaruscode/PMT/Algorithms/ParsingToolkit.h"
#include <boost/test/unit_test.hpp>
#include <tuple>
#include <vector>
#include <string_view>
#include <string>
#include <sstream>
#include <cassert>

Go to the source code of this file.

Macros

#define BOOST_TEST_MODULE   ( ParsingToolkit_test )
 

Functions

void isCharacterEscaped_test ()
 
void removeTrailingBlanks_test ()
 
void findNextBlank_test ()
 
void readMultiline_test ()
 

Detailed Description

Unit test for utilities in ParsingToolkit.h

Date
May 13, 2022
Author
Gianluca Petrillo (petri.nosp@m.llo@.nosp@m.slac..nosp@m.stan.nosp@m.ford..nosp@m.edu)
See Also
icaruscode/PMT/Algorithms/ParsingToolkit.h

Definition in file ParsingToolkit_test.cc.

Macro Definition Documentation

#define BOOST_TEST_MODULE   ( ParsingToolkit_test )

Definition at line 14 of file ParsingToolkit_test.cc.

Function Documentation

void findNextBlank_test ( )

Definition at line 92 of file ParsingToolkit_test.cc.

92  {
93 
94  using namespace std::string_literals;
95  using namespace std::string_view_literals;
96  icarus::ParsingToolkit tk; // default configuration
97 
98  std::string_view s;
99  BOOST_TEST(std::distance(s.cbegin(), tk.findNextBlank(s)) == 0);
100 
101  s = "a b c "sv;
102  BOOST_TEST(std::distance(s.cbegin(), tk.findNextBlank(s)) == 1);
103 
104  s = "ab\\ cd e "sv;
105  BOOST_TEST(std::distance(s.cbegin(), tk.findNextBlank(s)) == 6);
106 
107  s = "a "sv;
108  BOOST_TEST(std::distance(s.cbegin(), tk.findNextBlank(s)) == 1);
109 
110 } // findNextBlank_test()
double distance(geo::Point_t const &point, CathodeDesc_t const &cathode)
Returns the distance of a point from the cathode.
Utilities for text parsing.
then echo File list $list not found else cat $list while read file do echo $file sed s
Definition: file_to_url.sh:60
void isCharacterEscaped_test ( )

Definition at line 29 of file ParsingToolkit_test.cc.

29  {
30 
31  icarus::ParsingToolkit const tk; // default configuration
32 
33  std::string const s { R"(\a\\a\\\a\\\\a\\\\\a\\\\\\a\\\)" };
34  auto const b = s.begin();
35  auto it = b;
36 
37  BOOST_TEST(!tk.isCharacterEscaped(b, it++)); // \ !
38  BOOST_TEST( tk.isCharacterEscaped(b, it++)); // \a !
39  BOOST_TEST(!tk.isCharacterEscaped(b, it++)); // \a\ !
40  BOOST_TEST( tk.isCharacterEscaped(b, it++)); // \a\\ !
41  BOOST_TEST(!tk.isCharacterEscaped(b, it++)); // \a\\a !
42  BOOST_TEST(!tk.isCharacterEscaped(b, it++)); // \a\\a\ !
43  BOOST_TEST( tk.isCharacterEscaped(b, it++)); // \a\\a\\ !
44  BOOST_TEST(!tk.isCharacterEscaped(b, it++)); // \a\\a\\\ !
45  BOOST_TEST( tk.isCharacterEscaped(b, it++)); // \a\\a\\\a !
46  BOOST_TEST(!tk.isCharacterEscaped(b, it++)); // \a\\a\\\a\ !
47  BOOST_TEST( tk.isCharacterEscaped(b, it++)); // \a\\a\\\a\\ !
48  BOOST_TEST(!tk.isCharacterEscaped(b, it++)); // \a\\a\\\a\\\ !
49  BOOST_TEST( tk.isCharacterEscaped(b, it++)); // \a\\a\\\a\\\\ !
50  BOOST_TEST(!tk.isCharacterEscaped(b, it++)); // \a\\a\\\a\\\\a !
51  BOOST_TEST(!tk.isCharacterEscaped(b, it++)); // \a\\a\\\a\\\\a\ !
52  BOOST_TEST( tk.isCharacterEscaped(b, it++)); // \a\\a\\\a\\\\a\\ !
53  BOOST_TEST(!tk.isCharacterEscaped(b, it++)); // \a\\a\\\a\\\\a\\\ !
54  BOOST_TEST( tk.isCharacterEscaped(b, it++)); // \a\\a\\\a\\\\a\\\\ !
55  BOOST_TEST(!tk.isCharacterEscaped(b, it++)); // \a\\a\\\a\\\\a\\\\\ !
56  BOOST_TEST( tk.isCharacterEscaped(b, it++)); // \a\\a\\\a\\\\a\\\\\a !
57  BOOST_TEST(!tk.isCharacterEscaped(b, it++)); // \a\\a\\\a\\\\a\\\\\a\ !
58  BOOST_TEST( tk.isCharacterEscaped(b, it++)); // \a\\a\\\a\\\\a\\\\\a\\ !
59  BOOST_TEST(!tk.isCharacterEscaped(b, it++)); // \a\\a\\\a\\\\a\\\\\a\\\ !
60  BOOST_TEST( tk.isCharacterEscaped(b, it++)); // \a\\a\\\a\\\\a\\\\\a\\\\ !
61  BOOST_TEST(!tk.isCharacterEscaped(b, it++)); // \a\\a\\\a\\\\a\\\\\a\\\\\ !
62  BOOST_TEST( tk.isCharacterEscaped(b, it++)); // \a\\a\\\a\\\\a\\\\\a\\\\\\ !
63  BOOST_TEST(!tk.isCharacterEscaped(b, it++)); // \a\\a\\\a\\\\a\\\\\a\\\\\\a !
64  BOOST_TEST(!tk.isCharacterEscaped(b, it++)); // \a\\a\\\a\\\\a\\\\\a\\\\\\a\ !
65  BOOST_TEST( tk.isCharacterEscaped(b, it++)); // \a\\a\\\a\\\\a\\\\\a\\\\\\a\\ !
66  BOOST_TEST(!tk.isCharacterEscaped(b, it++)); // \a\\a\\\a\\\\a\\\\\a\\\\\\a\\\ !
67  assert(it == s.end());
68  BOOST_TEST( tk.isCharacterEscaped(b, it));
69 
70 } // isCharacterEscaped_test()
bool isCharacterEscaped(BIter begin, BIter itCh) const
Returns whether the character pointed by itCh is escaped or not.
Utilities for text parsing.
then echo File list $list not found else cat $list while read file do echo $file sed s
Definition: file_to_url.sh:60
void readMultiline_test ( )

Definition at line 114 of file ParsingToolkit_test.cc.

void removeTrailingBlanks_test ( )

Definition at line 74 of file ParsingToolkit_test.cc.

74  {
75 
76  using namespace std::string_literals;
77  using namespace std::string_view_literals;
78  icarus::ParsingToolkit tk; // default configuration
79 
80  BOOST_TEST(tk.removeTrailingBlanks(""s) == ""sv);
81 
82  BOOST_TEST(tk.removeTrailingBlanks("a b c "s) == "a b c "sv);
83 
84  BOOST_TEST(tk.removeTrailingBlanks(" \\ a b c "s) == "\\ a b c "sv);
85 
86  BOOST_TEST(tk.removeTrailingBlanks(" \t a b c "s) == "a b c "sv);
87 
88 } // removeTrailingBlanks_test()
Utilities for text parsing.
then echo File list $list not found else cat $list while read file do echo $file sed s
Definition: file_to_url.sh:60