Skip to content

Commit 593b47f

Browse files
committed
Adds tests for multibyte string
1 parent ead9c02 commit 593b47f

File tree

4 files changed

+32
-0
lines changed

4 files changed

+32
-0
lines changed

test/KzykHys/CsvParser/CsvParserTest.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,4 +92,21 @@ public function testOffsetAndLimitOption()
9292
$this->assertEquals(array(1 => array(4, 5, 6), 2 => array(7, 8, 9)), $parser->parse());
9393
}
9494

95+
public function testMultibyteString()
96+
{
97+
$dir = __DIR__ . '/Resources/csv/';
98+
$files = array(
99+
$dir . '6-cp932-excel-win.csv', $dir . '6-cp932-excel-mac.csv'
100+
);
101+
$expected = json_decode(file_get_contents($dir . '6-cp932-excel.json'));
102+
103+
foreach ($files as $file) {
104+
$fromFile = CsvParser::fromFile($file)->parse();
105+
$fromString = CsvParser::fromString(file_get_contents($file))->parse();
106+
$this->assertEquals($fromFile, $fromString);
107+
$this->assertEquals($expected, $fromFile);
108+
}
109+
110+
}
111+
95112
}

test/KzykHys/CsvParser/Resources/csv/6-cp932-excel-mac.csv

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
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�łłĂ��܂�����,,,,,,,,,,,,
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2013�N11��12��,�K�N,135.001,���@�̎����́A���p���郉�C�Z���X�ɐN�Q���肱�Ƃɂ�����ҏW�@�I�łłĂ��܂�����
2+
2013�N11��13��,�K�N,136.001,���@�̎����́A���p���郉�C�Z���X�ɐN�Q���肱�Ƃɂ�����ҏW�@�I�łłĂ��܂�����
3+
,,,
4+
,,,
5+
,,,
6+
,,,
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[
2+
["2013年11月12日", "薔薇", 135.001, "方法の資料は、引用するライセンスに侵害ありことにおける編集法的ででていませある"],
3+
["2013年11月13日", "薔薇", 136.001, "方法の資料は、引用するライセンスに侵害ありことにおける編集法的ででていませある"],
4+
["","","",""],
5+
["","","",""],
6+
["","","",""],
7+
["","","",""]
8+
]

0 commit comments

Comments
 (0)