1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
|
# -*- 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
|