1
0
mirror of https://github.com/duke-git/lancet.git synced 2026-02-09 15:12:26 +08:00

feat: add IsGBK

This commit is contained in:
dudaodong
2022-12-15 16:21:09 +08:00
parent fb3de03f37
commit 0a99492cf6
6 changed files with 134 additions and 4 deletions

View File

@@ -4,8 +4,10 @@ import (
"fmt"
"testing"
"time"
"unicode/utf8"
"github.com/duke-git/lancet/internal"
"golang.org/x/text/encoding/simplifiedchinese"
)
func TestIsAllUpper(t *testing.T) {
@@ -388,3 +390,13 @@ func TestIsZeroValue(t *testing.T) {
assert.Equal(false, IsZeroValue(value))
}
}
func TestIsGBK(t *testing.T) {
assert := internal.NewAssert(t, "TestIsGBK")
str := "你好"
gbkData, _ := simplifiedchinese.GBK.NewEncoder().Bytes([]byte(str))
assert.Equal(true, IsGBK(gbkData))
assert.Equal(false, utf8.Valid(gbkData))
}