File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change 4
4
describe Rex ::Text do
5
5
context "Class methods" do
6
6
7
+ context ".to_ebcdic" do
8
+ it "should convert ASCII to EBCDIC (both US standards)" do
9
+ described_class . to_ebcdic ( "Hello, World!" ) . should eq ( "\xc8 \x85 \x93 \x93 \x96 \x6b \x40 \xe6 \x96 \x99 \x93 \x84 \x5a " )
10
+ end
11
+ it "should raise on non-convertable characters" do
12
+ lambda { described_class . to_ebcdic ( "\xff \xfe " ) } . should raise_exception ( described_class ::IllegalSequence )
13
+ end
14
+ end
15
+
16
+ context ".from_ebcdic" do
17
+ it "should convert EBCDIC to ASCII (both US standards)" do
18
+ described_class . from_ebcdic ( "\xc8 \x85 \x93 \x93 \x96 \x6b \x40 \xe6 \x96 \x99 \x93 \x84 \x5a " ) . should eq ( "Hello, World!" )
19
+ end
20
+ it "should raise on non-convertable characters" do
21
+ lambda { described_class . from_ebcdic ( "\xff \xfe " ) } . should raise_exception ( described_class ::IllegalSequence )
22
+ end
23
+ end
24
+
25
+ context ".to_utf8" do
26
+ it "should convert a string to UTF-8, skipping badchars" do
27
+ described_class . to_utf8 ( "Hello, world!" ) . should eq ( "Hello, world!" )
28
+ described_class . to_utf8 ( "Oh no, \xff \xfe can't convert!" ) . should eq ( "Oh no, can't convert!" )
29
+ end
30
+ end
31
+
7
32
context ".to_octal" do
8
33
it "should convert all chars 00 through ff" do
9
34
described_class . to_octal ( "\x7f " *100 ) . should eq ( "\\ 177" *100 )
You can’t perform that action at this time.
0 commit comments