Sha256: a5ca7624cfd9b029fc2f0b8e2d4c48cb921b4be149d3871f69d0658dee5c2250

Contents?: true

Size: 1.68 KB

Versions: 1

Compression:

Stored size: 1.68 KB

Contents

#  _____         _
# |_   _|__  ___| |_
#   | |/ _ \/ __| __|
#   | |  __/\__ \ |_
#   |_|\___||___/\__|
#
# for lib/nano/fileutils/wc.rb
#
# Extracted Fri Oct 28 14:20:18 EDT 2005
# Unit Tools Reap Test Extractor
#

require 'nano/fileutils/wc.rb'


  require 'test/unit'

  # FIND TEST DIRECTORY
  paths = File.expand_path(File.dirname(__FILE__)).split('/')
  paths.size.downto(1) do |i|
    f = (paths.slice(0..i)+['test']).join('/')
    $TESTDIR = File.join(f,'FIXTURE') if File.directory?(f)
  end
  raise unless $TESTDIR

  class TC_FileUtils_WC < Test::Unit::TestCase

    def setup
      @workdir = Dir.getwd
      @thisdir = $TESTDIR

      @file = 'test_file.txt'
    end

    def test_method
      assert_respond_to( FileUtils, :wc )
    end

    def test_wc
      Dir.chdir @thisdir
      begin
        assert_nothing_raised{ FileUtils.wc(@file) }
        assert_nothing_raised{ FileUtils.wc(@file,'bytes') }
        assert_nothing_raised{ FileUtils.wc(@file,'chars') }
        assert_nothing_raised{ FileUtils.wc(@file,'words') }
        assert_nothing_raised{ FileUtils.wc(@file,'lines') }
        assert_raises(RuntimeError){ FileUtils.wc(@file,'bogus') }
      ensure
        Dir.chdir @workdir
      end
    end

    def test_wc_results
      Dir.chdir @thisdir
      begin
        assert_equal([166,166,25,25],FileUtils.wc(@file))
        assert_equal(166,FileUtils.wc(@file,'bytes'),"Wrong number of bytes")
        assert_equal(166,FileUtils.wc(@file,'chars'),"Wrong number of chars")
        assert_equal(25,FileUtils.wc(@file,'words'),"Wrong number of words")
        assert_equal(25,FileUtils.wc(@file,'lines'),"Wrong number of lines")
      ensure
        Dir.chdir @workdir
      end
    end

  end


Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
facets-0.9.0 test/lib/nano/fileutils/test_wc.rb