go-stock/backend/data/utils_test.go
spark c81b1a730d feat(data):添加tushare数据接口并优化股票代码转换功能(设置好提问模板后可进行K线分析功能)
- 新增 TushareApi 结构体和 GetDaily 方法,用于获取 A 股日线行情数据
- 在 openai_api.go 中添加获取股票日 K线数据的协程
- 在 utils.go 中添加股票代码与 tushare 代码相互转换的函数
- 更新相关测试文件以支持新功能
2025-02-17 17:33:17 +08:00

39 lines
1.1 KiB
Go

package data
import (
"go-stock/backend/logger"
"testing"
)
// TestRemoveNonPrintable tests the RemoveAllBlankChar function.
func TestRemoveNonPrintable(t *testing.T) {
//tests := []struct {
// input string
// expected string
//}{
// {"新 希 望", "新希望"},
// {"", ""},
// {"Hello, World!", "Hello, World!"},
// {"\x00\x01\x02", ""},
// {"Hello\x00World", "HelloWorld"},
// {"\x1F\x20\x7E\x7F", " \x7E"},
//}
//for _, test := range tests {
// actual := RemoveAllBlankChar(test.input)
// if actual != test.expected {
// t.Errorf("RemoveAllBlankChar(%q) = %q; expected %q", test.input, actual, test.expected)
// }
//}
txt := "新 希 望"
txt2 := RemoveAllBlankChar(txt)
logger.SugaredLogger.Infof("RemoveAllBlankChar(%s)", txt2)
logger.SugaredLogger.Infof("RemoveAllBlankChar(%s)", txt)
}
func TestConvertStockCodeToTushareCode(t *testing.T) {
logger.SugaredLogger.Infof("ConvertStockCodeToTushareCode(%s)", ConvertStockCodeToTushareCode("sz000802"))
logger.SugaredLogger.Infof("ConvertTushareCodeToStockCode(%s)", ConvertTushareCodeToStockCode("000802.SZ"))
}