Welcome to mirror list, hosted at ThFree Co, Russian Federation.

unicode_spec.rb « gitlab « lib « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 68f3266ecc70844095f60ee62349a8a183f6b2b6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# frozen_string_literal: true

require "spec_helper"

RSpec.describe Gitlab::Unicode do
  describe described_class::BIDI_REGEXP do
    using RSpec::Parameterized::TableSyntax

    where(:bidi_string, :match) do
      "\u2066"       | true # left-to-right isolate
      "\u2067"       | true # right-to-left isolate
      "\u2068"       | true # first strong isolate
      "\u2069"       | true # pop directional isolate
      "\u202a"       | true # left-to-right embedding
      "\u202b"       | true # right-to-left embedding
      "\u202c"       | true # pop directional formatting
      "\u202d"       | true # left-to-right override
      "\u202e"       | true # right-to-left override
      "\u2066foobar" | true
      ""             | false
      "foo"          | false
      "\u2713"       | false # checkmark
    end

    with_them do
      let(:utf8_string) { bidi_string.encode("utf-8") }

      it "matches only the bidi characters" do
        expect(utf8_string.match?(subject)).to eq(match)
      end
    end
  end
end