Sha256: 4195ec0fb6545f023aada8eeddf661533f2951b1fcdbfde0e47286ff7a25e526
Contents?: true
Size: 1.24 KB
Versions: 1
Compression:
Stored size: 1.24 KB
Contents
require 'spec_helper' module Yargi describe Random do it "should be installed as a graph class method" do Digraph.random.should be_a(Digraph) end it "should serve the requested number of vertices unless strip" do graph = Digraph.random do |r| r.vertex_count = 10 r.edge_count = 20 r.strip = false end graph.vertex_count.should == 10 graph.edge_count.should == 20 end it "should allow specifying sizes inline" do graph = Digraph.random(10, 20) do |r| r.strip = false end graph.vertex_count.should == 10 graph.edge_count.should == 20 end it "should strip the graph if requested" do graph = Digraph.random(50, 20) graph.vertex_count.should_not eq(50) Decorate::DEPTH.execute(graph) graph.vertices{|v| v[:depth] > 20}.should be_empty end it "should allow specifying vertex and edge builders" do graph = Digraph.random(10, 20) do |r| r.vertex_builder = lambda{|v,i| v[:i] = i} r.edge_builder = lambda{|e,i| e[:i] = i} r.strip = false end graph.vertices.collect{|v| v[:i]}.should == (0...10).to_a graph.edges.collect{|e| e[:i]}.should == (0...20).to_a end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
yargi-0.2.0 | spec/test_random.rb |