Sha256: 114ddec59aee715723255f9d0307a9a7e205148b0b5f10560d15cbcbe3d886aa

Contents?: true

Size: 1.22 KB

Versions: 4

Compression:

Stored size: 1.22 KB

Contents

#! /usr/bin/env ruby
# coding: utf-8

require "helper"
require "stringio"

class Tefil::LineSubstituter
  public :process_stream
end

class TC_LineSubstituter < Test::Unit::TestCase
  def setup
    @ls00 = Tefil::LineSubstituter.new('abc', 'XYZ')
    @ls01 = Tefil::LineSubstituter.new('abc', 'XYZ', {:global => true})
    @ls02 = Tefil::LineSubstituter.new('^a', 'A', {:regexp => true})
  end

  def test_process_stream
    setup
    $stdin = StringIO.new
    $stdin.puts "abcdabcd"
    $stdin.puts "ABCDABCD"
    $stdin.rewind
    str = capture_stdout{}
    result = capture_stdout{ @ls00.filter([])}
    correct =
      "XYZdabcd\n" +
      "ABCDABCD\n"
    assert_equal(correct, result)


    setup
    $stdin = StringIO.new
    $stdin.puts "abcdabcd"
    $stdin.puts "ABCDABCD"
    $stdin.rewind
    str = capture_stdout{}
    result = capture_stdout{ @ls01.filter([])}
    correct =
      "XYZdXYZd\n" +
      "ABCDABCD\n"
    assert_equal(correct, result)

    setup
    $stdin = StringIO.new
    $stdin.puts "abcdabcd"
    $stdin.puts "ABCDABCD"
    $stdin.rewind
    str = capture_stdout{}
    result = capture_stdout{ @ls02.filter([])}
    correct =
      "Abcdabcd\n" +
      "ABCDABCD\n"
    assert_equal(correct, result)

  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
tefil-0.1.5 test/test_linesubstituter.rb
tefil-0.1.4 test/test_linesubstituter.rb
tefil-0.1.3 test/test_linesubstituter.rb
tefil-0.1.2 test/test_linesubstituter.rb