...

Source file src/github.com/chai2010/gettext-go/po/util_test.go

Documentation: github.com/chai2010/gettext-go/po

     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 po
     6  
     7  import (
     8  	"testing"
     9  )
    10  
    11  func TestDecodePoString(t *testing.T) {
    12  	if s := decodePoString(poStrEncode); s != poStrDecode {
    13  		t.Fatalf(`expect = %s got = %s`, poStrDecode, s)
    14  	}
    15  }
    16  
    17  func TestEncodePoString(t *testing.T) {
    18  	if s := encodePoString(poStrDecode); s != poStrEncodeStd {
    19  		t.Fatalf(`expect = %s; got = %s`, poStrEncodeStd, s)
    20  	}
    21  }
    22  
    23  const poStrEncode = `# noise
    24  123456789
    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"
    30  "Language-Team: \n"
    31  "MIME-Version: 1.0\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"
    36  "TestPoString: abc"
    37  "123\n"
    38  >>
    39  123456???
    40  `
    41  
    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"
    47  "Language-Team: \n"
    48  "MIME-Version: 1.0\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"
    54  `
    55  
    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>
    61  Language-Team: 
    62  MIME-Version: 1.0
    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
    67  TestPoString: abc123
    68  `
    69  

View as plain text