Add line fixers: FixTabIndentationToSpaces, FixTabIndentationToSpaces, FixTabIndentationToSpaces.

This commit is contained in:
Amy Boyd
2016-07-04 17:25:40 +01:00
parent eb919067e6
commit bbbff6689b
2 changed files with 127 additions and 0 deletions

View File

@@ -0,0 +1,72 @@
package editorconfig
import (
"testing"
)
func TestFixTabIndentationToSpaces(t *testing.T) {
var result string
result = FixTabIndentationToSpaces("4", "\t\thello world")
if result != " hello world" {
t.Error("Unexpected result: " + result)
}
result = FixTabIndentationToSpaces("3", "\thello world")
if result != " hello world" {
t.Error("Unexpected result: " + result)
}
result = FixTabIndentationToSpaces("2", "\t\t\thello world")
if result != " hello world" {
t.Error("Unexpected result: " + result)
}
}
func TestFixMixedIndentationToSpaces(t *testing.T) {
var result string
result = FixMixedIndentationToSpaces("2", "\t \t hello worl d")
if result != " hello worl d" {
t.Error("Unexpected result: " + result)
}
result = FixMixedIndentationToSpaces("3", " \thello world !")
if result != " hello world !" {
t.Error("Unexpected result: " + result)
}
result = FixMixedIndentationToSpaces("2", " \t hello world !")
if result != " hello world !" {
t.Error("Unexpected result: " + result)
}
}
func TestFixUndividableIndentationToNearestSpacesAmount(t *testing.T) {
var result string
result = FixUndividableIndentationToNearestSpacesAmount("2", "hello")
if result != "hello" {
t.Error("String changed but it was already fine. Changed to: " + result)
}
result = FixUndividableIndentationToNearestSpacesAmount("2", " hello")
if result != " hello" {
t.Error("String changed but it was already fine. Changed to: " + result)
}
result = FixUndividableIndentationToNearestSpacesAmount("1", " hello")
if result != " hello" {
t.Error("String changed but it was already fine. Changed to: " + result)
}
result = FixUndividableIndentationToNearestSpacesAmount("3", " hello")
if result != " hello" {
t.Error("Unexpected result: " + result)
}
result = FixUndividableIndentationToNearestSpacesAmount("5", " hello")
if result != " hello" {
t.Error("Unexpected result: " + result)
}
}