chore:remove folder
This commit is contained in:
@@ -1,51 +0,0 @@
|
||||
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()
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
#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
|
||||
@@ -1,71 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/goplus/llgo/chore/_xtool/llcppsymg/header"
|
||||
)
|
||||
|
||||
func TestGenHeaderFilePath() {
|
||||
fmt.Println("=== Test GenHeaderFilePath ===")
|
||||
|
||||
tempDir := os.TempDir()
|
||||
tempFile1 := filepath.Join(tempDir, "test1.h")
|
||||
tempFile2 := filepath.Join(tempDir, "test2.h")
|
||||
os.Create(tempFile1)
|
||||
os.Create(tempFile2)
|
||||
defer os.Remove(tempFile1)
|
||||
defer os.Remove(tempFile2)
|
||||
|
||||
testCases := []struct {
|
||||
name string
|
||||
cflags string
|
||||
files []string
|
||||
}{
|
||||
{
|
||||
name: "Valid files",
|
||||
cflags: "-I" + tempDir,
|
||||
files: []string{"test1.h", "test2.h"},
|
||||
},
|
||||
{
|
||||
name: "Mixed existing and non-existing files",
|
||||
cflags: "-I" + tempDir,
|
||||
files: []string{"test1.h", "nonexistent.h"},
|
||||
},
|
||||
{
|
||||
name: "No existing files",
|
||||
cflags: "-I" + tempDir,
|
||||
files: []string{"nonexistent1.h", "nonexistent2.h"},
|
||||
},
|
||||
{
|
||||
name: "Empty file list",
|
||||
cflags: "-I/usr/include",
|
||||
files: []string{},
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
fmt.Printf("Test case: %s\n", tc.name)
|
||||
fmt.Printf("Input files: %v\n", tc.files)
|
||||
|
||||
result, err := header.GenHeaderFilePath(tc.cflags, tc.files)
|
||||
|
||||
if err != nil {
|
||||
fmt.Printf("Error: %v\n", err)
|
||||
}
|
||||
if result != nil {
|
||||
relativeResult := make([]string, len(result))
|
||||
for i, path := range result {
|
||||
relativeResult[i] = filepath.Base(path)
|
||||
}
|
||||
fmt.Printf("Output: %v\n", relativeResult)
|
||||
}
|
||||
fmt.Println()
|
||||
}
|
||||
}
|
||||
|
||||
func main() {
|
||||
TestGenHeaderFilePath()
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
#stdout
|
||||
=== Test GenHeaderFilePath ===
|
||||
Test case: Valid files
|
||||
Input files: [test1.h test2.h]
|
||||
Output: [test1.h test2.h]
|
||||
|
||||
Test case: Mixed existing and non-existing files
|
||||
Input files: [test1.h nonexistent.h]
|
||||
Error: some files not found or inaccessible: [file not found: nonexistent.h]
|
||||
Output: [test1.h]
|
||||
|
||||
Test case: No existing files
|
||||
Input files: [nonexistent1.h nonexistent2.h]
|
||||
Error: some files not found or inaccessible: [file not found: nonexistent1.h file not found: nonexistent2.h]
|
||||
|
||||
Test case: Empty file list
|
||||
Input files: []
|
||||
Error: no valid header files
|
||||
|
||||
|
||||
#stderr
|
||||
|
||||
#exit 0
|
||||
@@ -1,4 +1,22 @@
|
||||
#stdout
|
||||
=== Test GenHeaderFilePath ===
|
||||
Test case: Valid files
|
||||
Input files: [test1.h test2.h]
|
||||
Output: [test1.h test2.h]
|
||||
|
||||
Test case: Mixed existing and non-existing files
|
||||
Input files: [test1.h nonexistent.h]
|
||||
Error: some files not found or inaccessible: [file not found: nonexistent.h]
|
||||
Output: [test1.h]
|
||||
|
||||
Test case: No existing files
|
||||
Input files: [nonexistent1.h nonexistent2.h]
|
||||
Error: some files not found or inaccessible: [file not found: nonexistent1.h file not found: nonexistent2.h]
|
||||
|
||||
Test case: Empty file list
|
||||
Input files: []
|
||||
Error: no valid header files
|
||||
|
||||
=== Test NewSymbolProcessor ===
|
||||
Before: No prefixes After: Prefixes: [lua_ luaL_]
|
||||
|
||||
|
||||
@@ -2,12 +2,15 @@ package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"sort"
|
||||
|
||||
"github.com/goplus/llgo/chore/_xtool/llcppsymg/parse"
|
||||
)
|
||||
|
||||
func main() {
|
||||
TestGenHeaderFilePath()
|
||||
TestNewSymbolProcessor()
|
||||
TestRemovePrefix()
|
||||
TestToGoName()
|
||||
@@ -16,6 +19,64 @@ func main() {
|
||||
TestParseHeaderFile()
|
||||
}
|
||||
|
||||
func TestGenHeaderFilePath() {
|
||||
fmt.Println("=== Test GenHeaderFilePath ===")
|
||||
|
||||
tempDir := os.TempDir()
|
||||
tempFile1 := filepath.Join(tempDir, "test1.h")
|
||||
tempFile2 := filepath.Join(tempDir, "test2.h")
|
||||
os.Create(tempFile1)
|
||||
os.Create(tempFile2)
|
||||
defer os.Remove(tempFile1)
|
||||
defer os.Remove(tempFile2)
|
||||
|
||||
testCases := []struct {
|
||||
name string
|
||||
cflags string
|
||||
files []string
|
||||
}{
|
||||
{
|
||||
name: "Valid files",
|
||||
cflags: "-I" + tempDir,
|
||||
files: []string{"test1.h", "test2.h"},
|
||||
},
|
||||
{
|
||||
name: "Mixed existing and non-existing files",
|
||||
cflags: "-I" + tempDir,
|
||||
files: []string{"test1.h", "nonexistent.h"},
|
||||
},
|
||||
{
|
||||
name: "No existing files",
|
||||
cflags: "-I" + tempDir,
|
||||
files: []string{"nonexistent1.h", "nonexistent2.h"},
|
||||
},
|
||||
{
|
||||
name: "Empty file list",
|
||||
cflags: "-I/usr/include",
|
||||
files: []string{},
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
fmt.Printf("Test case: %s\n", tc.name)
|
||||
fmt.Printf("Input files: %v\n", tc.files)
|
||||
|
||||
result, err := parse.GenHeaderFilePath(tc.cflags, tc.files)
|
||||
|
||||
if err != nil {
|
||||
fmt.Printf("Error: %v\n", err)
|
||||
}
|
||||
if result != nil {
|
||||
relativeResult := make([]string, len(result))
|
||||
for i, path := range result {
|
||||
relativeResult[i] = filepath.Base(path)
|
||||
}
|
||||
fmt.Printf("Output: %v\n", relativeResult)
|
||||
}
|
||||
fmt.Println()
|
||||
}
|
||||
}
|
||||
|
||||
func TestNewSymbolProcessor() {
|
||||
fmt.Println("=== Test NewSymbolProcessor ===")
|
||||
process := parse.NewSymbolProcessor([]string{"lua_", "luaL_"})
|
||||
|
||||
@@ -1,4 +1,21 @@
|
||||
#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
|
||||
|
||||
=== Test GetCommonSymbols ===
|
||||
|
||||
Test Case: Lua symbols
|
||||
|
||||
@@ -12,10 +12,50 @@ import (
|
||||
)
|
||||
|
||||
func main() {
|
||||
TestGenDylibPaths()
|
||||
TestGetCommonSymbols()
|
||||
TestReadExistingSymbolTable()
|
||||
TestGenSymbolTableData()
|
||||
}
|
||||
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 := symbol.GenDylibPaths(tc.input)
|
||||
|
||||
if err != nil {
|
||||
fmt.Printf("Error: %v\n", err)
|
||||
} else {
|
||||
fmt.Printf("Output: %v\n", result)
|
||||
}
|
||||
fmt.Println()
|
||||
}
|
||||
}
|
||||
func TestGetCommonSymbols() {
|
||||
fmt.Println("=== Test GetCommonSymbols ===")
|
||||
testCases := []struct {
|
||||
@@ -67,7 +107,6 @@ func TestGetCommonSymbols() {
|
||||
}
|
||||
fmt.Println()
|
||||
}
|
||||
|
||||
func TestReadExistingSymbolTable() {
|
||||
fmt.Println("=== Test ReadExistingSymbolTable ===")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user