mirror of
https://github.com/walles/moar.git
synced 2024-09-11 12:15:43 +03:00
39 lines
605 B
Go
39 lines
605 B
Go
package twin
|
|
|
|
import (
|
|
"reflect"
|
|
"testing"
|
|
|
|
"gotest.tools/v3/assert"
|
|
)
|
|
|
|
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'}}))
|
|
}
|