github.com/blend/go-sdk@v1.20220411.3/stringutil/split_space_test.go (about)

     1  /*
     2  
     3  Copyright (c) 2022 - Present. Blend Labs, Inc. All rights reserved
     4  Use of this source code is governed by a MIT license that can be found in the LICENSE file.
     5  
     6  */
     7  
     8  package stringutil
     9  
    10  import (
    11  	"testing"
    12  
    13  	"github.com/blend/go-sdk/assert"
    14  )
    15  
    16  func TestSplitSpace(t *testing.T) {
    17  	assert := assert.New(t)
    18  
    19  	values := SplitSpace("")
    20  	assert.Len(values, 0)
    21  
    22  	values = SplitSpace("foo")
    23  	assert.Len(values, 1)
    24  	assert.Equal("foo", values[0])
    25  
    26  	values = SplitSpace("foo bar")
    27  	assert.Len(values, 2)
    28  	assert.Equal("foo", values[0])
    29  	assert.Equal("bar", values[1])
    30  
    31  	values = SplitSpace("foo  bar")
    32  	assert.Len(values, 2)
    33  	assert.Equal("foo", values[0])
    34  	assert.Equal("bar", values[1])
    35  
    36  	values = SplitSpace("foo\tbar")
    37  	assert.Len(values, 2)
    38  	assert.Equal("foo", values[0])
    39  	assert.Equal("bar", values[1])
    40  
    41  	values = SplitSpace("foo \tbar")
    42  	assert.Len(values, 2)
    43  	assert.Equal("foo", values[0])
    44  	assert.Equal("bar", values[1])
    45  
    46  	values = SplitSpace("foo bar  ")
    47  	assert.Len(values, 2)
    48  	assert.Equal("foo", values[0])
    49  	assert.Equal("bar", values[1])
    50  
    51  	values = SplitSpace("foo bar baz")
    52  	assert.Len(values, 3)
    53  	assert.Equal("foo", values[0])
    54  	assert.Equal("bar", values[1])
    55  	assert.Equal("baz", values[2])
    56  }