2019-10-21 14:22:31 -07:00
|
|
|
package anchor
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"gotest.tools/assert"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestWrappedWithParentheses_StringIsWrappedWithParentheses(t *testing.T) {
|
|
|
|
str := "(something)"
|
|
|
|
assert.Assert(t, IsConditionAnchor(str))
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestWrappedWithParentheses_StringHasOnlyParentheses(t *testing.T) {
|
|
|
|
str := "()"
|
|
|
|
assert.Assert(t, IsConditionAnchor(str))
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestWrappedWithParentheses_StringHasNoParentheses(t *testing.T) {
|
|
|
|
str := "something"
|
|
|
|
assert.Assert(t, !IsConditionAnchor(str))
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestWrappedWithParentheses_StringHasLeftParentheses(t *testing.T) {
|
|
|
|
str := "(something"
|
|
|
|
assert.Assert(t, !IsConditionAnchor(str))
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestWrappedWithParentheses_StringHasRightParentheses(t *testing.T) {
|
|
|
|
str := "something)"
|
|
|
|
assert.Assert(t, !IsConditionAnchor(str))
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestWrappedWithParentheses_StringParenthesesInside(t *testing.T) {
|
|
|
|
str := "so)m(et(hin)g"
|
|
|
|
assert.Assert(t, !IsConditionAnchor(str))
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestWrappedWithParentheses_Empty(t *testing.T) {
|
|
|
|
str := ""
|
|
|
|
assert.Assert(t, !IsConditionAnchor(str))
|
|
|
|
}
|
|
|
|
|
2020-01-24 12:05:53 -08:00
|
|
|
func TestIsExistenceAnchor_Yes(t *testing.T) {
|
|
|
|
assert.Assert(t, IsExistenceAnchor("^(abc)"))
|
2019-10-21 14:22:31 -07:00
|
|
|
}
|
|
|
|
|
2020-01-24 12:05:53 -08:00
|
|
|
func TestIsExistenceAnchor_NoRightBracket(t *testing.T) {
|
|
|
|
assert.Assert(t, !IsExistenceAnchor("^(abc"))
|
2019-10-21 14:22:31 -07:00
|
|
|
}
|
|
|
|
|
2020-01-24 12:05:53 -08:00
|
|
|
func TestIsExistenceAnchor_OnlyHat(t *testing.T) {
|
|
|
|
assert.Assert(t, !IsExistenceAnchor("^abc"))
|
2019-10-21 14:22:31 -07:00
|
|
|
}
|
|
|
|
|
2020-01-24 12:05:53 -08:00
|
|
|
func TestIsExistenceAnchor_ConditionAnchor(t *testing.T) {
|
|
|
|
assert.Assert(t, !IsExistenceAnchor("(abc)"))
|
2019-10-21 14:22:31 -07:00
|
|
|
}
|