Sha256: 23634e3febe725110a6ba31518eeda0729a28628800792eb554c44ae180693d1
Contents?: true
Size: 1.1 KB
Versions: 2
Compression:
Stored size: 1.1 KB
Contents
require 'spec_helper' require 'combinatorics/choose' shared_examples_for "Choose::Mixin" do let(:empty_set) { Set[] } it "should return [[]] for [].choose(0).to_a" do set = subject[] results = set.choose(0).to_a expect(results).to eq([empty_set]) end it "should return [[]] for [1].choose(0).to_a" do set = subject[1] results = set.choose(0).to_a expect(results).to eq([empty_set]) end it "should return [[1]] for [1].choose(1).to_a" do set = subject[1] results = set.choose(1).to_a expect(results).to eq([Set[1]]) end it "should return [[1], [2]] for [1, 2].choose(1).to_a" do set = subject[1, 2] results = set.choose(1).to_a expect(results).to match_array([Set[1], Set[2]]) end it "should return [[1, 2]] for [1, 2].choose(2).to_a" do set = subject[1, 2] results = set.choose(2).to_a expect(results).to eq([Set[1, 2]]) end it "should filter out repeated elements" do set1 = subject[1,1,2,3] set2 = subject[1,2,3] expect(set1.choose(2).to_a).to eq(set2.choose(2).to_a) end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
combinatorics-0.5.0 | spec/choose/mixin_examples.rb |
combinatorics-0.4.4 | spec/choose/mixin_examples.rb |