1
1
mirror of https://github.com/walles/moar.git synced 2024-11-30 02:34:13 +03:00
moar/twin/cell_test.go

39 lines
605 B
Go
Raw Normal View History

package twin
import (
"reflect"
"testing"
2022-09-25 10:06:46 +03:00
"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'}}))
}