Skip to content

Commit

Permalink
Add a test for the auto-edit that fixes timestamps having a colon for…
Browse files Browse the repository at this point in the history
… the decimal separator instead of a dot

Demonstrates that we already have a workaround for #378
  • Loading branch information
jacquesh committed Aug 12, 2024
1 parent b4603ca commit 4a996a6
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/lyric_auto_edit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "lyric_auto_edit.h"
#include "lyric_metadata.h"
#include "metrics.h"
#include "mvtf/mvtf.h"
#include "parsers.h"

static std::optional<LyricData> ReplaceHtmlEscapedChars(const LyricData& lyrics)
Expand Down Expand Up @@ -306,3 +307,23 @@ std::optional<LyricData> auto_edit::RunAutoEdit(AutoEditType type, const LyricDa
return result;
}

// ============
// Tests
// ============
#ifdef MVTF_TESTS_ENABLED
MVTF_TEST(autoedit_fixmalformedtimestamps_corrects_decimal_separator_from_colon_to_dot)
{
const std::string input = "[00:15:83]test";
LyricData parsed = parsers::lrc::parse({}, input);
std::optional<LyricData> fixed = FixMalformedTimestamps(parsed);
ASSERT(fixed.has_value());

std::tstring output = parsers::lrc::expand_text(fixed.value(), false);

ASSERT(fixed.value().IsTimestamped());
ASSERT(fixed.value().lines.size() == 1);
ASSERT(fixed.value().lines[0].timestamp == 15.83);
ASSERT(fixed.value().lines[0].text == _T("test"));
ASSERT(output == _T("[00:15.83]test\r\n"));
}
#endif

0 comments on commit 4a996a6

Please sign in to comment.