mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
24b57b102c
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66922 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
70 lines
1.8 KiB
Ruby
70 lines
1.8 KiB
Ruby
# -*- coding: utf-8 -*-
|
|
# frozen_string_literal: false
|
|
|
|
require_relative "../helper"
|
|
|
|
module TestCSVWriteQuoteEmpty
|
|
def test_quote_empty_default
|
|
assert_equal(%Q["""",""#{$INPUT_RECORD_SEPARATOR}],
|
|
generate_line([%Q["], ""]))
|
|
end
|
|
|
|
def test_quote_empty_false
|
|
assert_equal(%Q["""",#{$INPUT_RECORD_SEPARATOR}],
|
|
generate_line([%Q["], ""],
|
|
quote_empty: false))
|
|
end
|
|
|
|
def test_empty_default
|
|
assert_equal(%Q[foo,"",baz#{$INPUT_RECORD_SEPARATOR}],
|
|
generate_line(["foo", "", "baz"]))
|
|
end
|
|
|
|
def test_empty_false
|
|
assert_equal(%Q[foo,,baz#{$INPUT_RECORD_SEPARATOR}],
|
|
generate_line(["foo", "", "baz"],
|
|
quote_empty: false))
|
|
end
|
|
|
|
def test_empty_only_default
|
|
assert_equal(%Q[""#{$INPUT_RECORD_SEPARATOR}],
|
|
generate_line([""]))
|
|
end
|
|
|
|
def test_empty_only_false
|
|
assert_equal(%Q[#{$INPUT_RECORD_SEPARATOR}],
|
|
generate_line([""],
|
|
quote_empty: false))
|
|
end
|
|
|
|
def test_empty_double_default
|
|
assert_equal(%Q["",""#{$INPUT_RECORD_SEPARATOR}],
|
|
generate_line(["", ""]))
|
|
end
|
|
|
|
def test_empty_double_false
|
|
assert_equal(%Q[,#{$INPUT_RECORD_SEPARATOR}],
|
|
generate_line(["", ""],
|
|
quote_empty: false))
|
|
end
|
|
end
|
|
|
|
class TestCSVWriteQuoteEmptyGenerateLine < Test::Unit::TestCase
|
|
include TestCSVWriteQuoteEmpty
|
|
extend DifferentOFS
|
|
|
|
def generate_line(row, **kwargs)
|
|
CSV.generate_line(row, **kwargs)
|
|
end
|
|
end
|
|
|
|
class TestCSVWriteQuoteEmptyGenerate < Test::Unit::TestCase
|
|
include TestCSVWriteQuoteEmpty
|
|
extend DifferentOFS
|
|
|
|
def generate_line(row, **kwargs)
|
|
CSV.generate(**kwargs) do |csv|
|
|
csv << row
|
|
end
|
|
end
|
|
end
|