mirror of
https://github.com/red-data-tools/YouPlot.git
synced 2025-09-19 10:28:06 +08:00
Add barplot test
This commit is contained in:
@@ -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
|
||||
|
Reference in New Issue
Block a user