~juju-qa/ubuntu/xenial/juju/xenial-2.0-beta3

« back to all changes in this revision

Viewing changes to src/github.com/chai2010/gettext-go/gettext/mo/encoder_test.go

  • Committer: Martin Packman
  • Date: 2016-03-30 19:31:08 UTC
  • mfrom: (1.1.41)
  • Revision ID: martin.packman@canonical.com-20160330193108-h9iz3ak334uk0z5r
Merge new upstream source 2.0~beta3

Show diffs side-by-side

added added

removed removed

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