@@ -114,10 +114,10 @@ func TestMatchMessageType(t *testing.T) {
114114
115115func TestAutoDecode (t * testing.T ) {
116116 _ , err := AutoDecode ([]byte {0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 })
117- if err != zlib . ErrHeader {
117+ if err == nil {
118118 t .Error ()
119119 }
120- _ , err = AutoDecode ([]byte {0 })
120+ _ , err = AutoDecode ([]byte {78 , 0 })
121121 if err == nil {
122122 t .Error ()
123123 }
@@ -137,6 +137,22 @@ func TestAutoDecode(t *testing.T) {
137137 if string (bytes ) != "rocketmq-client-go" {
138138 t .Error ()
139139 }
140+ // lz4
141+ bytes , err = AutoDecode ([]byte {4 , 34 , 77 , 24 , 100 , 112 , 185 , 18 , 0 , 0 , 128 , 114 , 111 , 99 , 107 , 101 , 116 , 109 , 113 , 45 , 99 , 108 , 105 , 101 , 110 , 116 , 45 , 103 , 111 , 0 , 0 , 0 , 0 , 248 , 183 , 23 , 47 })
142+ if err != nil {
143+ t .Error ()
144+ }
145+ if string (bytes ) != "rocketmq-client-go" {
146+ t .Error ()
147+ }
148+ // zstd
149+ bytes , err = AutoDecode ([]byte {40 , 181 , 47 , 253 , 32 , 18 , 145 , 0 , 0 , 114 , 111 , 99 , 107 , 101 , 116 , 109 , 113 , 45 , 99 , 108 , 105 , 101 , 110 , 116 , 45 , 103 , 111 })
150+ if err != nil {
151+ t .Error ()
152+ }
153+ if string (bytes ) != "rocketmq-client-go" {
154+ t .Error ()
155+ }
140156}
141157
142158func TestGZIPDecode (t * testing.T ) {
@@ -167,6 +183,34 @@ func TestZlibDecode(t *testing.T) {
167183 }
168184}
169185
186+ func TestLz4Decode (t * testing.T ) {
187+ _ , err := Lz4Decode ([]byte {0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 })
188+ if err == nil {
189+ t .Error ()
190+ }
191+ bytes , err := Lz4Decode ([]byte {4 , 34 , 77 , 24 , 100 , 112 , 185 , 18 , 0 , 0 , 128 , 114 , 111 , 99 , 107 , 101 , 116 , 109 , 113 , 45 , 99 , 108 , 105 , 101 , 110 , 116 , 45 , 103 , 111 , 0 , 0 , 0 , 0 , 248 , 183 , 23 , 47 })
192+ if err != nil {
193+ t .Error ()
194+ }
195+ if string (bytes ) != "rocketmq-client-go" {
196+ t .Error ()
197+ }
198+ }
199+
200+ func TestZstdDecode (t * testing.T ) {
201+ _ , err := ZstdDecode ([]byte {0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 })
202+ if err == nil {
203+ t .Error ()
204+ }
205+ bytes , err := ZstdDecode ([]byte {40 , 181 , 47 , 253 , 32 , 18 , 145 , 0 , 0 , 114 , 111 , 99 , 107 , 101 , 116 , 109 , 113 , 45 , 99 , 108 , 105 , 101 , 110 , 116 , 45 , 103 , 111 })
206+ if err != nil {
207+ t .Error ()
208+ }
209+ if string (bytes ) != "rocketmq-client-go" {
210+ t .Error ()
211+ }
212+ }
213+
170214func TestSelectAnAddress (t * testing.T ) {
171215 if SelectAnAddress (nil ) != nil {
172216 t .Error ()
0 commit comments