Project
Loading...
Searching...
No Matches
testAliasExpander.cxx
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11
12#define BOOST_TEST_MODULE Test DCS AliasExpander
13#define BOOST_TEST_MAIN
14
15#define BOOST_TEST_DYN_LINK
16
17#include <boost/test/unit_test.hpp>
18#include <boost/test/data/test_case.hpp>
19#include <iostream>
21
22BOOST_AUTO_TEST_CASE(ExpandAliasesIsNoopWhenNoPatternGiven)
23{
24 std::vector<std::string> aliases = o2::dcs::expandAliases({"ab"});
25
26 std::vector<std::string> expected = {"ab"};
27
28 BOOST_TEST(aliases == expected, boost::test_tools::per_element());
29}
30
31BOOST_AUTO_TEST_CASE(ExpandAliasesReturnsEmptyVectorWhenPatternIsIncorrect)
32{
33 std::vector<std::string> aliases = o2::dcs::expandAliases({"ab[c"});
34
35 std::vector<std::string> expected = {};
36
37 BOOST_TEST(aliases == expected, boost::test_tools::per_element());
38
39 aliases = o2::dcs::expandAliases({"ab]c"});
40
41 BOOST_TEST(aliases == expected, boost::test_tools::per_element());
42
43 aliases = o2::dcs::expandAliases({"ab[1.2]c"});
44
45 BOOST_TEST(aliases == expected, boost::test_tools::per_element());
46}
47
48BOOST_AUTO_TEST_CASE(ExpandAliasesWithIntegerRange)
49{
50 std::vector<std::string> aliases = o2::dcs::expandAliases({"a[1..2]bcde[99..101]toto"});
51
52 std::vector<std::string> expected = {
53 "a1bcde099toto",
54 "a1bcde100toto",
55 "a1bcde101toto",
56 "a2bcde099toto",
57 "a2bcde100toto",
58 "a2bcde101toto"};
59
60 BOOST_TEST(aliases == expected, boost::test_tools::per_element());
61}
62
63BOOST_AUTO_TEST_CASE(ExpandAliasesWithIntegerRangeWithCustomFormat)
64{
65 std::vector<std::string> aliases = o2::dcs::expandAliases({"a[1..3{:03d}]"});
66
67 std::vector<std::string> expected = {
68 "a001",
69 "a002",
70 "a003"};
71
72 BOOST_TEST(aliases == expected, boost::test_tools::per_element());
73}
74
75BOOST_AUTO_TEST_CASE(ExpandAliasesWithIntegerRangeWithCustomFormatBis)
76{
77 std::vector<std::string> aliases = o2::dcs::expandAliases({"a[1..3{:d}]"});
78
79 std::vector<std::string> expected = {
80 "a1",
81 "a2",
82 "a3"};
83
84 BOOST_TEST(aliases == expected, boost::test_tools::per_element());
85}
86
87BOOST_AUTO_TEST_CASE(ExpandAliasesWithStringList)
88{
89 std::vector<std::string> aliases = o2::dcs::expandAliases({"a[1..2]bcde[99..101][toto,titi,tata]"});
90
91 std::vector<std::string> expected = {
92 "a1bcde099tata",
93 "a1bcde099titi",
94 "a1bcde099toto",
95 "a1bcde100tata",
96 "a1bcde100titi",
97 "a1bcde100toto",
98 "a1bcde101tata",
99 "a1bcde101titi",
100 "a1bcde101toto",
101 "a2bcde099tata",
102 "a2bcde099titi",
103 "a2bcde099toto",
104 "a2bcde100tata",
105 "a2bcde100titi",
106 "a2bcde100toto",
107 "a2bcde101tata",
108 "a2bcde101titi",
109 "a2bcde101toto",
110 };
111
112 BOOST_TEST(aliases == expected, boost::test_tools::per_element());
113}
114
116{
117 std::vector<std::string> aliases = o2::dcs::expandAliases(
118 {"MchHvLvLeft/Chamber[00..03]Left/Quad1Sect[0..2].actual.[vMon,iMon]",
119 "MchHvLvLeft/Chamber[00..03]Left/Quad2Sect[0..2].actual.[vMon,iMon]",
120 "MchHvLvLeft/Chamber[04..09]Left/Slat[00..08].actual.[vMon,iMon]",
121 "MchHvLvLeft/Chamber[06..09]Left/Slat[09..12].actual.[vMon,iMon]",
122 "MchHvLvRight/Chamber[00..03]Right/Quad0Sect[0..2].actual.[vMon,iMon]",
123 "MchHvLvRight/Chamber[00..03]Right/Quad3Sect[0..2].actual.[vMon,iMon]",
124 "MchHvLvRight/Chamber[04..09]Right/Slat[00..08].actual.[vMon,iMon]",
125 "MchHvLvRight/Chamber[06..09]Right/Slat[09..12].actual.[vMon,iMon]"});
126
127 BOOST_TEST(aliases.size(), 376);
128}
std::vector< std::string > expandAliases(const std::vector< std::string > &patternedAliases)
BOOST_AUTO_TEST_CASE(ExpandAliasesIsNoopWhenNoPatternGiven)
std::map< std::string, ID > expected
BOOST_TEST(digits==digitsD, boost::test_tools::per_element())