Sha256: eada53bfaa258cfde539e699c581b8d6a05da6c0f036c55fa5419d4be2342b87

Contents?: true

Size: 1.08 KB

Versions: 2

Compression:

Stored size: 1.08 KB

Contents

# frozen_string_literal: true

#
# Copyright (c) 2018-present, Blue Marble Payroll, LLC
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
#

require './spec/spec_helper'

describe ::Differential::Calculator::Totals do
  it 'should properly calculate sigmas and delta' do
    totals = ::Differential::Calculator::Totals.new

    totals.add(300, ::Differential::Calculator::Side::A)

    expect(totals.a_sigma).to eq(300)
    expect(totals.b_sigma).to eq(0)
    expect(totals.delta).to   eq(-300)

    totals.add(400, ::Differential::Calculator::Side::B)

    expect(totals.a_sigma).to eq(300)
    expect(totals.b_sigma).to eq(400)
    expect(totals.delta).to   eq(100)

    totals.add(2.5, ::Differential::Calculator::Side::A)

    expect(totals.a_sigma).to eq(302.5)
    expect(totals.b_sigma).to eq(400)
    expect(totals.delta).to   eq(97.5)

    totals.add(2.50, ::Differential::Calculator::Side::B)

    expect(totals.a_sigma).to eq(302.5)
    expect(totals.b_sigma).to eq(402.5)
    expect(totals.delta).to   eq(100)
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
differential-1.0.2 spec/differential/calculator/totals_spec.rb
differential-1.0.1 spec/differential/calculator/totals_spec.rb