1
1
mirror of https://github.com/walles/moar.git synced 2024-11-27 01:05:23 +03:00
moar/twin/cell_test.go
2022-09-25 09:06:46 +02:00

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'}}))
}