mirror of
https://github.com/projectM-visualizer/projectm.git
synced 2026-03-29 18:54:07 +00:00
Fix some errors in FileParser
This commit is contained in:
@ -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));
|
||||
}
|
||||
|
||||
@ -17,7 +17,7 @@ class FileParser
|
||||
public:
|
||||
using ValueMap = std::map<std::string, std::string>; //!< 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.
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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;
|
||||
|
||||
Reference in New Issue
Block a user