Sha256: 33cd15d90e2667915189ca5f5279aec6f2f5dc6873ca4704f15b59f2bb781bc5
Contents?: true
Size: 1.69 KB
Versions: 1
Compression:
Stored size: 1.69 KB
Contents
require_relative '../test_helper' describe Skr::Core::Strings do # just 'cuz Str = Skr::Core::Strings def test_random_is_of_proper_length assert_equal 12, Str.random.length assert_equal 6, Str.random(6).length end def test_random_doesnt_use_bad_chars bad = Str::BAD_RAND_CHARS assert bad.present?, 'list of bad random chars is empty' 0.upto(10).each do | i | string = Str.random string.each_char do |c| refute bad.include?(c), "Random string #{string} included bad char '#{c}'" end end end def test_code_identifier_shortens # if all words are long engouth to shorten, then it takes an # equal number from each assert_equal 'GENACMCORP', Str.code_identifier( 'General Acme Corp' ) # If one word is too short, it'll attempt to make up the difference with # later words assert_equal 'GENIINCORP', Str.code_identifier( 'General I Incorporated' ) # If it gets to the end and it's still too short, it'll append the # padding char assert_equal 'GENERALIBC', Str.code_identifier( 'General I BC' ) assert_equal 'GENERALIB*', Str.code_identifier( 'General I B.', padding: '*' ) assert_equal 'FSANSEYEAG', Str.code_identifier( 'Four score and seven years ago', padding: '*' ) assert_equal 'ALONSBEAST', Str.code_identifier( 'A long s beasty' ) assert_equal 'GE', Str.code_identifier( 'GE', padding: false ) assert_equal 'HI33ME', Str.code_identifier( 'Hi 33 Me!', padding: false ) assert_equal 'BADIANDOCO', Str.code_identifier( "Bayer, Dickinson and O'Conner", padding: false ) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
stockor-core-0.2 | test/core/strings_test.rb |