Sha256: 71df046612e0eaf3b05702e792fb818ecfad1383d5c9533e43a4884bc577c22d
Contents?: true
Size: 1.84 KB
Versions: 377
Compression:
Stored size: 1.84 KB
Contents
require File.join(File.expand_path(File.dirname(__FILE__)), '../../..', 'test_helper.rb') require 'rbbt/util/log/progress' class TestProgress < Test::Unit::TestCase def test_bar t1 = Thread.new do Log::ProgressBar.with_bar(20, :desc => "Bar 1") do |bar| 20.times do bar.tick sleep 0.3 end Log.debug "Done progress" assert_equal 100, bar.percent end end t2 = Thread.new do Log::ProgressBar.with_bar(20, :desc => "Bar 2") do |bar| 20.times do bar.tick sleep 0.2 end Log.debug "Done progress" assert_equal 100, bar.percent end end t1.join t2.join end def test_bar_no_size t1 = Thread.new do Log::ProgressBar.with_bar(nil, :desc => "Bar 1") do |bar| 20.times do bar.tick sleep 0.3 end #Log.debug "Done progress" assert bar.history.length > 0 end end t2 = Thread.new do Log::ProgressBar.with_bar(nil, :desc => "Bar 2") do |bar| 20.times do bar.tick sleep 0.2 end #Log.debug "Done progress" assert bar.history.length > 0 end end t1.join t2.join end def test_bar_nested Log::ProgressBar.with_bar(20, :desc => "Bar 1") do |bar| bar.init 20.times do Log::ProgressBar.with_bar(5, :desc => "Bar 2") do |bar| 5.times do bar.tick sleep 0.2 end end bar.tick sleep 0.2 end end end def test_pos size = 10000 Log::ProgressBar.with_bar(size, :desc => "Bar 1") do |bar| bar.init nums = [] 100.times do nums << rand(size) end nums.sort.each do |num| bar.pos num sleep 0.1 end bar.tick end end end
Version data entries
377 entries across 377 versions & 1 rubygems