Skip to content

Commit

Permalink
Check encode related warnings after read_text
Browse files Browse the repository at this point in the history
Add a unittest to check whether calling read_text results in warnings when
later writing in utf8 encoding
  • Loading branch information
mephinet authored and Leont committed Aug 5, 2016
1 parent 04368a1 commit a30d880
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 0 deletions.
3 changes: 3 additions & 0 deletions dist.ini
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,6 @@ install_tool = eumm
remove = PerlIO::utf8_strict
[Prereqs / RuntimeRecommends]
PerlIO::utf8_strict = 0
[Encoding]
encoding=cp1252
filenames=t/data/cp1252.txt
24 changes: 24 additions & 0 deletions t/20-no-side-effects.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#! perl

use strict;
use warnings;

use Test::More;
use Test::Warnings;

use File::Slurper 'read_text';
use File::Spec::Functions 'catfile';
use FindBin '$RealBin';
use File::Temp 'tempfile';

my $inputfile = catfile( $RealBin, 'data', 'cp1252.txt' );

my $s = read_text( $inputfile, 'cp1252' );

my ( $outfh, $outputfile ) = tempfile();
binmode $outfh, ':encoding(utf8)';

print $outfh "Snowman! \x{2603}\n";
close $outfh;

done_testing;
50 changes: 50 additions & 0 deletions t/data/cp1252.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
latin1 test paragraph:
~
0x21 ! 0x22 " 0x23 # 0x24 $ 0x25 %
0x26 & 0x27 ' 0x28 ( 0x29 ) 0x2a *
0x2b + 0x2c , 0x2d - 0x2e . 0x2f /
0x30 0 0x31 1 0x32 2 0x33 3 0x34 4
0x35 5 0x36 6 0x37 7 0x38 8 0x39 9
0x3a : 0x3b ; 0x3c < 0x3d = 0x3e >
0x3f ? 0x40 @ 0x41 A 0x42 B 0x43 C
0x44 D 0x45 E 0x46 F 0x47 G 0x48 H
0x4a J 0x4b K 0x4c L 0x4d M 0x4e N
0x4f O 0x50 P 0x51 Q 0x52 R 0x53 S
0x54 T 0x55 U 0x56 V 0x57 W 0x58 X
0x59 Y 0x5a Z 0x5b [ 0x5c \ 0x5d ]
0x5e ^ 0x5f _ 0x60 ` 0x61 a 0x62 b
0x63 c 0x64 d 0x65 e 0x66 f 0x67 g
0x68 h 0x69 i 0x6a j 0x6b k 0x6c l
0x6d m 0x6e n 0x6f o 0x70 p 0x71 q
0x72 r 0x73 s 0x74 t 0x75 u 0x76 v
0x77 w 0x78 x 0x79 y 0x7a z 0x7b {
0x7c | 0x7d } 0x7e ~ 0xa0 � 0xa1 �
0xa2 � 0xa3 � 0xa4 � 0xa5 � 0xa6 �
0xa7 � 0xa8 � 0xa9 � 0xaa � 0xab �
0xac � 0xae � 0xaf � 0xb0 � 0xb1 �
0xb2 � 0xb3 � 0xb4 � 0xb5 � 0xb6 �
0xb7 � 0xb8 � 0xb9 � 0xba � 0xbb �
0xbc � 0xbd � 0xbe � 0xbf � 0xc0 �
0xc1 � 0xc2 � 0xc3 � 0xc4 � 0xc5 �
0xc6 � 0xc7 � 0xc8 � 0xc9 � 0xca �
0xcb � 0xcc � 0xcd � 0xce � 0xcf �
0xd0 � 0xd1 � 0xd2 � 0xd3 � 0xd4 �
0xd5 � 0xd6 � 0xd7 � 0xd8 � 0xd9 �
0xda � 0xdb � 0xdc � 0xdd � 0xde �
0xdf � 0xe0 � 0xe1 � 0xe2 � 0xe3 �
0xe4 � 0xe5 � 0xe6 � 0xe7 � 0xe8 �
0xe9 � 0xea � 0xeb � 0xec � 0xed �
0xee � 0xef � 0xf0 � 0xf1 � 0xf2 �
0xf3 � 0xf4 � 0xf5 � 0xf6 � 0xf7 �
0xf8 � 0xf9 � 0xfa � 0xfb � 0xfc �
0xfd � 0xfe � 0xff �
~
cp1252 test paragraph:
~
0x80 � 0x82 � 0x83 � 0x84 � 0x85 �
0x86 � 0x87 � 0x88 � 0x89 � 0x8a �
0x8b � 0x8c � 0x8e � 0x91 � 0x92 �
0x93 � 0x94 � 0x95 � 0x96 � 0x97 �
0x98 � 0x99 � 0x9a � 0x9b � 0x9c �
0x9e � 0x9f �
~

0 comments on commit a30d880

Please sign in to comment.