Unit test icarus::details::KeyValueParser
More...
#include "icaruscode/PMT/Algorithms/KeyValueParser.h"
#include "icaruscode/Decode/DecoderTools/details/KeyValuesData.h"
#include <boost/test/unit_test.hpp>
#include <iostream>
#include <sstream>
#include <vector>
#include <array>
#include <string>
#include <cstdint>
Go to the source code of this file.
Unit test icarus::details::KeyValueParser
- Date
- May 18, 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/KeyValueParser.h
Definition in file KeyValueParser_test.cc.
#define BOOST_TEST_MODULE ( KeyValueParser_test ) |
BOOST_AUTO_TEST_CASE |
( |
parse_testcase |
| ) |
|
Definition at line 30 of file KeyValueParser_test.cc.
32 std::string
const info { R
"(
# SPR test input file
Description: "
This is a test for the key-values parser with default settings.
It is expected to be used to describe the Single Photoelectron Response.
"
Contact: Gianluca Petrillo (petrillo@slac.stanford.edu)
Gain: 9.7e6 # from amplitude 4 mV
Tick: '2 ns'
Samples: 0.0 1.0 2.5 \
4.5 3.0 2.5
Samples:+1.8 1.6 1.2 0.8 0.8 0.7 0.7 0.6
)" };
36 std::istringstream
in {
info };
39 std::cout <<
"Input:\n" << std::string(80,
'-') <<
"\n"
41 <<
"\n" << std::string(80,
'-')
42 <<
"\nParsed:\n" << data
45 BOOST_TEST(data.hasItem(
"Description"));
46 if (data.hasItem(
"Description")) {
48 BOOST_TEST(item.
nValues() == 1);
49 BOOST_TEST(item.value() ==
"\n"
50 "This is a test for the key-values parser with default settings.\n"
51 "It is expected to be used to describe the Single Photoelectron Response.\n"
55 BOOST_TEST(data.hasItem(
"Contact"));
56 if (data.hasItem(
"Contact")) {
58 BOOST_TEST(item.
nValues() == 3);
59 BOOST_TEST(item.value(0) ==
"Gianluca");
60 BOOST_TEST(item.value(1) ==
"Petrillo");
61 BOOST_TEST(item.value(2) ==
"(petrillo@slac.stanford.edu)");
64 BOOST_TEST(data.hasItem(
"Gain"));
65 if (data.hasItem(
"Gain")) {
67 BOOST_TEST(item.
nValues() == 1);
72 BOOST_TEST(data.hasItem(
"Tick"));
73 if (data.hasItem(
"Tick")) {
75 BOOST_TEST(item.
nValues() == 1);
76 BOOST_TEST(item.value() ==
"2 ns");
79 BOOST_TEST(data.hasItem(
"Samples"));
80 if (data.hasItem(
"Samples")) {
83 { 0.0, 1.0, 2.5, 4.5, 3.0, 2.5, 1.8, 1.6, 1.2, 0.8, 0.8, 0.7, 0.7, 0.6 };
85 BOOST_CHECK_EQUAL_COLLECTIONS
86 (values.begin(), values.end(), samples.cbegin(), samples.cend());
92 T getNumber(std::size_t index, unsigned int base) const
Returns the requested value, converted into a number of type T
Representation of a single item of data: a key and several values.
then echo ***************************************echo array
Collection of items with key/values structure.
std::size_t nValues() const noexcept
Returns the number of values currently present.
std::vector< T > getVector(Conv converter={}) const
Returns all the values, each converted into type T
Parser to fill a KeyValuesData structure out of a character buffer.
if &&[-z"$BASH_VERSION"] then echo Attempting to switch to bash bash shellSwitch exit fi &&["$1"= 'shellSwitch'] shift declare a IncludeDirectives for Dir in
BEGIN_PROLOG could also be cout