2 #include <gtest/gtest.h>
3 #include <boost/filesystem/path.hpp>
8 using namespace std::literals::string_literals;
60 const auto expectedStyles = std::vector<StyleProperties>{
92 ASSERT_EQ(sample.getStyleProperties(), expectedStyles);
96 ASSERT_EQ(sample.stylePropertiesOf(
"book"s),
119 ASSERT_EQ(sample.stylePropertiesOf(
"invalid style"s), std::nullopt);
122 TEST(TranslationTableTest, constructorTestFromPath) {
123 ASSERT_NO_THROW(
TranslationTable(boost::filesystem::path(
"../../src/translationTable.json")));
126 TEST(TranslationTableTest, parsingInvalidStyleFieldsTest) {
127 auto invalidContent = std::stringstream{R
"(
138 const auto expected = std::vector<StyleProperties>{{
"garbage", {}, {}}};
139 ASSERT_EQ(table.getStyleProperties(), expected);
142 TEST(TranslationTableTest, parsingInvalidStyleNameTest) {
143 auto invalidContent = std::stringstream{R
"(
147 "someKey": "garbage",
148 "requiredFields": "def",
149 "optionalFields": "def"
155 const auto expected = std::vector<StyleProperties>{{
"", {}, {}}};
156 ASSERT_EQ(table.getStyleProperties(), expected);
159 TEST(TranslationTableTest, parsingInvalidStylesTest) {
160 auto invalidContent = std::stringstream{R
"(
165 "requiredFields": "def",
166 "optionalFields": "def"
171 ASSERT_ANY_THROW(const auto table =
TranslationTable(std::move(invalidContent)));
174 TEST(TranslationTableTest, parsingInvalidFileContent) {
175 auto invalidContent = std::stringstream{R
"(
184 ASSERT_ANY_THROW(const auto table =
TranslationTable(std::move(invalidContent)));
187 TEST(TranslationTableTest, parsingInvalidFile) {
188 auto invalidFile = boost::filesystem::path(
"./someUnExistingFile.json");
192 TEST(TranslationTableTest, parsingDirectory) {
193 auto invalidFile = boost::filesystem::path(
".");