Skip to content

Commit

Permalink
Add more test cases to ensure correct behaviour
Browse files Browse the repository at this point in the history
  • Loading branch information
piotrmurach committed Mar 2, 2020
1 parent 9972d63 commit 57b7537
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions spec/unit/format_time_spec.rb
Original file line number Diff line number Diff line change
@@ -1,18 +1,25 @@
# encoding: utf-8
# frozen_string_literal: true

RSpec.describe RSpec::Benchmark, '#format_time' do
RSpec.describe RSpec::Benchmark, "#format_time" do
{
1e-10 => "0 ns",
0.42e-6 => "420 ns",
# us
3.4e-6 => "3.4 μs",
34e-6 => "34 μs",
340e-6 => "340 μs",
1e-3 => "1 ms",
12e-3 => "12 ms",
# ms
0.001 => "1 ms",
0.0123 => "12.3 ms",
0.123 => "123 ms",
0.1 => "100 ms",
# sec
1.0 => "1 sec",
1.2345 => "1.23 sec",
12.123 => "12.1 sec",
123.45 => "123 sec",
1234 => "1234 sec"
1234 => "1234 sec",
1234.56 => "1235 sec"
}.each do |input, expected|
it "#{input} -> #{expected}" do
expect(described_class.format_time(input)).to eq(expected)
Expand Down

0 comments on commit 57b7537

Please sign in to comment.