llcppsymg:config & clangutil test
llcppsymg:clangutil test
This commit is contained in:
63
chore/_xtool/llcppsymg/_cmptest/config_test/config.go
Normal file
63
chore/_xtool/llcppsymg/_cmptest/config_test/config.go
Normal file
@@ -0,0 +1,63 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/goplus/llgo/chore/_xtool/llcppsymg/config"
|
||||
)
|
||||
|
||||
func main() {
|
||||
TestGetConf()
|
||||
}
|
||||
|
||||
func TestGetConf() {
|
||||
testCases := []struct {
|
||||
name string
|
||||
input string
|
||||
}{
|
||||
{
|
||||
name: "SQLite configuration",
|
||||
input: `{
|
||||
"name": "sqlite",
|
||||
"cflags": "-I/opt/homebrew/opt/sqlite/include",
|
||||
"include": ["sqlite3.h"],
|
||||
"libs": "-L/opt/homebrew/opt/sqlite/lib -lsqlite3",
|
||||
"trimPrefixes": ["sqlite3_"],
|
||||
"cplusplus": false
|
||||
}`,
|
||||
},
|
||||
{
|
||||
name: "Lua configuration",
|
||||
input: `{
|
||||
"name": "lua",
|
||||
"cflags": "-I/opt/homebrew/include/lua",
|
||||
"include": ["lua.h"],
|
||||
"libs": "-L/opt/homebrew/lib -llua -lm",
|
||||
"trimPrefixes": ["lua_", "lua_"],
|
||||
"cplusplus": false
|
||||
}`,
|
||||
},
|
||||
{
|
||||
name: "Invalid JSON",
|
||||
input: `{invalid json}`,
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
fmt.Printf("=== Test case: %s ===\n", tc.name)
|
||||
result, err := config.GetConf([]byte(tc.input))
|
||||
|
||||
if err != nil {
|
||||
fmt.Println("Error:", err.Error())
|
||||
} else {
|
||||
fmt.Println("Name:", result.Config.Name)
|
||||
fmt.Println("CFlags:", result.Config.CFlags)
|
||||
fmt.Println("Libs:", result.Config.Libs)
|
||||
fmt.Println("Include:", strings.Join(result.Config.Include, ", "))
|
||||
fmt.Println("TrimPrefixes:", strings.Join(result.Config.TrimPrefixes, ", "))
|
||||
fmt.Println("Cplusplus:", result.Config.Cplusplus)
|
||||
}
|
||||
fmt.Println()
|
||||
}
|
||||
}
|
||||
24
chore/_xtool/llcppsymg/_cmptest/config_test/llgo.expect
Normal file
24
chore/_xtool/llcppsymg/_cmptest/config_test/llgo.expect
Normal file
@@ -0,0 +1,24 @@
|
||||
#stdout
|
||||
=== Test case: SQLite configuration ===
|
||||
Name: sqlite
|
||||
CFlags: -I/opt/homebrew/opt/sqlite/include
|
||||
Libs: -L/opt/homebrew/opt/sqlite/lib -lsqlite3
|
||||
Include: sqlite3.h
|
||||
TrimPrefixes: sqlite3_
|
||||
Cplusplus: false
|
||||
|
||||
=== Test case: Lua configuration ===
|
||||
Name: lua
|
||||
CFlags: -I/opt/homebrew/include/lua
|
||||
Libs: -L/opt/homebrew/lib -llua -lm
|
||||
Include: lua.h
|
||||
TrimPrefixes: lua_, lua_
|
||||
Cplusplus: false
|
||||
|
||||
=== Test case: Invalid JSON ===
|
||||
Error: failed to parse config
|
||||
|
||||
|
||||
#stderr
|
||||
|
||||
#exit 0
|
||||
Reference in New Issue
Block a user