summaryrefslogtreecommitdiffhomepage
path: root/pkg/p9/messages_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/p9/messages_test.go')
-rw-r--r--pkg/p9/messages_test.go37
1 files changed, 37 insertions, 0 deletions
diff --git a/pkg/p9/messages_test.go b/pkg/p9/messages_test.go
index dfb41bb76..c0d65d82c 100644
--- a/pkg/p9/messages_test.go
+++ b/pkg/p9/messages_test.go
@@ -15,6 +15,7 @@
package p9
import (
+ "fmt"
"reflect"
"testing"
)
@@ -186,6 +187,13 @@ func TestEncodeDecode(t *testing.T) {
&Rxattrwalk{
Size: 1,
},
+ &Txattrcreate{
+ FID: 1,
+ Name: "a",
+ AttrSize: 2,
+ Flags: 3,
+ },
+ &Rxattrcreate{},
&Treaddir{
Directory: 1,
Offset: 2,
@@ -389,3 +397,32 @@ func TestEncodeDecode(t *testing.T) {
}
}
}
+
+func TestMessageStrings(t *testing.T) {
+ for typ, fn := range messageRegistry {
+ name := fmt.Sprintf("%+v", typ)
+ t.Run(name, func(t *testing.T) {
+ defer func() { // Ensure no panic.
+ if r := recover(); r != nil {
+ t.Errorf("printing %s failed: %v", name, r)
+ }
+ }()
+ m := fn()
+ _ = fmt.Sprintf("%v", m)
+ err := ErrInvalidMsgType{typ}
+ _ = err.Error()
+ })
+ }
+}
+
+func TestRegisterDuplicate(t *testing.T) {
+ defer func() {
+ if r := recover(); r == nil {
+ // We expect a panic.
+ t.FailNow()
+ }
+ }()
+
+ // Register a duplicate.
+ register(&Rlerror{})
+}