eBooru/test/unit/string_test.rb
Earlopain fc7d84affd
[RuboCop] Enable Style/FrozenStringLiteralComment
This reduces allocations on the posts page by about 5%, from basic testing
2024-02-25 18:15:55 +01:00

20 lines
708 B
Ruby

# frozen_string_literal: true
require "test_helper"
class StringTest < ActiveSupport::TestCase
context "String#to_escaped_for_sql_like" do
should "work" do
assert_equal('foo\%bar', 'foo%bar'.to_escaped_for_sql_like)
assert_equal('foo\_bar', 'foo_bar'.to_escaped_for_sql_like)
assert_equal('foo%bar', 'foo*bar'.to_escaped_for_sql_like)
assert_equal('foo*bar', 'foo\*bar'.to_escaped_for_sql_like)
assert_equal('foo\\\\%bar', 'foo\\\\*bar'.to_escaped_for_sql_like)
assert_equal('foo\\\\bar', 'foo\bar'.to_escaped_for_sql_like)
assert_equal('%\\\\%', '*\\\\*'.to_escaped_for_sql_like)
assert_equal('%*%', '*\**'.to_escaped_for_sql_like)
end
end
end