Add barplot test

This commit is contained in:
kojix2
2020-11-23 20:09:32 +09:00
parent 0ff8c6a9f0
commit a0c3863b4c
2 changed files with 181 additions and 10 deletions

View File

@@ -4,20 +4,38 @@ require "tempfile"
require_relative '../test_helper'
class YouPlotCommandTest < Test::Unit::TestCase
def startup
end
def setup
@ta = "ta"
@stdin = $stdin.dup
@stdin = $stdin.dup
$stdin = File.open(File.expand_path("../fixtures/iris.csv", __dir__), "r")
@stderr = $stderr.dup
end
test :scatter do
$stdin = File.open(File.expand_path("../fixtures/iris.csv", __dir__), "r")
Tempfile.new("iris-scatter") do |tmp_file|
$stderr = tmp_file
YouPlot::Command.new(["scatter", "-H", "-d,", "-t", "IRIS"]).run
assert_equal File.read(File.expand_path("../fixtures/iris-scatter.txt", __dir__)), tmp_file.read
end
$stdin = @stdin
def cleanup
$stdin = @stdin
$stderr = @stderr
end
def fixture(fname)
File.read(File.expand_path("../fixtures/#{fname}", __dir__))
end
test :scatter do
Tempfile.new do |tmp_file|
$stderr = tmp_file
YouPlot::Command.new(["scatter", "-H", "-d,", "-t", "IRIS"]).run
assert_equal fixture('iris-scatter.txt'), tmp_file.read
end
end
test :barplot do
Tempfile.new do |tmp_file|
$stderr = tmp_file
YouPlot::Command.new(["barplot", "-H", "-d,", "-t", "IRIS"]).run
assert_equal fixture('iris-bar.txt'), tmp_file.read
end
end
end