Ai
1 Star 0 Fork 120

elddriver/mind-cluster

forked from Ascend/mind-cluster
Paused
 
Create your Gitee Account
Explore and code with more than 13.5 million developers,Free private repositories !:)
Sign up
文件
Clone or Download
strings_test.go 2.20 KB
Copy Edit Raw Blame History
zhoupan39 authored 2024-11-20 14:37 +08:00 . npu-exporter公共代码提取
/* Copyright(C) 2023. Huawei Technologies Co.,Ltd. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Package utils provides the util func
package utils
import (
"testing"
"github.com/smartystreets/goconvey/convey"
)
const byteLength = 32
func TestReplacePrefix(t *testing.T) {
convey.Convey("relative path", t, func() {
path := ReplacePrefix("./testdata/cert/ca.crt", "****")
convey.So(path, convey.ShouldEqual, "****testdata/cert/ca.crt")
})
convey.Convey("abconvey.Solute path", t, func() {
path := ReplacePrefix("/testdata/cert/ca.crt", "****")
convey.So(path, convey.ShouldEqual, "****estdata/cert/ca.crt")
})
convey.Convey("path length less than 2", t, func() {
path := ReplacePrefix("/", "****")
convey.So(path, convey.ShouldEqual, "****")
})
convey.Convey("empty string", t, func() {
path := ReplacePrefix("", "****")
convey.So(path, convey.ShouldEqual, "****")
})
}
func TestMaskPrefix(t *testing.T) {
convey.Convey("relative path", t, func() {
path := MaskPrefix("./testdata/cert/ca.crt")
convey.So(path, convey.ShouldEqual, "****testdata/cert/ca.crt")
})
convey.Convey("abconvey.Solute path", t, func() {
path := MaskPrefix("/testdata/cert/ca.crt")
convey.So(path, convey.ShouldEqual, "****estdata/cert/ca.crt")
})
convey.Convey("path length less than 2", t, func() {
path := MaskPrefix("/")
convey.So(path, convey.ShouldEqual, "****")
})
convey.Convey("empty string", t, func() {
path := MaskPrefix("")
convey.So(path, convey.ShouldEqual, "****")
})
}
func TestGetSha256Code(t *testing.T) {
convey.Convey("test sha256", t, func() {
hashs := GetSha256Code([]byte("this is a test sentence"))
convey.So(len(hashs), convey.ShouldEqual, byteLength)
})
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/elddriver/mind-cluster.git
git@gitee.com:elddriver/mind-cluster.git
elddriver
mind-cluster
mind-cluster
366d0f7fc38e

Search