llcppsymg:gendylib path test

llcppsymg:headerpath test
This commit is contained in:
luoliwoshang
2024-09-25 11:56:43 +08:00
parent a83f7a822e
commit ffa823f748
7 changed files with 294 additions and 53 deletions

View File

@@ -0,0 +1,51 @@
package main
import (
"fmt"
"github.com/goplus/llgo/chore/_xtool/llcppsymg/dylib"
)
func TestGenDylibPaths() {
fmt.Println("=== Test GenDylibPaths ===")
testCases := []struct {
name string
input string
}{
{
name: "Lua library",
input: "-L/opt/homebrew/lib -llua -lm",
},
{
name: "SQLite library",
input: "-L/opt/homebrew/opt/sqlite/lib -lsqlite3",
},
{
name: "INIReader library",
input: "-L/opt/homebrew/Cellar/inih/58/lib -lINIReader",
},
{
name: "No valid library",
input: "-L/opt/homebrew/lib",
},
}
for _, tc := range testCases {
fmt.Printf("Test case: %s\n", tc.name)
fmt.Printf("Input: %s\n", tc.input)
result, err := dylib.GenDylibPaths(tc.input)
if err != nil {
fmt.Printf("Error: %v\n", err)
} else {
fmt.Printf("Output: %v\n", result)
}
fmt.Println()
}
}
func main() {
TestGenDylibPaths()
}

View File

@@ -0,0 +1,22 @@
#stdout
=== Test GenDylibPaths ===
Test case: Lua library
Input: -L/opt/homebrew/lib -llua -lm
Output: [/opt/homebrew/lib/liblua.dylib /opt/homebrew/lib/libm.dylib]
Test case: SQLite library
Input: -L/opt/homebrew/opt/sqlite/lib -lsqlite3
Output: [/opt/homebrew/opt/sqlite/lib/libsqlite3.dylib]
Test case: INIReader library
Input: -L/opt/homebrew/Cellar/inih/58/lib -lINIReader
Output: [/opt/homebrew/Cellar/inih/58/lib/libINIReader.dylib]
Test case: No valid library
Input: -L/opt/homebrew/lib
Error: failed to parse pkg-config output: -L/opt/homebrew/lib
#stderr
#exit 0