llcppsymg:symbol generate test

llcppsymg:symbo test

llcppsymg:exist symb file test

llcppsymg:GenSymbolTabledata

llcppsymg:GenSymbolTableData test

llcppsymg:full symg operation test
This commit is contained in:
luoliwoshang
2024-09-25 14:59:02 +08:00
parent 174fdd40da
commit 944133de6e
13 changed files with 499 additions and 139 deletions

View File

@@ -0,0 +1,71 @@
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()
}

View File

@@ -0,0 +1,23 @@
#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