Sha256: 3dabef06677c2ae1c4292a6668f15412d325dde6e8a069ef4d745ec60d054462

Contents?: true

Size: 915 Bytes

Versions: 1

Compression:

Stored size: 915 Bytes

Contents

# -*- coding: utf-8 -*-
require 'minitest/autorun'
require 'sixarm_ruby_ramp/enumerable/map'
require 'ostruct'

class EnumerableMapTest < Minitest::Test

  def test_map_id
    x = [OpenStruct.new(id: 1), OpenStruct.new(id: 2), OpenStruct.new(id: 3)]
    assert_equal(x.map(&:id), x.map_id)
  end

  def test_map_to_a
    x = [{a: :b, c: :d}, {e: :f, g: :h}]
    assert_equal(x.map(&:to_a), x.map_to_a)
  end

  def test_map_to_f
    x = ["1", "2", "3"]
    assert_equal(x.map(&:to_f) , x.map_to_f)
  end

  def test_map_to_i
    x = ["1", "2", "3"]
    assert_equal(x.map(&:to_i), x.map_to_i)
  end

  def test_map_to_s
    x = [1, 2, 3]
    assert_equal(x.map(&:to_s), x.map_to_s)
  end

  def test_map_to_sym
    x = ["a", "b", "c"]
    assert_equal(x.map(&:to_sym) , x.map_to_sym)
  end

  def test_map_with_index
    assert_equal(["a0", "b1", "c2"], ["a", "b", "c"].map_with_index{|x,i| "#{x}#{i}"})
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
sixarm_ruby_ramp-4.2.2 test/sixarm_ruby_ramp_test/enumerable/map_test.rb