Instrument Neutral Distributed Interface INDI
2.2.5
integs
XmlAwaiterTest.cpp
Go to the documentation of this file.
1
/*******************************************************************************
2
Copyright(c) 2022 Ludovic Pollet. All rights reserved.
3
4
This library is free software; you can redistribute it and/or
5
modify it under the terms of the GNU Library General Public
6
License version 2 as published by the Free Software Foundation.
7
8
This library is distributed in the hope that it will be useful,
9
but WITHOUT ANY WARRANTY; without even the implied warranty of
10
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11
Library General Public License for more details.
12
13
You should have received a copy of the GNU Library General Public License
14
along with this library; see the file COPYING.LIB. If not, write to
15
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
16
Boston, MA 02110-1301, USA.
17
*******************************************************************************/
18
19
#include <stdexcept>
20
21
#include "gtest/gtest.h"
22
23
#include "
XmlAwaiter.h
"
24
25
std::string
parseXmlFragmentFromString
(
const
std::string &str)
26
{
27
ssize_t pos = 0;
28
auto
lambda = [&pos, &str]()->
char
29
{
30
return
str[pos++];
31
};
32
return
parseXmlFragment
(lambda);
33
}
34
35
36
TEST
(XmlAwaiter, SimpleFragment)
37
{
38
EXPECT_EQ(
parseXmlFragmentFromString
(
"< toto >"
),
"<toto>"
);
39
EXPECT_EQ(
parseXmlFragmentFromString
(
"<toto\n>"
),
"<toto>"
);
40
EXPECT_EQ(
parseXmlFragmentFromString
(
"<\ntoto\n>"
),
"<toto>"
);
41
EXPECT_EQ(
parseXmlFragmentFromString
(
"\n\n<\ntoto\n>"
),
"<toto>"
);
42
43
EXPECT_EQ(
parseXmlFragmentFromString
(
"< toto />"
),
"<toto/>"
);
44
EXPECT_EQ(
parseXmlFragmentFromString
(
"<toto\n/>"
),
"<toto/>"
);
45
EXPECT_EQ(
parseXmlFragmentFromString
(
"<\ntoto\n/>"
),
"<toto/>"
);
46
EXPECT_EQ(
parseXmlFragmentFromString
(
"\n\n<\ntoto\n/>"
),
"<toto/>"
);
47
}
48
49
TEST
(XmlAwaiter, SimpleAttribute)
50
{
51
EXPECT_EQ(
parseXmlFragmentFromString
(
"< toto value='1' >"
),
"<toto value='1'>"
);
52
EXPECT_EQ(
parseXmlFragmentFromString
(
"<toto\nvalue='1'>"
),
"<toto value='1'>"
);
53
EXPECT_EQ(
parseXmlFragmentFromString
(
"< toto value='1' />"
),
"<toto value='1'/>"
);
54
EXPECT_EQ(
parseXmlFragmentFromString
(
"<toto\nvalue='1'/>"
),
"<toto value='1'/>"
);
55
56
EXPECT_EQ(
parseXmlFragmentFromString
(
"< toto value >"
),
"<toto value>"
);
57
EXPECT_EQ(
parseXmlFragmentFromString
(
"<toto\nvalue>"
),
"<toto value>"
);
58
EXPECT_EQ(
parseXmlFragmentFromString
(
"< toto value />"
),
"<toto value/>"
);
59
EXPECT_EQ(
parseXmlFragmentFromString
(
"<toto\nvalue/>"
),
"<toto value/>"
);
60
61
}
62
parseXmlFragmentFromString
std::string parseXmlFragmentFromString(const std::string &str)
Definition
XmlAwaiterTest.cpp:25
TEST
TEST(XmlAwaiter, SimpleFragment)
Definition
XmlAwaiterTest.cpp:36
parseXmlFragment
std::string parseXmlFragment(std::function< char()> readchar)
Definition
XmlAwaiter.cpp:24
XmlAwaiter.h
Generated on Thu Oct 22 2026 14:46:48 for Instrument Neutral Distributed Interface INDI by
1.9.8