@ -91,8 +91,8 @@ func AssertGoldenStringWithCustomLineValidation(t TestingT, checkLine func(expec
if err != nil {
if err != nil {
t . Fatalf ( "%v" , err )
t . Fatalf ( "%v" , err )
}
}
expectedLines := strings . Sp lit( stri ng( normaliz e( expectedOutput ) ) , "\n" )
expectedLines := lines ( expectedOutput )
actualLines := strings . Sp lit( stri ng( normaliz e( [ ] byte ( actualOutput ) ) ) , "\n" )
actualLines := lines ( [ ] byte ( actualOutput ) )
expectedLineCount := len ( expectedLines )
expectedLineCount := len ( expectedLines )
actualLineCount := len ( actualLines )
actualLineCount := len ( actualLines )
for i := 0 ; i < max ( expectedLineCount , actualLineCount ) ; i ++ {
for i := 0 ; i < max ( expectedLineCount , actualLineCount ) ; i ++ {
@ -118,6 +118,10 @@ func AssertGoldenStringWithCustomLineValidation(t TestingT, checkLine func(expec
}
}
}
}
func lines ( raw [ ] byte ) [ ] string {
return strings . Split ( strings . TrimSuffix ( string ( normalize ( raw ) ) , "\n" ) , "\n" ) // We first remove the final newline (if any), so that e.g. the 2-line string "a\nb\n" is mapped to ["a", "b"] and not ["a", "b", ""].
}
func path ( filename string ) string {
func path ( filename string ) string {
if filepath . IsAbs ( filename ) {
if filepath . IsAbs ( filename ) {
return filename
return filename