Sha256: 1c17ab37d69f347866b5bb442e0879150772e9bb84652ec61f1193ef918f548c

Contents?: true

Size: 1.29 KB

Versions: 26

Compression:

Stored size: 1.29 KB

Contents

require 'test_helper'

describe Unitwise::Expression::Decomposer do
  subject { Unitwise::Expression::Decomposer }

  describe "#terms" do
    it "should accept codes" do
      fts = subject.new("[ft_i]/s").terms
      fts.count.must_equal 2
    end
    it "should accept names" do
      kms = subject.new("kilometer/second").terms
      kms.count.must_equal 2
    end
    it "should accept spaced names" do
      ncg = subject.new("Newtonian constant of gravitation").terms
      ncg.count.must_equal 1
    end
    it "should accept parameterized names" do
      pc = subject.new("planck_constant").terms
      pc.count.must_equal 1
    end
    it "should accept symbols" do
      saff = subject.new("<i>g<sub>n</sub></i>").terms
      saff.count.must_equal 1
    end
    it "should accept complex units" do
      complex = subject.new("(mg.(km/s)3/J)2.Pa").terms
      complex.count.must_equal 5
    end
    it "should accept more complex units" do
      complex = subject.new("4.1(mm/2s3)4.7.3J-2").terms
      complex.count.must_equal 3
    end
    it "should accept weird units" do
      frequency = subject.new("/s").terms
      frequency.count.must_equal 1
    end
    it "should accept units with a factor and unit" do
      oddity = subject.new("2ms2").terms
      oddity.count.must_equal 1
    end
  end

end

Version data entries

26 entries across 26 versions & 2 rubygems

Version Path
unitwise-2.3.0 test/unitwise/expression/decomposer_test.rb
unitwise-2.2.0 test/unitwise/expression/decomposer_test.rb
unitwise-2.1.0 test/unitwise/expression/decomposer_test.rb
unitwise-2.0.0 test/unitwise/expression/decomposer_test.rb
unitwise-1.1.0 test/unitwise/expression/decomposer_test.rb
unitwise-193-1.0.4 test/unitwise/expression/decomposer_test.rb
unitwise-1.0.4 test/unitwise/expression/decomposer_test.rb
unitwise-1.0.3 test/unitwise/expression/decomposer_test.rb
unitwise-1.0.2 test/unitwise/expression/decomposer_test.rb
unitwise-1.0.1 test/unitwise/expression/decomposer_test.rb
unitwise-1.0.0 test/unitwise/expression/decomposer_test.rb
unitwise-0.10.0 test/unitwise/expression/decomposer_test.rb
unitwise-0.9.1 test/unitwise/expression/decomposer_test.rb
unitwise-0.9.0 test/unitwise/expression/decomposer_test.rb
unitwise-0.8.1 test/unitwise/expression/decomposer_test.rb
unitwise-0.8.0 test/unitwise/expression/decomposer_test.rb
unitwise-0.7.1 test/unitwise/expression/decomposer_test.rb
unitwise-0.7.0 test/unitwise/expression/decomposer_test.rb
unitwise-0.6.2 test/unitwise/expression/decomposer_test.rb
unitwise-0.6.1 test/unitwise/expression/decomposer_test.rb