1 #include <gtest/gtest.h>
11 using namespace std::literals::string_literals;
13 template<
class D,
class S>
15 return dynamic_cast<const D *
>(src) !=
nullptr;
35 const auto file = R
"(some
42 ASSERT_NO_THROW([&]() {
43 for (
const auto c : file) {
47 ASSERT_TRUE(isType<GlobalParserState>(state));
53 const auto file = R
"(some@)"s;
56 ASSERT_NO_THROW([&]() {
57 for (
const auto c : file) {
61 ASSERT_FALSE(isType<GlobalParserState>(state));
62 ASSERT_TRUE(isType<StyleParserState>(state));
68 const auto file = R
"(here are spaces)"s;
71 ASSERT_ANY_THROW([&]() {
72 for (
const auto c : file) {
81 const auto file = R
"(thisIsAValidStyle)"s;
84 ASSERT_NO_THROW([&]() {
85 for (
const auto c : file) {
90 ASSERT_TRUE(isType<StyleParserState>(state));
95 const auto file = R
"(thisIsAValidStyle{)"s;
98 ASSERT_NO_THROW([&]() {
99 for (
const auto c : file) {
104 ASSERT_EQ(result.front().style,
"thisIsAValidStyle"s);
105 ASSERT_FALSE(isType<StyleParserState>(state));
106 ASSERT_TRUE(isType<IdentifierParserState>(state));
111 const auto file = R
"(someUselessStuff @thisIsAValidStyle{)"s;
114 ASSERT_NO_THROW([&]() {
115 for (
const auto c : file) {
120 ASSERT_EQ(result.front().style,
"thisIsAValidStyle"s);
121 ASSERT_TRUE(isType<IdentifierParserState>(state));
126 const auto file = R
"(identifier with whitespace)"s;
129 ASSERT_ANY_THROW([&]() {
130 for (
const auto c : file) {
139 const auto file = R
"(identifier,)"s;
140 result.push_back({"",
"", {}});
143 ASSERT_NO_THROW([&]() {
144 for (
const auto c : file) {
149 ASSERT_EQ(result.front().id,
"identifier"s);
150 ASSERT_TRUE(isType<KeyParserState>(state));
155 const auto file = R
"( this is a key )"s;
158 ASSERT_NO_THROW([&]() {
159 for (
const auto c : file) {
164 ASSERT_TRUE(isType<KeyParserState>(state));
169 const auto file = R
"( this is a key =)"s;
170 result.push_back({"",
"", {}});
173 ASSERT_NO_THROW([&]() {
174 for (
const auto c : file) {
179 ASSERT_EQ(result.front().attributes.front().name,
"this is a key"s);
180 ASSERT_TRUE(isType<ValueParserState>(state));
185 const auto file = R
"( this is a key ,)"s;
186 result.push_back({"",
"", {{
"",
""}}});
189 ASSERT_NO_THROW([&]() {
190 for (
const auto c : file) {
195 ASSERT_EQ(result.front().attributes.front().value,
"this is a key"s);
196 ASSERT_TRUE(isType<KeyParserState>(state));
201 const auto file = R
"( {{ this, is a key }} ,)"s;
202 result.push_back({"",
"", {{
"",
""}}});
205 ASSERT_NO_THROW([&]() {
206 for (
const auto c : file) {
211 ASSERT_EQ(result.front().attributes.front().value,
"this, is a key"s);
212 ASSERT_TRUE(isType<KeyParserState>(state));
217 const auto file = R
"(} )"s;
220 ASSERT_NO_THROW([&]() {
221 for (
const auto c : file) {
226 ASSERT_TRUE(isType<GlobalParserState>(state));
231 const auto file = R
"(} )"s;
232 result.push_back({"",
"", {{
"",
""}}});
235 ASSERT_NO_THROW([&]() {
236 for (
const auto c : file) {
241 ASSERT_TRUE(isType<GlobalParserState>(state));
246 const auto file = R
"(@inproceedings{Feigenspan11,
247 author = {Janet Feigenspan},
248 title = {{Program Comprehension of Feature-Oriented Software Development}},
249 booktitle = {International Doctoral Symposium on Empirical Software Engineering (IDoESE)},
252 url = {http://wwwiti.cs.uni-magdeburg.de/iti_db/publikationen/ps/auto/Feigenspan11.pdf}
256 BibElement expected{
"Feigenspan11",
"inproceedings", {
257 {
"author",
"Janet Feigenspan"},
258 {
"title",
"Program Comprehension of Feature-Oriented Software Development"},
259 {
"booktitle",
"International Doctoral Symposium on Empirical Software Engineering (IDoESE)"},
262 {
"url",
"http://wwwiti.cs.uni-magdeburg.de/iti_db/publikationen/ps/auto/Feigenspan11.pdf"}
265 ASSERT_NO_THROW([&]() {
266 for (
const auto c : file) {
271 ASSERT_EQ(result.front(), expected);
272 ASSERT_TRUE(isType<GlobalParserState>(state));
277 const auto file = R
"(
278 @inproceedings{Feigenspan11,
279 author = {Janet Feigenspan},
280 title = {{Program Comprehension of Feature-Oriented Software Development}},
281 booktitle = {International Doctoral Symposium on Empirical Software Engineering (IDoESE)},
284 url = {http://wwwiti.cs.uni-magdeburg.de/iti_db/publikationen/ps/auto/Feigenspan11.pdf}
286 @article{FeigenspanSiFr11,
287 author = {Janet Feigenspan and Norbert Siegmund and Jana Fruth},
288 title = {{On the Role of Program Comprehension in Embedded Systems}},
289 journal = {Softwaretechnik-Trends},
294 url = {http://www.uni-koblenz-landau.de/koblenz/fb4/institute/uebergreifend/sre/conferences/wsr/wsr2011/wsr2011_proceedings.pdf}
298 std::vector<BibElement> expected{
299 {
"Feigenspan11",
"inproceedings", {
300 {
"author",
"Janet Feigenspan"},
301 {
"title",
"Program Comprehension of Feature-Oriented Software Development"},
302 {
"booktitle",
"International Doctoral Symposium on Empirical Software Engineering (IDoESE)"},
305 {
"url",
"http://wwwiti.cs.uni-magdeburg.de/iti_db/publikationen/ps/auto/Feigenspan11.pdf"}
306 }}, {
"FeigenspanSiFr11",
"article", {
307 {
"author",
"Janet Feigenspan and Norbert Siegmund and Jana Fruth"},
308 {
"title",
"On the Role of Program Comprehension in Embedded Systems"},
309 {
"journal",
"Softwaretechnik-Trends"},
315 "http://www.uni-koblenz-landau.de/koblenz/fb4/institute/uebergreifend/sre/conferences/wsr/wsr2011/wsr2011_proceedings.pdf"}
318 ASSERT_NO_THROW([&]() {
319 for (
const auto c : file) {
324 ASSERT_EQ(result, expected);