assets builder tools (#39)
Reviewed-on: #39 Reviewed-by: xtul <mpiasecki720@protonmail.com>
This commit was merged in pull request #39.
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
package assets
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestCheckMDL(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
// Uncompiled ASCII model with a name mismatch.
|
||||
bad := filepath.Join(dir, "foo.mdl")
|
||||
if err := os.WriteFile(bad, []byte("newmodel wrong\nbeginmodelgeom wrong\nendmodelgeom wrong\ndonemodel wrong\n"), 0o644); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
var out, errw bytes.Buffer
|
||||
if code := runCheckMDL([]string{dir}, &out, &errw); code != exitFail {
|
||||
t.Fatalf("bad mdl exit = %d, want %d\n%s", code, exitFail, errw.String())
|
||||
}
|
||||
|
||||
// A binary (compiled) model is fine.
|
||||
good := t.TempDir()
|
||||
if err := os.WriteFile(filepath.Join(good, "bar.mdl"), []byte("\x00\x00compiled binary blob"), 0o644); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
out.Reset()
|
||||
errw.Reset()
|
||||
if code := runCheckMDL([]string{good}, &out, &errw); code != exitOK {
|
||||
t.Fatalf("binary mdl exit = %d, want %d\n%s", code, exitOK, errw.String())
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user