-
-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
133 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package lib | ||
|
||
import ( | ||
"os" | ||
"path/filepath" | ||
"testing" | ||
) | ||
|
||
func TestExpandModelPath(t *testing.T) { | ||
// Create a temporary directory for testing | ||
tempDir := t.TempDir() | ||
modelName := "test_model" | ||
modelPath := filepath.Join(tempDir, modelName) | ||
modelJSONPath := modelPath + ".json" | ||
|
||
// Test case 1: Both ONNX and JSON files are present | ||
os.WriteFile(modelPath, []byte("dummy ONNX model"), 0644) | ||
os.WriteFile(modelJSONPath, []byte("dummy JSON"), 0644) | ||
|
||
result, err := ExpandModelPath(modelName, tempDir) | ||
if err != nil || result != modelPath { | ||
t.Errorf("Expected %s, got %s, error: %v", modelPath, result, err) | ||
} | ||
|
||
// Test case 2: ONNX file is present, but JSON file is missing | ||
os.Remove(modelJSONPath) // remove the JSON file | ||
|
||
result, err = ExpandModelPath(modelName, tempDir) | ||
if err == nil || result != "" { | ||
t.Errorf("Expected error for missing JSON file, got: %v, result: %s", err, result) | ||
} | ||
|
||
// Test case 3: Model not found | ||
result, err = ExpandModelPath("non_existent_model", tempDir) | ||
if err == nil || result != "" { | ||
t.Errorf("Expected error for non-existent model, got: %v, result: %s", err, result) | ||
} | ||
|
||
// Test case 4: Model found in the default model directory | ||
modelNameInDir := "another_model" | ||
modelPathInDir := filepath.Join(tempDir, modelNameInDir) | ||
modelJSONPathInDir := modelPathInDir + ".json" | ||
|
||
os.WriteFile(modelPathInDir, []byte("dummy ONNX model"), 0644) | ||
os.WriteFile(modelJSONPathInDir, []byte("dummy JSON"), 0644) | ||
|
||
result, err = ExpandModelPath(modelNameInDir, tempDir) | ||
if err != nil || result != modelPathInDir { | ||
t.Errorf("Expected %s, got %s, error: %v", modelPathInDir, result, err) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
彩虹,又稱天弓、天虹、絳等,簡稱虹,是氣象中的一種光學現象,當太陽 光照射到半空中的水滴,光線被折射及反射,在天空上形成拱形的七彩光譜,由外 圈至内圈呈紅、橙、黃、綠、蓝、靛蓝、堇紫七种颜色(霓虹則相反)。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters