diff --git a/src/libprojectM/MilkdropPresetFactory/FileParser.cpp b/src/libprojectM/MilkdropPresetFactory/FileParser.cpp index 14c1eaf30..648cebe79 100644 --- a/src/libprojectM/MilkdropPresetFactory/FileParser.cpp +++ b/src/libprojectM/MilkdropPresetFactory/FileParser.cpp @@ -168,7 +168,7 @@ void FileParser::ParseLine(const std::string& line) std::string value(line.begin() + varNameDelimiterPos + 1, line.end()); // Only add first occurrence to mimic Milkdrop behaviour - if (!varName.empty() && !value.empty() && m_presetValues.find(varName) == m_presetValues.end()) + if (!varName.empty() && m_presetValues.find(varName) == m_presetValues.end()) { m_presetValues.emplace(std::move(varName), std::move(value)); } diff --git a/src/libprojectM/MilkdropPresetFactory/FileParser.hpp b/src/libprojectM/MilkdropPresetFactory/FileParser.hpp index 17e00cee8..d9feeee40 100644 --- a/src/libprojectM/MilkdropPresetFactory/FileParser.hpp +++ b/src/libprojectM/MilkdropPresetFactory/FileParser.hpp @@ -17,7 +17,7 @@ class FileParser public: using ValueMap = std::map; //!< A map with key/value pairs, each representing one line in the preset file. - static constexpr std::streamsize maxFileSize = 0x100000; //!< Maximum size of a preset file. Used for sanity checks. + static constexpr size_t maxFileSize = 0x100000; //!< Maximum size of a preset file. Used for sanity checks. /** * @brief Reads the preset file into an internal map to prepare for parsing. diff --git a/tests/FileParserTest.cpp b/tests/FileParserTest.cpp index 776a70298..e54e72429 100644 --- a/tests/FileParserTest.cpp +++ b/tests/FileParserTest.cpp @@ -61,8 +61,9 @@ TEST(FileParser, EmptyValue) const auto& values = parser.PresetValues(); - // Lines with empty values should be ignored - EXPECT_TRUE(values.find("empty_value") == values.end()); + // Lines with empty values should be stored as such + ASSERT_FALSE(values.find("empty_value") == values.end()); + EXPECT_EQ(values.at("empty_value"), ""); } TEST(FileParser, EmptyKey) diff --git a/tests/data/FileParser/parser-code.milk b/tests/data/FileParser/parser-code.milk index 430c52aa7..3930b473e 100644 --- a/tests/data/FileParser/parser-code.milk +++ b/tests/data/FileParser/parser-code.milk @@ -1,7 +1,8 @@ // Very simple multi-line equation per_frame_1=r=1.0; per_frame_2=g=1.0; -per_frame_3=b=1.0; +per_frame_3= +per_frame_4=b=1.0; // A gap in numbering should terminate parsing per_frame_gap_1=r=1.0;