Skip to content

Commit

Permalink
up: com, str - add some consts and add some tests
Browse files Browse the repository at this point in the history
  • Loading branch information
inhere committed Oct 14, 2022
1 parent afdcc45 commit f9e4a30
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 25 deletions.
25 changes: 0 additions & 25 deletions comdef/consts.go
Original file line number Diff line number Diff line change
@@ -1,30 +1,5 @@
package comdef

const (
// CommaStr const define
CommaStr = ","
// CommaChar define
CommaChar = ','

// PathStr define const
PathStr = "/"
// PathChar define
PathChar = '/'

// DefaultSep comma string
DefaultSep = ","

// SpaceChar char
SpaceChar = ' '
// SpaceStr string
SpaceStr = " "

// NewlineChar char
NewlineChar = '\n'
// NewlineStr string
NewlineStr = "\n"
)

// consts for compare operation
const (
OpEq = "="
Expand Down
41 changes: 41 additions & 0 deletions comdef/symbols.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package comdef

const (
// CommaStr const define
CommaStr = ","
// CommaChar define
CommaChar = ','

// EqualStr define
EqualStr = "="
// EqualChar define
EqualChar = '='

// ColonStr define
ColonStr = ":"
// ColonChar define
ColonChar = ':'

// SemicolonStr semicolon define
SemicolonStr = ";"
// SemicolonChar define
SemicolonChar = ';'

// PathStr define const
PathStr = "/"
// PathChar define
PathChar = '/'

// DefaultSep comma string
DefaultSep = ","

// SpaceChar char
SpaceChar = ' '
// SpaceStr string
SpaceStr = " "

// NewlineChar char
NewlineChar = '\n'
// NewlineStr string
NewlineStr = "\n"
)
14 changes: 14 additions & 0 deletions strutil/split_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,17 @@ func TestSubstr(t *testing.T) {
assert.Eq(t, "cDEF12", strutil.Substr("abcDEF123", 2, -1))
assert.Eq(t, "cDEF", strutil.Substr("abcDEF123", 2, -3))
}

func TestSplitInlineComment(t *testing.T) {
val, comment := strutil.SplitInlineComment("value0")
assert.Eq(t, "value0", val)
assert.Eq(t, "", comment)

val, comment = strutil.SplitInlineComment("value0 // comments at end")
assert.Eq(t, "value0", val)
assert.Eq(t, "// comments at end", comment)

val, comment = strutil.SplitInlineComment("value0 # comments at end")
assert.Eq(t, "value0", val)
assert.Eq(t, "# comments at end", comment)
}

0 comments on commit f9e4a30

Please sign in to comment.