package main import ( "regexp" "testing" ) func TestSimpleFileSimpleExpression(t *testing.T) { fileContents := ` 100 ` expected := ` 150 ` regex := regexp.MustCompile(`(\d+)`) luaExpr := `*1.5` modifiedContent, err := process(fileContents, regex, luaExpr) if err != nil { t.Fatalf("Error processing file: %v", err) } if modifiedContent != expected { t.Fatalf("Expected modified content to be %v, but got %v", expected, modifiedContent) } } func TestSimpleFileVExpression(t *testing.T) { fileContents := ` 100 ` expected := ` 150 ` regex := regexp.MustCompile(`(\d+)`) luaExpr := `v1 * 1.5` modifiedContent, err := process(fileContents, regex, luaExpr) if err != nil { t.Fatalf("Error processing file: %v", err) } if modifiedContent != expected { t.Fatalf("Expected modified content to be %v, but got %v", expected, modifiedContent) } } func TestSimpleFileTableVExpression(t *testing.T) { fileContents := ` 100 ` expected := ` 150 ` regex := regexp.MustCompile(`(\d+)`) luaExpr := `v[1] * 1.5` modifiedContent, err := process(fileContents, regex, luaExpr) if err != nil { t.Fatalf("Error processing file: %v", err) } if modifiedContent != expected { t.Fatalf("Expected modified content to be %v, but got %v", expected, modifiedContent) } } func TestComplexFileSimpleExpression(t *testing.T) { fileContents := ` 100 200 300 ` expected := ` 150 300 450 ` regex := regexp.MustCompile(`(\d+)`) luaExpr := `*1.5` modifiedContent, err := process(fileContents, regex, luaExpr) if err != nil { t.Fatalf("Error processing file: %v", err) } if modifiedContent != expected { t.Fatalf("Expected modified content to be %v, but got %v", expected, modifiedContent) } } func TestComplexFileVExpression(t *testing.T) { fileContents := ` 100 200 300 ` expected := ` 150 300 450 ` regex := regexp.MustCompile(`(\d+)`) luaExpr := `v1 * 1.5` modifiedContent, err := process(fileContents, regex, luaExpr) if err != nil { t.Fatalf("Error processing file: %v", err) } if modifiedContent != expected { t.Fatalf("Expected modified content to be %v, but got %v", expected, modifiedContent) } } func TestComplexFileTableVExpression(t *testing.T) { fileContents := ` 100 200 300 ` expected := ` 150 300 450 ` regex := regexp.MustCompile(`(\d+)`) luaExpr := `v[1] * 1.5` modifiedContent, err := process(fileContents, regex, luaExpr) if err != nil { t.Fatalf("Error processing file: %v", err) } if modifiedContent != expected { t.Fatalf("Expected modified content to be %v, but got %v", expected, modifiedContent) } }