Skip to content

Instantly share code, notes, and snippets.

@myokoym
Created May 26, 2014 13:10
Show Gist options
  • Save myokoym/66126acc3e6721c0f5e5 to your computer and use it in GitHub Desktop.
Save myokoym/66126acc3e6721c0f5e5 to your computer and use it in GitHub Desktop.
require "test-unit"
class RegexpTest < Test::Unit::TestCase
def setup
@regexp = /\bCairo(?:::[A-Z][\w\d_]+)*(?:[#.][\[_@\w\d]*(?:[=?!_*+\-\]]|\b)|\b)/
end
def test_front
line = "Cairo::Contextはrcairoで描画するときに使用する主要なオブジェ\n"
assert_equal(["Cairo::Context"], line.gsub(@regexp).to_a)
end
def test_between_border
line = "フェスを設定したCairo::Contextを作ります。それから、描画オプ\n"
assert_equal(["Cairo::Context"], line.gsub(@regexp).to_a)
end
def test_move_to
line = "ションを設定し、Cairo::Context#move_to、\n"
assert_equal(["Cairo::Context#move_to"], line.gsub(@regexp).to_a)
end
def test_line_to
line = "Cairo::Context#line_toなどで形を作り、その形を\n"
assert_equal(["Cairo::Context#line_to"], line.gsub(@regexp).to_a)
end
def test_matches
line = "Cairo::Context#strokeかCairo::Context#fillで描画\n"
assert_equal(["Cairo::Context#stroke", "Cairo::Context#fill"], line.gsub(@regexp).to_a)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment