Sha256: bccb4860dfa84c59dd185313de2f97abe4c029665fb828fb300527984a2c1670
Contents?: true
Size: 1.63 KB
Versions: 1
Compression:
Stored size: 1.63 KB
Contents
require 'spec_helper' require 'clicoder' require 'clicoder/judge' require 'tempfile' module Clicoder describe Judge do let(:judge) { Judge.new( {} ) } describe '#diff_judge' do before(:all) do # input for judge @input = Tempfile.new('clicoder') @input.write([1, 2, 3].join("\n")) @input.close @correct_output = Tempfile.new('clicoder') @correct_output.write([1, 2, 3].join("\n")) @correct_output.close @wrong_output = Tempfile.new('clicoder') @wrong_output.write([1, 2, 4].join("\n")) @wrong_output.close end it 'returns true when the contents of two files are the same' do expect(judge.diff_judge(@input.path, @correct_output.path)).to be true end it 'returns false when the contents of two files are different' do expect(judge.diff_judge(@input.path, @wrong_output.path)).to be false end end describe '#float_judge' do before(:all) do @input = Tempfile.new('clicoder') @input.write(<<-EOS) 0.11 0.11 0.13 0.13 EOS @input.close @output = Tempfile.new('clicoder') @output.write(<<-EOS) 0.12 0.12 0.12 0.12 EOS @output.close end subject { judge.float_judge(@input.path, @output.path, abs_error) } context 'when diff is less than allowed absolute error' do let(:abs_error) { 10**(-1) } it { should be true } end context 'when diff is less than allowed absolute error' do let(:abs_error) { 10**(-2) } it { should be false } end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
clicoder-0.0.6 | spec/judge_spec.rb |