编写Interpreter的测试函数,并纠错

This commit is contained in:
chenxinquan 2022-11-07 11:51:34 +08:00
parent 586f3c4290
commit e42bbf3c19
2 changed files with 25 additions and 6 deletions

View File

@ -26,7 +26,7 @@
//
////////////////////////////////////////////////////////////////
package genmai
package Interpreter
import (
"encoding/binary"
@ -36,20 +36,20 @@ import (
func UtilsToS64(i int) string {
bytes := make([]byte, 8)
binary.LittleEndian.PutUint64(bytes, uint64())
binary.LittleEndian.PutUint64(bytes, uint64(i))
/* */
return string(bytes)
}
func UtilsToS32(i int) string {
bytes :make([]byte, 4)
binary.LittleEndian.PutUint32(bytes, uint32())
bytes := make([]byte, 4)
binary.LittleEndian.PutUint32(bytes, uint32(i))
/* */
return string(bytes)
}
func UtilsToU64(s sting) int {
func UtilsToU64(s string) int {
bytes := make([]byte, 8)
copy(bytes, []byte(s))
/* */
@ -64,7 +64,7 @@ func UtilsToU32(s string) int {
}
func UtilsPad(length int) string {
return string.Repeat("a", length)
return strings.Repeat("a", length)
}
func UtilsInterpreterPuse() {

View File

@ -32,6 +32,13 @@ import (
"fmt"
//"reflect"
"github.com/mitchellh/mapstructure"
// TODO:
// 应该写成相对路径因为genmai应该是编译成库所以包路径不
// 是以main开头。
//
// go 有点拉
inter "main/src/genmai/Interpreter"
)
func Test() {
@ -43,6 +50,18 @@ func Test() {
// "Source" : "aaa",
// }
///////////////////////////////
// Utils
fmt.Println(inter.UtilsToS64(97))
fmt.Println(inter.UtilsToS32(97))
/* */
fmt.Println(inter.UtilsToU64("a"))
fmt.Println(inter.UtilsToU32("a"))
/* */
inter.UtilsInterpreterPuse()
///////////////////////////////
// YAML common
config := ConfigParserYAML{}