From a0c3863b4c44a1875a1131ff73b23a910174be65 Mon Sep 17 00:00:00 2001 From: kojix2 <2xijok@gmail.com> Date: Mon, 23 Nov 2020 20:09:32 +0900 Subject: [PATCH] Add barplot test --- test/fixtures/iris-bar.txt | 153 +++++++++++++++++++++++++++++++++++++ test/uplot/command_test.rb | 38 ++++++--- 2 files changed, 181 insertions(+), 10 deletions(-) create mode 100644 test/fixtures/iris-bar.txt diff --git a/test/fixtures/iris-bar.txt b/test/fixtures/iris-bar.txt new file mode 100644 index 0000000..0a747f2 --- /dev/null +++ b/test/fixtures/iris-bar.txt @@ -0,0 +1,153 @@ + sepal_width + ┌ ┐ + 5.1 ┤■■■■■■■■■■■■■■■■■■■■■■■■■■■■ 3.5 + 4.9 ┤■■■■■■■■■■■■■■■■■■■■■■■■ 3.0 + 4.7 ┤■■■■■■■■■■■■■■■■■■■■■■■■■ 3.2 + 4.6 ┤■■■■■■■■■■■■■■■■■■■■■■■■■ 3.1 + 5.0 ┤■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ 3.6 + 5.4 ┤■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ 3.9 + 4.6 ┤■■■■■■■■■■■■■■■■■■■■■■■■■■■ 3.4 + 5.0 ┤■■■■■■■■■■■■■■■■■■■■■■■■■■■ 3.4 + 4.4 ┤■■■■■■■■■■■■■■■■■■■■■■■ 2.9 + 4.9 ┤■■■■■■■■■■■■■■■■■■■■■■■■■ 3.1 + 5.4 ┤■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ 3.7 + 4.8 ┤■■■■■■■■■■■■■■■■■■■■■■■■■■■ 3.4 + 4.8 ┤■■■■■■■■■■■■■■■■■■■■■■■■ 3.0 + 4.3 ┤■■■■■■■■■■■■■■■■■■■■■■■■ 3.0 + 5.8 ┤■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ 4.0 + 5.7 ┤■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ 4.4 + 5.4 ┤■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ 3.9 + 5.1 ┤■■■■■■■■■■■■■■■■■■■■■■■■■■■■ 3.5 + 5.7 ┤■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ 3.8 + 5.1 ┤■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ 3.8 + 5.4 ┤■■■■■■■■■■■■■■■■■■■■■■■■■■■ 3.4 + 5.1 ┤■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ 3.7 + 4.6 ┤■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ 3.6 + 5.1 ┤■■■■■■■■■■■■■■■■■■■■■■■■■■ 3.3 + 4.8 ┤■■■■■■■■■■■■■■■■■■■■■■■■■■■ 3.4 + 5.0 ┤■■■■■■■■■■■■■■■■■■■■■■■■ 3.0 + 5.0 ┤■■■■■■■■■■■■■■■■■■■■■■■■■■■ 3.4 + 5.2 ┤■■■■■■■■■■■■■■■■■■■■■■■■■■■■ 3.5 + 5.2 ┤■■■■■■■■■■■■■■■■■■■■■■■■■■■ 3.4 + 4.7 ┤■■■■■■■■■■■■■■■■■■■■■■■■■ 3.2 + 4.8 ┤■■■■■■■■■■■■■■■■■■■■■■■■■ 3.1 + 5.4 ┤■■■■■■■■■■■■■■■■■■■■■■■■■■■ 3.4 + 5.2 ┤■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ 4.1 + 5.5 ┤■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ 4.2 + 4.9 ┤■■■■■■■■■■■■■■■■■■■■■■■■■ 3.1 + 5.0 ┤■■■■■■■■■■■■■■■■■■■■■■■■■ 3.2 + 5.5 ┤■■■■■■■■■■■■■■■■■■■■■■■■■■■■ 3.5 + 4.9 ┤■■■■■■■■■■■■■■■■■■■■■■■■■ 3.1 + 4.4 ┤■■■■■■■■■■■■■■■■■■■■■■■■ 3.0 + 5.1 ┤■■■■■■■■■■■■■■■■■■■■■■■■■■■ 3.4 + 5.0 ┤■■■■■■■■■■■■■■■■■■■■■■■■■■■■ 3.5 + 4.5 ┤■■■■■■■■■■■■■■■■■■ 2.3 + 4.4 ┤■■■■■■■■■■■■■■■■■■■■■■■■■ 3.2 + 5.0 ┤■■■■■■■■■■■■■■■■■■■■■■■■■■■■ 3.5 + 5.1 ┤■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ 3.8 + 4.8 ┤■■■■■■■■■■■■■■■■■■■■■■■■ 3.0 + 5.1 ┤■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ 3.8 + 4.6 ┤■■■■■■■■■■■■■■■■■■■■■■■■■ 3.2 + 5.3 ┤■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ 3.7 + 5.0 ┤■■■■■■■■■■■■■■■■■■■■■■■■■■ 3.3 + 7.0 ┤■■■■■■■■■■■■■■■■■■■■■■■■■ 3.2 + 6.4 ┤■■■■■■■■■■■■■■■■■■■■■■■■■ 3.2 + 6.9 ┤■■■■■■■■■■■■■■■■■■■■■■■■■ 3.1 + 5.5 ┤■■■■■■■■■■■■■■■■■■ 2.3 + 6.5 ┤■■■■■■■■■■■■■■■■■■■■■■ 2.8 + 5.7 ┤■■■■■■■■■■■■■■■■■■■■■■ 2.8 + 6.3 ┤■■■■■■■■■■■■■■■■■■■■■■■■■■ 3.3 + 4.9 ┤■■■■■■■■■■■■■■■■■■■ 2.4 + 6.6 ┤■■■■■■■■■■■■■■■■■■■■■■■ 2.9 + 5.2 ┤■■■■■■■■■■■■■■■■■■■■■ 2.7 + 5.0 ┤■■■■■■■■■■■■■■■■ 2.0 + 5.9 ┤■■■■■■■■■■■■■■■■■■■■■■■■ 3.0 + 6.0 ┤■■■■■■■■■■■■■■■■■■ 2.2 + 6.1 ┤■■■■■■■■■■■■■■■■■■■■■■■ 2.9 + 5.6 ┤■■■■■■■■■■■■■■■■■■■■■■■ 2.9 + 6.7 ┤■■■■■■■■■■■■■■■■■■■■■■■■■ 3.1 + 5.6 ┤■■■■■■■■■■■■■■■■■■■■■■■■ 3.0 + 5.8 ┤■■■■■■■■■■■■■■■■■■■■■ 2.7 + 6.2 ┤■■■■■■■■■■■■■■■■■■ 2.2 + 5.6 ┤■■■■■■■■■■■■■■■■■■■■ 2.5 + 5.9 ┤■■■■■■■■■■■■■■■■■■■■■■■■■ 3.2 + 6.1 ┤■■■■■■■■■■■■■■■■■■■■■■ 2.8 + 6.3 ┤■■■■■■■■■■■■■■■■■■■■ 2.5 + 6.1 ┤■■■■■■■■■■■■■■■■■■■■■■ 2.8 + 6.4 ┤■■■■■■■■■■■■■■■■■■■■■■■ 2.9 + 6.6 ┤■■■■■■■■■■■■■■■■■■■■■■■■ 3.0 + 6.8 ┤■■■■■■■■■■■■■■■■■■■■■■ 2.8 + 6.7 ┤■■■■■■■■■■■■■■■■■■■■■■■■ 3.0 + 6.0 ┤■■■■■■■■■■■■■■■■■■■■■■■ 2.9 + 5.7 ┤■■■■■■■■■■■■■■■■■■■■■ 2.6 + 5.5 ┤■■■■■■■■■■■■■■■■■■■ 2.4 + 5.5 ┤■■■■■■■■■■■■■■■■■■■ 2.4 + 5.8 ┤■■■■■■■■■■■■■■■■■■■■■ 2.7 + 6.0 ┤■■■■■■■■■■■■■■■■■■■■■ 2.7 + 5.4 ┤■■■■■■■■■■■■■■■■■■■■■■■■ 3.0 + 6.0 ┤■■■■■■■■■■■■■■■■■■■■■■■■■■■ 3.4 + 6.7 ┤■■■■■■■■■■■■■■■■■■■■■■■■■ 3.1 + 6.3 ┤■■■■■■■■■■■■■■■■■■ 2.3 + 5.6 ┤■■■■■■■■■■■■■■■■■■■■■■■■ 3.0 + 5.5 ┤■■■■■■■■■■■■■■■■■■■■ 2.5 + 5.5 ┤■■■■■■■■■■■■■■■■■■■■■ 2.6 + 6.1 ┤■■■■■■■■■■■■■■■■■■■■■■■■ 3.0 + 5.8 ┤■■■■■■■■■■■■■■■■■■■■■ 2.6 + 5.0 ┤■■■■■■■■■■■■■■■■■■ 2.3 + 5.6 ┤■■■■■■■■■■■■■■■■■■■■■ 2.7 + 5.7 ┤■■■■■■■■■■■■■■■■■■■■■■■■ 3.0 + 5.7 ┤■■■■■■■■■■■■■■■■■■■■■■■ 2.9 + 6.2 ┤■■■■■■■■■■■■■■■■■■■■■■■ 2.9 + 5.1 ┤■■■■■■■■■■■■■■■■■■■■ 2.5 + 5.7 ┤■■■■■■■■■■■■■■■■■■■■■■ 2.8 + 6.3 ┤■■■■■■■■■■■■■■■■■■■■■■■■■■ 3.3 + 5.8 ┤■■■■■■■■■■■■■■■■■■■■■ 2.7 + 7.1 ┤■■■■■■■■■■■■■■■■■■■■■■■■ 3.0 + 6.3 ┤■■■■■■■■■■■■■■■■■■■■■■■ 2.9 + 6.5 ┤■■■■■■■■■■■■■■■■■■■■■■■■ 3.0 + 7.6 ┤■■■■■■■■■■■■■■■■■■■■■■■■ 3.0 + 4.9 ┤■■■■■■■■■■■■■■■■■■■■ 2.5 + 7.3 ┤■■■■■■■■■■■■■■■■■■■■■■■ 2.9 + 6.7 ┤■■■■■■■■■■■■■■■■■■■■ 2.5 + 7.2 ┤■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ 3.6 + 6.5 ┤■■■■■■■■■■■■■■■■■■■■■■■■■ 3.2 + 6.4 ┤■■■■■■■■■■■■■■■■■■■■■ 2.7 + 6.8 ┤■■■■■■■■■■■■■■■■■■■■■■■■ 3.0 + 5.7 ┤■■■■■■■■■■■■■■■■■■■■ 2.5 + 5.8 ┤■■■■■■■■■■■■■■■■■■■■■■ 2.8 + 6.4 ┤■■■■■■■■■■■■■■■■■■■■■■■■■ 3.2 + 6.5 ┤■■■■■■■■■■■■■■■■■■■■■■■■ 3.0 + 7.7 ┤■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ 3.8 + 7.7 ┤■■■■■■■■■■■■■■■■■■■■■ 2.6 + 6.0 ┤■■■■■■■■■■■■■■■■■■ 2.2 + 6.9 ┤■■■■■■■■■■■■■■■■■■■■■■■■■ 3.2 + 5.6 ┤■■■■■■■■■■■■■■■■■■■■■■ 2.8 + 7.7 ┤■■■■■■■■■■■■■■■■■■■■■■ 2.8 + 6.3 ┤■■■■■■■■■■■■■■■■■■■■■ 2.7 + 6.7 ┤■■■■■■■■■■■■■■■■■■■■■■■■■■ 3.3 + 7.2 ┤■■■■■■■■■■■■■■■■■■■■■■■■■ 3.2 + 6.2 ┤■■■■■■■■■■■■■■■■■■■■■■ 2.8 + 6.1 ┤■■■■■■■■■■■■■■■■■■■■■■■■ 3.0 + 6.4 ┤■■■■■■■■■■■■■■■■■■■■■■ 2.8 + 7.2 ┤■■■■■■■■■■■■■■■■■■■■■■■■ 3.0 + 7.4 ┤■■■■■■■■■■■■■■■■■■■■■■ 2.8 + 7.9 ┤■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ 3.8 + 6.4 ┤■■■■■■■■■■■■■■■■■■■■■■ 2.8 + 6.3 ┤■■■■■■■■■■■■■■■■■■■■■■ 2.8 + 6.1 ┤■■■■■■■■■■■■■■■■■■■■■ 2.6 + 7.7 ┤■■■■■■■■■■■■■■■■■■■■■■■■ 3.0 + 6.3 ┤■■■■■■■■■■■■■■■■■■■■■■■■■■■ 3.4 + 6.4 ┤■■■■■■■■■■■■■■■■■■■■■■■■■ 3.1 + 6.0 ┤■■■■■■■■■■■■■■■■■■■■■■■■ 3.0 + 6.9 ┤■■■■■■■■■■■■■■■■■■■■■■■■■ 3.1 + 6.7 ┤■■■■■■■■■■■■■■■■■■■■■■■■■ 3.1 + 6.9 ┤■■■■■■■■■■■■■■■■■■■■■■■■■ 3.1 + 5.8 ┤■■■■■■■■■■■■■■■■■■■■■ 2.7 + 6.8 ┤■■■■■■■■■■■■■■■■■■■■■■■■■ 3.2 + 6.7 ┤■■■■■■■■■■■■■■■■■■■■■■■■■■ 3.3 + 6.7 ┤■■■■■■■■■■■■■■■■■■■■■■■■ 3.0 + 6.3 ┤■■■■■■■■■■■■■■■■■■■■ 2.5 + 6.5 ┤■■■■■■■■■■■■■■■■■■■■■■■■ 3.0 + 6.2 ┤■■■■■■■■■■■■■■■■■■■■■■■■■■■ 3.4 + 5.9 ┤■■■■■■■■■■■■■■■■■■■■■■■■ 3.0 + └ ┘ diff --git a/test/uplot/command_test.rb b/test/uplot/command_test.rb index b50776a..1d1a0c1 100644 --- a/test/uplot/command_test.rb +++ b/test/uplot/command_test.rb @@ -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