Make file parsing concurrent

This commit is contained in:
2025-03-22 13:50:10 +01:00
parent b96b6f9ef1
commit 769435db2c
2 changed files with 49 additions and 11 deletions

View File

@@ -80,6 +80,38 @@ func TestShorthandNotation(t *testing.T) {
}
}
func TestShorthandNotationFloats(t *testing.T) {
fileContents := `
<config>
<item>
<value>132.671327</value>
</item>
</config>
`
expected := `
<config>
<item>
<value>176.01681007940928</value>
</item>
</config>
`
regex := regexp.MustCompile(`(?s)<value>(\d*\.?\d+)</value>`)
luaExpr := `v1 * 1.32671327` // Use direct assignment syntax
luaScript := buildLuaScript(luaExpr)
modifiedContent, _, _, err := process(fileContents, regex, luaScript, "test.xml", luaExpr )
if err != nil {
t.Fatalf("Error processing file: %v", err)
}
normalizedModified := normalizeWhitespace(modifiedContent)
normalizedExpected := normalizeWhitespace(expected)
if normalizedModified != normalizedExpected {
t.Fatalf("Expected modified content to be %q, but got %q", normalizedExpected, normalizedModified)
}
}
func TestArrayNotation(t *testing.T) {
fileContents := `
<config>