Sha256: 20e791008481f977a91b0c2eb91179388dbcec8a393fe27c720918f42333c7ef

Contents?: true

Size: 1.36 KB

Versions: 14

Compression:

Stored size: 1.36 KB

Contents

# encoding: utf-8

require 'helper'

class TestString < Test::Unit::TestCase
  FS = Faker::String

  def test_atoms
    assert_equal "abc", FS.from_regexp(/abc/)
  end

  def test_digits
    assert_match /\d\d\d/, FS.from_regexp(/\d\d\d/)
  end

  def test_word_characters
    assert_match /\w\w\w/, FS.from_regexp(/\w\w\w/)
  end

  def test_spaces
    assert_match /\s\s\s/, FS.from_regexp(/\s\s\s/)
  end

  def test_escaped_characters
    assert_equal "\\/.()[]{}", FS.from_regexp(/\\\/\.\(\)\[\]\{\}/)
  end

  def test_atom_sets
    assert ['a', 'b', 'c'].include?(FS.from_regexp(/[abc]/))
  end

  def test_special_sets
    assert_match /[\w\d]/, FS.from_regexp(/[\w\d]/)
  end

  def test_atom_question
    assert_match /a?/, FS.from_regexp(/a?/)
  end

  def test_special_question
    assert_match /^\w?$/, FS.from_regexp(/\w?/)
  end

  def test_set_question
    assert_match /^[abc]?$/, FS.from_regexp(/[abc]?/)
  end

  def test_atom_plus
    assert_match /a+/, FS.from_regexp(/a+/)
  end

  def test_special_plus
    assert_match /\w+/, FS.from_regexp(/\w+/)
  end

  def test_set_plus
    assert_match /^[abc]+$/, FS.from_regexp(/[abc]+/)
  end

  def test_atom_star
    assert_match /a*/, FS.from_regexp(/a*/)
  end

  def test_special_star
    assert_match /\w*/, FS.from_regexp(/\w*/)
  end

  def test_set_star
    assert_match /^[abc]*$/, FS.from_regexp(/[abc]*/)
  end
end

Version data entries

14 entries across 14 versions & 3 rubygems

Version Path
solidus_backend-1.0.0.pre3 vendor/bundle/gems/ffaker-1.32.1/test/test_string.rb
solidus_backend-1.0.0.pre2 vendor/bundle/gems/ffaker-1.32.1/test/test_string.rb
solidus_backend-1.0.0.pre vendor/bundle/gems/ffaker-1.32.1/test/test_string.rb
ffaker-1.32.1 test/test_string.rb
ffaker-1.32.0 test/test_string.rb
ffaker-1.31.0 test/test_string.rb
ffaker-1.30.0 test/test_string.rb
ffaker-1.25.0 test/test_string.rb
ffaker-1.24.0 test/test_string.rb
ffakerer-1.0.2 test/test_string.rb
ffaker-1.23.0 test/test_string.rb
ffakerer-1.0.1 test/test_string.rb
ffaker-1.22.1 test/test_string.rb
ffaker-1.22.0 test/test_string.rb