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.
11
func TestDecodePoString(t *testing.T) {
12
if s := decodePoString(poStrEncode); s != poStrDecode {
13
t.Fatalf(`expect = %s got = %s`, poStrDecode, s)
17
func TestEncodePoString(t *testing.T) {
18
if s := encodePoString(poStrDecode); s != poStrEncodeStd {
19
t.Fatalf(`expect = %s; got = %s`, poStrEncodeStd, s)
23
const poStrEncode = `# noise
25
"Project-Id-Version: Poedit 1.5\n"
26
"Report-Msgid-Bugs-To: poedit@googlegroups.com\n"
27
"POT-Creation-Date: 2012-07-30 10:34+0200\n"
28
"PO-Revision-Date: 2013-02-24 21:00+0800\n"
29
"Last-Translator: Christopher Meng <trans@cicku.me>\n"
32
"Content-Type: text/plain; charset=UTF-8\n"
33
"Content-Transfer-Encoding: 8bit\n"
34
"Plural-Forms: nplurals=1; plural=0;\n"
35
"X-Generator: Poedit 1.5.5\n"
42
const poStrEncodeStd = `"Project-Id-Version: Poedit 1.5\n"
43
"Report-Msgid-Bugs-To: poedit@googlegroups.com\n"
44
"POT-Creation-Date: 2012-07-30 10:34+0200\n"
45
"PO-Revision-Date: 2013-02-24 21:00+0800\n"
46
"Last-Translator: Christopher Meng <trans@cicku.me>\n"
49
"Content-Type: text/plain; charset=UTF-8\n"
50
"Content-Transfer-Encoding: 8bit\n"
51
"Plural-Forms: nplurals=1; plural=0;\n"
52
"X-Generator: Poedit 1.5.5\n"
53
"TestPoString: abc123\n"
56
const poStrDecode = `Project-Id-Version: Poedit 1.5
57
Report-Msgid-Bugs-To: poedit@googlegroups.com
58
POT-Creation-Date: 2012-07-30 10:34+0200
59
PO-Revision-Date: 2013-02-24 21:00+0800
60
Last-Translator: Christopher Meng <trans@cicku.me>
63
Content-Type: text/plain; charset=UTF-8
64
Content-Transfer-Encoding: 8bit
65
Plural-Forms: nplurals=1; plural=0;
66
X-Generator: Poedit 1.5.5