-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathencoder_test.go
57 lines (52 loc) · 1.33 KB
/
encoder_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// Copyright 2013 ChaiShushan <chaishushan{AT}gmail.com>. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package mo
import (
"reflect"
"sort"
"testing"
)
func TestFile_Data(t *testing.T) {
f, err := Load(testMoFile.Data())
if err != nil {
t.Fatal(err)
}
if a, b := len(f.Messages), len(testMoFile.Messages); a != b {
t.Logf("size not equal: expect = %d, got = %d", b, a)
}
for i, v := range f.Messages {
if !reflect.DeepEqual(&v, &testMoFile.Messages[i]) {
t.Fatalf("%d: expect = %v, got = %v", i, testMoFile.Messages[i], v)
}
}
}
func init() {
sort.Slice(testMoFile.Messages, func(i, j int) bool {
return testMoFile.Messages[i].less(&testMoFile.Messages[j])
})
}
var testMoFile = &File{
Messages: []Message{
Message{
MsgContext: "main.init",
MsgId: "Gettext in init.",
MsgStr: "Init函数中的Gettext.",
},
Message{
MsgContext: "main.main",
MsgId: "Hello, world!",
MsgStr: "你好, 世界!",
},
Message{
MsgContext: "main.func",
MsgId: "Gettext in func.",
MsgStr: "闭包函数中的Gettext.",
},
Message{
MsgContext: "code.google.com/p/gettext-go/examples/hi.SayHi",
MsgId: "pkg hi: Hello, world!",
MsgStr: "来自\"Hi\"包的问候: 你好, 世界!",
},
},
}