Skip to content

Commit

Permalink
Adds tests for multibyte string
Browse files Browse the repository at this point in the history
  • Loading branch information
kzykhys committed Jan 15, 2014
1 parent ead9c02 commit 593b47f
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 0 deletions.
17 changes: 17 additions & 0 deletions test/KzykHys/CsvParser/CsvParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,4 +92,21 @@ public function testOffsetAndLimitOption()
$this->assertEquals(array(1 => array(4, 5, 6), 2 => array(7, 8, 9)), $parser->parse());
}

public function testMultibyteString()
{
$dir = __DIR__ . '/Resources/csv/';
$files = array(
$dir . '6-cp932-excel-win.csv', $dir . '6-cp932-excel-mac.csv'
);
$expected = json_decode(file_get_contents($dir . '6-cp932-excel.json'));

foreach ($files as $file) {
$fromFile = CsvParser::fromFile($file)->parse();
$fromString = CsvParser::fromString(file_get_contents($file))->parse();
$this->assertEquals($fromFile, $fromString);
$this->assertEquals($expected, $fromFile);
}

}

}
1 change: 1 addition & 0 deletions test/KzykHys/CsvParser/Resources/csv/6-cp932-excel-mac.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2013�N11��12��,�K�N,135.001,���@�̎����́A���p���郉�C�Z���X�ɐN�Q���肱�Ƃɂ�����ҏW�@�I�łłĂ��܂�����2013�N11��13��,�K�N,136.001,���@�̎����́A���p���郉�C�Z���X�ɐN�Q���肱�Ƃɂ�����ҏW�@�I�łłĂ��܂�����,,,,,,,,,,,,
Expand Down
6 changes: 6 additions & 0 deletions test/KzykHys/CsvParser/Resources/csv/6-cp932-excel-win.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
2013�N11��12��,�K�N,135.001,���@�̎����́A���p���郉�C�Z���X�ɐN�Q���肱�Ƃɂ�����ҏW�@�I�łłĂ��܂�����
2013�N11��13��,�K�N,136.001,���@�̎����́A���p���郉�C�Z���X�ɐN�Q���肱�Ƃɂ�����ҏW�@�I�łłĂ��܂�����
,,,
,,,
,,,
,,,
8 changes: 8 additions & 0 deletions test/KzykHys/CsvParser/Resources/csv/6-cp932-excel.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[
["2013年11月12日", "薔薇", 135.001, "方法の資料は、引用するライセンスに侵害ありことにおける編集法的ででていませある"],
["2013年11月13日", "薔薇", 136.001, "方法の資料は、引用するライセンスに侵害ありことにおける編集法的ででていませある"],
["","","",""],
["","","",""],
["","","",""],
["","","",""]
]

0 comments on commit 593b47f

Please sign in to comment.