代码拉取完成,页面将自动刷新
package swag
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestValidDataType(t *testing.T) {
assert.NoError(t, CheckSchemaType(STRING))
assert.NoError(t, CheckSchemaType(NUMBER))
assert.NoError(t, CheckSchemaType(INTEGER))
assert.NoError(t, CheckSchemaType(BOOLEAN))
assert.NoError(t, CheckSchemaType(ARRAY))
assert.NoError(t, CheckSchemaType(OBJECT))
assert.Error(t, CheckSchemaType("oops"))
}
func TestTransToValidSchemeType(t *testing.T) {
assert.Equal(t, TransToValidSchemeType("uint"), INTEGER)
assert.Equal(t, TransToValidSchemeType("uint32"), INTEGER)
assert.Equal(t, TransToValidSchemeType("uint64"), INTEGER)
assert.Equal(t, TransToValidSchemeType("float32"), NUMBER)
assert.Equal(t, TransToValidSchemeType("bool"), BOOLEAN)
assert.Equal(t, TransToValidSchemeType("string"), STRING)
// should accept any type, due to user defined types
TransToValidSchemeType("oops")
}
func TestIsGolangPrimitiveType(t *testing.T) {
assert.Equal(t, IsGolangPrimitiveType("uint"), true)
assert.Equal(t, IsGolangPrimitiveType("int"), true)
assert.Equal(t, IsGolangPrimitiveType("uint8"), true)
assert.Equal(t, IsGolangPrimitiveType("uint16"), true)
assert.Equal(t, IsGolangPrimitiveType("int16"), true)
assert.Equal(t, IsGolangPrimitiveType("byte"), true)
assert.Equal(t, IsGolangPrimitiveType("uint32"), true)
assert.Equal(t, IsGolangPrimitiveType("int32"), true)
assert.Equal(t, IsGolangPrimitiveType("rune"), true)
assert.Equal(t, IsGolangPrimitiveType("uint64"), true)
assert.Equal(t, IsGolangPrimitiveType("int64"), true)
assert.Equal(t, IsGolangPrimitiveType("float32"), true)
assert.Equal(t, IsGolangPrimitiveType("float64"), true)
assert.Equal(t, IsGolangPrimitiveType("bool"), true)
assert.Equal(t, IsGolangPrimitiveType("string"), true)
assert.Equal(t, IsGolangPrimitiveType("oops"), false)
}
func TestIsNumericType(t *testing.T) {
assert.Equal(t, IsNumericType(INTEGER), true)
assert.Equal(t, IsNumericType(NUMBER), true)
assert.Equal(t, IsNumericType(STRING), false)
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。