#include <gtest/gtest.h>
using namespace std::literals::string_literals;
template<class D, class S>
return dynamic_cast<const D *>(src) != nullptr;
}
protected:
std::vector<BibElement> result;
void SetUp() override {
result = {};
}
};
const auto file = R"(some
non
at_ characters)"s;
ASSERT_NO_THROW([&]() {
for (const auto c : file) {
}
}());
ASSERT_TRUE(isType<GlobalParserState>(state));
delete state;
}
const auto file = R"(some@)"s;
ASSERT_NO_THROW([&]() {
for (const auto c : file) {
}
}());
ASSERT_FALSE(isType<GlobalParserState>(state));
ASSERT_TRUE(isType<StyleParserState>(state));
delete state;
}
const auto file = R"(here are spaces)"s;
ASSERT_ANY_THROW([&]() {
for (const auto c : file) {
}
}());
delete state;
}
const auto file = R"(thisIsAValidStyle)"s;
ASSERT_NO_THROW([&]() {
for (const auto c : file) {
}
}());
ASSERT_TRUE(isType<StyleParserState>(state));
delete state;
}
const auto file = R"(thisIsAValidStyle{)"s;
ASSERT_NO_THROW([&]() {
for (const auto c : file) {
}
}());
ASSERT_EQ(result.front().style, "thisIsAValidStyle"s);
ASSERT_FALSE(isType<StyleParserState>(state));
ASSERT_TRUE(isType<IdentifierParserState>(state));
delete state;
}
const auto file = R"(someUselessStuff @thisIsAValidStyle{)"s;
ASSERT_NO_THROW([&]() {
for (const auto c : file) {
}
}());
ASSERT_EQ(result.front().style, "thisIsAValidStyle"s);
ASSERT_TRUE(isType<IdentifierParserState>(state));
delete state;
}
const auto file = R"(identifier with whitespace)"s;
ASSERT_ANY_THROW([&]() {
for (const auto c : file) {
}
}());
delete state;
}
const auto file = R"(identifier,)"s;
result.push_back({"", "", {}});
ASSERT_NO_THROW([&]() {
for (const auto c : file) {
}
}());
ASSERT_EQ(result.front().id, "identifier"s);
ASSERT_TRUE(isType<KeyParserState>(state));
delete state;
}
const auto file = R"( this is a key )"s;
ASSERT_NO_THROW([&]() {
for (const auto c : file) {
}
}());
ASSERT_TRUE(isType<KeyParserState>(state));
delete state;
}
const auto file = R"( this is a key =)"s;
result.push_back({"", "", {}});
ASSERT_NO_THROW([&]() {
for (const auto c : file) {
}
}());
ASSERT_EQ(result.front().attributes.front().name, "this is a key"s);
ASSERT_TRUE(isType<ValueParserState>(state));
delete state;
}
const auto file = R"( this is a key ,)"s;
result.push_back({"", "", {{"", ""}}});
ASSERT_NO_THROW([&]() {
for (const auto c : file) {
}
}());
ASSERT_EQ(result.front().attributes.front().value, "this is a key"s);
ASSERT_TRUE(isType<KeyParserState>(state));
delete state;
}
const auto file = R"( {{ this, is a key }} ,)"s;
result.push_back({"", "", {{"", ""}}});
ASSERT_NO_THROW([&]() {
for (const auto c : file) {
}
}());
ASSERT_EQ(result.front().attributes.front().value, "this, is a key"s);
ASSERT_TRUE(isType<KeyParserState>(state));
delete state;
}
const auto file = R"(} )"s;
ASSERT_NO_THROW([&]() {
for (const auto c : file) {
}
}());
ASSERT_TRUE(isType<GlobalParserState>(state));
delete state;
}
const auto file = R"(} )"s;
result.push_back({"", "", {{"", ""}}});
ASSERT_NO_THROW([&]() {
for (const auto c : file) {
}
}());
ASSERT_TRUE(isType<GlobalParserState>(state));
delete state;
}
const auto file = R"(@inproceedings{Feigenspan11,
author = {Janet Feigenspan},
title = {{Program Comprehension of Feature-Oriented Software Development}},
booktitle = {International Doctoral Symposium on Empirical Software Engineering (IDoESE)},
year = {2011},
month = Sep,
url = {http://wwwiti.cs.uni-magdeburg.de/iti_db/publikationen/ps/auto/Feigenspan11.pdf}
})"s;
BibElement expected{
"Feigenspan11",
"inproceedings", {
{"author", "Janet Feigenspan"},
{"title", "Program Comprehension of Feature-Oriented Software Development"},
{"booktitle", "International Doctoral Symposium on Empirical Software Engineering (IDoESE)"},
{"year", "2011"},
{"month", "Sep"},
{"url", "http://wwwiti.cs.uni-magdeburg.de/iti_db/publikationen/ps/auto/Feigenspan11.pdf"}
}};
ASSERT_NO_THROW([&]() {
for (const auto c : file) {
}
}());
ASSERT_EQ(result.front(), expected);
ASSERT_TRUE(isType<GlobalParserState>(state));
delete state;
}
const auto file = R"(
@inproceedings{Feigenspan11,
author = {Janet Feigenspan},
title = {{Program Comprehension of Feature-Oriented Software Development}},
booktitle = {International Doctoral Symposium on Empirical Software Engineering (IDoESE)},
year = {2011},
month = Sep,
url = {http://wwwiti.cs.uni-magdeburg.de/iti_db/publikationen/ps/auto/Feigenspan11.pdf}
}
@article{FeigenspanSiFr11,
author = {Janet Feigenspan and Norbert Siegmund and Jana Fruth},
title = {{On the Role of Program Comprehension in Embedded Systems}},
journal = {Softwaretechnik-Trends},
year = {2011},
volume = {31},
number = {2},
month = May,
url = {http://www.uni-koblenz-landau.de/koblenz/fb4/institute/uebergreifend/sre/conferences/wsr/wsr2011/wsr2011_proceedings.pdf}
})"s;
std::vector<BibElement> expected{
{"Feigenspan11", "inproceedings", {
{"author", "Janet Feigenspan"},
{"title", "Program Comprehension of Feature-Oriented Software Development"},
{"booktitle", "International Doctoral Symposium on Empirical Software Engineering (IDoESE)"},
{"year", "2011"},
{"month", "Sep"},
{"url", "http://wwwiti.cs.uni-magdeburg.de/iti_db/publikationen/ps/auto/Feigenspan11.pdf"}
}}, {"FeigenspanSiFr11", "article", {
{"author", "Janet Feigenspan and Norbert Siegmund and Jana Fruth"},
{"title", "On the Role of Program Comprehension in Embedded Systems"},
{"journal", "Softwaretechnik-Trends"},
{"year", "2011"},
{"volume", "31"},
{"number", "2"},
{"month", "May"},
{"url",
"http://www.uni-koblenz-landau.de/koblenz/fb4/institute/uebergreifend/sre/conferences/wsr/wsr2011/wsr2011_proceedings.pdf"}
}}};
ASSERT_NO_THROW([&]() {
for (const auto c : file) {
}
}());
ASSERT_EQ(result, expected);
delete state;
}