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