]> Sergey Matveev's repositories - go-opus.git/commitdiff
Unit test for opus error string
authorHraban Luyat <hraban@0brg.net>
Sun, 5 Jul 2015 11:35:02 +0000 (12:35 +0100)
committerHraban Luyat <hraban@0brg.net>
Sun, 5 Jul 2015 11:35:02 +0000 (12:35 +0100)
opus_test.go

index 5cc3adcbcf4728f958b9ded6c849b0c6f7f6e694..bdab063c6d98bdd0032125e9338ffd372f0b9445 100644 (file)
@@ -38,6 +38,16 @@ func TestDecoderNew(t *testing.T) {
        }
 }
 
+func TestOpuserr(t *testing.T) {
+       // I scooped this -1 up from opus_defines.h, it's OPUS_BAD_ARG. Not pretty,
+       // but it's better than not testing at all. Again, accessing #defines from
+       // CGO is not possible.
+       err := opuserr(-1)
+       if err.Error() != "opus: invalid argument" {
+               t.Errorf("Expected \"invalid argument\" error message for error code -1: %v")
+       }
+}
+
 func addSineFloat32(buf []float32, sampleRate int, freq float64) {
        factor := 2 * math.Pi * freq / float64(sampleRate)
        for i := range buf {