Skip to content

Commit

Permalink
update rspec test
Browse files Browse the repository at this point in the history
  • Loading branch information
rask24 committed Feb 14, 2024
1 parent 4585c05 commit 98d9849
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 5 deletions.
1 change: 1 addition & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ RSpec::Core::RakeTask.new(:test) do |task|
task.pattern = [
"test/e2e/spec/corner_cases_spec.rb",
"test/e2e/spec/error_cases_spec.rb",
"test/e2e/spec/checker_spec.rb",
]
end

Expand Down
19 changes: 19 additions & 0 deletions test/e2e/spec/checker_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# frozen_string_literal: true

require_relative "../helper/command_helper"

describe("Performance test for push_swap") do
[5, 10, 50, 100, 200, 500, 1000].each do |size|
it "measures operations for random input of size #{size}" do
results = []
input = (0...size).to_a.shuffle.map(&:to_s)
stdout, _stderr, status = execute_push_swap(*input)
expect(status.exitstatus).to(eq(0))
results << stdout.split("\n").count

stdout, _stderr, status = execute_checker(*input)
expect(status.exitstatus).to(eq(0))
expect(stdout).to(eq("OK\n"))
end
end
end
6 changes: 1 addition & 5 deletions test/e2e/spec/performance_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,9 @@
results = []
20.times do
input = (0...500).to_a.shuffle.map(&:to_s)
stdout, _stderr, status = execute_push_swap(*input)
expect(status.exitstatus).to(eq(0))
stdout, _stderr, _status = execute_push_swap(*input)
results << stdout.split("\n").count

stdout, _stderr, status = execute_checker(*input)
expect(status.exitstatus).to(eq(0))
expect(stdout).to(eq("OK\n"))
print "\e[32m.\e[0m"
end
max_operations = results.max
Expand Down

0 comments on commit 98d9849

Please sign in to comment.