forked from openimsdk/open-im-server
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/v3.8-js-sdk-only'
# Conflicts: # go.mod # go.sum
- Loading branch information
Showing
12 changed files
with
157 additions
and
43 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
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,48 @@ | ||
package msggateway | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
func TestGobEncoder_Encode(t *testing.T) { | ||
encoder := NewGobEncoder() | ||
|
||
// 测试用例1: 编码 []byte 数据 | ||
inputData := []byte("test data") | ||
encodedData, err := encoder.Encode(inputData) | ||
if err != nil { | ||
t.Fatalf("expected no error, got %v", err) | ||
} | ||
if string(encodedData) != string(inputData) { | ||
t.Fatalf("expected encoded data to be '%s', got '%s'", inputData, encodedData) | ||
} | ||
|
||
// 测试用例2: 编码非 []byte 数据 | ||
nonByteData := "string data" | ||
_, err = encoder.Encode(nonByteData) | ||
if err == nil { | ||
t.Fatalf("expected an error when encoding non-byte data, got none") | ||
} | ||
} | ||
|
||
func TestGobEncoder_Decode(t *testing.T) { | ||
encoder := NewGobEncoder() | ||
|
||
// 测试用例1: 解码到 []byte 数据 | ||
encodedData := []byte("test data") | ||
var decodedData []byte | ||
err := encoder.Decode(encodedData, &decodedData) | ||
if err != nil { | ||
t.Fatalf("expected no error, got %v", err) | ||
} | ||
if string(decodedData) != string(encodedData) { | ||
t.Fatalf("expected decoded data to be '%s', got '%s'", encodedData, decodedData) | ||
} | ||
|
||
// 测试用例2: 解码到非 []byte 数据 | ||
var nonByteData string | ||
err = encoder.Decode(encodedData, &nonByteData) | ||
if err == nil { | ||
t.Fatalf("expected an error when decoding to non-byte data, got none") | ||
} | ||
} |
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
Oops, something went wrong.