2021-05-23 16:25:46 +03:00
|
|
|
package twin
|
|
|
|
|
|
|
|
import (
|
|
|
|
"reflect"
|
|
|
|
"testing"
|
|
|
|
|
2022-09-25 10:06:46 +03:00
|
|
|
"gotest.tools/v3/assert"
|
2021-05-23 16:25:46 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestTrimSpaceRight(t *testing.T) {
|
|
|
|
// Empty
|
|
|
|
assert.Assert(t, reflect.DeepEqual(
|
|
|
|
TrimSpaceRight(
|
|
|
|
[]Cell{},
|
|
|
|
),
|
|
|
|
[]Cell{}))
|
|
|
|
|
|
|
|
// Single non-space
|
|
|
|
assert.Assert(t, reflect.DeepEqual(
|
|
|
|
TrimSpaceRight(
|
|
|
|
[]Cell{{Rune: 'x'}},
|
|
|
|
),
|
|
|
|
[]Cell{{Rune: 'x'}}))
|
|
|
|
|
|
|
|
// Single space
|
|
|
|
assert.Assert(t, reflect.DeepEqual(
|
|
|
|
TrimSpaceRight(
|
|
|
|
[]Cell{{Rune: ' '}},
|
|
|
|
),
|
|
|
|
[]Cell{}))
|
|
|
|
|
|
|
|
// Non-space plus space
|
|
|
|
assert.Assert(t, reflect.DeepEqual(
|
|
|
|
TrimSpaceRight(
|
|
|
|
[]Cell{{Rune: 'x'}, {Rune: ' '}},
|
|
|
|
),
|
|
|
|
[]Cell{{Rune: 'x'}}))
|
|
|
|
}
|