-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathformat_support_test.go
More file actions
180 lines (157 loc) · 4.24 KB
/
format_support_test.go
File metadata and controls
180 lines (157 loc) · 4.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
package assimp
import (
"fmt"
"testing"
)
func TestGetSupportedImporterCount(t *testing.T) {
count := GetSupportedImporterCount()
if count <= 0 {
t.Errorf("Expected positive number of supported importers, got %d", count)
}
t.Logf("Assimp supports %d import formats", count)
}
func TestGetImportFormatDescription(t *testing.T) {
count := GetSupportedImporterCount()
if count == 0 {
t.Skip("No importers available")
}
// Test valid indices
for i := 0; i < count && i < 3; i++ {
desc := GetImportFormatDescription(i)
if desc == nil {
t.Errorf("Expected non-nil description for index %d", i)
continue
}
t.Logf("Importer %d: %s supports extensions: %s", i, desc.Name, desc.FileExtensions)
}
// Test invalid indices
invalidDesc := GetImportFormatDescription(-1)
if invalidDesc != nil {
t.Error("Expected nil description for negative index")
}
invalidDesc = GetImportFormatDescription(count)
if invalidDesc != nil {
t.Error("Expected nil description for index >= count")
}
}
func TestIsFormatSupported(t *testing.T) {
tests := []struct {
extension string
expected bool
}{
{"obj", true},
{"OBJ", true},
{"fbx", true},
{"FBX", true},
{"stl", true},
{"STL", true},
{"gltf", true},
{"glb", true}, // Note: GLB might be handled by GLTF importer
{"ply", true},
{"3ds", true},
{"xyz", false}, // unlikely to be supported
{"unsupported", false},
{"", false}, // empty string should return false
}
for _, test := range tests {
supported := IsFormatSupported(test.extension)
if supported != test.expected {
if test.expected {
t.Errorf("Expected format %s to be supported, but it isn't", test.extension)
} else {
t.Errorf("Expected format %s to be unsupported, but it is", test.extension)
}
} else {
t.Logf("Format %s support check: %v (expected: %v)", test.extension, supported, test.expected)
}
}
// Test with leading dot
withDot := IsFormatSupported(".obj")
if !withDot {
t.Error("Expected .obj (with leading dot) to be supported")
}
}
func TestGetAllSupportedFormats(t *testing.T) {
formats := GetAllSupportedFormats()
if len(formats) == 0 {
t.Error("Expected at least one supported format")
}
t.Logf("Found %d supported file extensions:", len(formats))
for i, ext := range formats {
if i >= 10 { // Limit output for readability
t.Log("...")
break
}
t.Logf(" %s", ext)
}
// Check that common formats are included
commonFormats := []string{"obj", "fbx", "stl", "gltf", "3ds"}
for _, format := range commonFormats {
found := false
for _, supported := range formats {
if supported == format {
found = true
break
}
}
if !found {
t.Errorf("Expected %s to be in supported formats", format)
}
}
}
func TestGetImporterInfo(t *testing.T) {
// Test with a known supported format
info := GetImporterInfo("obj")
if info == nil {
t.Error("Expected non-nil info for obj format")
} else {
t.Logf("OBJ Importer Info:")
t.Logf(" Name: %s", info.Name)
t.Logf(" Extensions: %s", info.FileExtensions)
t.Logf(" Author: %s", info.Author)
}
// Test with unsupported format
info = GetImporterInfo("unsupported")
if info != nil {
t.Error("Expected nil info for unsupported format")
}
// Test with leading dot
info = GetImporterInfo(".fbx")
if info == nil {
t.Error("Expected non-nil info for .fbx format")
}
}
func ExampleIsFormatSupported() {
fmt.Println("Checking format support:")
formats := []string{"obj", "fbx", "stl", "xyz"}
for _, format := range formats {
supported := IsFormatSupported(format)
fmt.Printf("%s: %v\n", format, supported)
}
// Output:
// Checking format support:
// obj: true
// fbx: true
// stl: true
// xyz: false
}
func ExampleGetAllSupportedFormats() {
formats := GetAllSupportedFormats()
fmt.Printf("Total supported formats: %d\n", len(formats))
// Show first 5 formats
for i := 0; i < 5 && i < len(formats); i++ {
fmt.Printf(" %s\n", formats[i])
}
// Output will vary based on Assimp version
}
func ExampleGetImportFormatDescription() {
count := GetSupportedImporterCount()
if count > 0 {
desc := GetImportFormatDescription(0)
if desc != nil {
fmt.Printf("First importer: %s\n", desc.Name)
fmt.Printf("Extensions: %s\n", desc.FileExtensions)
}
}
// Output will vary based on Assimp version
}