|
56 | 56 | it "drops a stray invalid byte and keeps the surrounding text" do |
57 | 57 | input = "Hello \xFF world".dup |
58 | 58 | expect(input.valid_encoding?).to be(false) |
59 | | - expect(described_class.new(input).convert).to eq("Hello world") |
| 59 | + expect(described_class.new(input).convert).to eq("Hello ? world") |
60 | 60 | end |
61 | 61 |
|
62 | 62 | it "drops a stray continuation byte" do |
63 | 63 | input = "abc \x80 def".dup |
64 | 64 | expect(input.valid_encoding?).to be(false) |
65 | | - expect(described_class.new(input).convert).to eq("abc def") |
| 65 | + expect(described_class.new(input).convert).to eq("abc ? def") |
66 | 66 | end |
67 | 67 |
|
68 | 68 | it "drops a truncated multi-byte sequence" do |
69 | 69 | input = "pre \xC3 post".dup |
70 | 70 | expect(input.valid_encoding?).to be(false) |
71 | | - expect(described_class.new(input).convert).to eq("pre post") |
| 71 | + expect(described_class.new(input).convert).to eq("pre ? post") |
72 | 72 | end |
73 | 73 |
|
74 | 74 | it "preserves valid multi-byte characters while dropping only the invalid byte" do |
75 | 75 | input = "héllo \xFF world".dup |
76 | 76 | expect(input.valid_encoding?).to be(false) |
77 | | - expect(described_class.new(input).convert).to eq("héllo world") |
| 77 | + expect(described_class.new(input).convert).to eq("héllo ? world") |
78 | 78 | end |
79 | 79 |
|
80 | 80 | it "still parses formatting around invalid bytes inside delimiters" do |
81 | 81 | input = "*bold\xFFtext*".dup |
82 | 82 | expect(input.valid_encoding?).to be(false) |
83 | | - expect(described_class.new(input).convert).to eq("**boldtext**") |
| 83 | + expect(described_class.new(input).convert).to eq("**bold?text**") |
84 | 84 | end |
85 | 85 | end |
86 | 86 | end |
|
0 commit comments