File: const_test.rb

package info (click to toggle)
ruby-gsl 2.1.0.3%2Bdfsg1-5
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 5,604 kB
  • sloc: ansic: 62,050; ruby: 15,845; sh: 19; makefile: 10
file content (29 lines) | stat: -rw-r--r-- 726 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
require 'test_helper'

class ConstTest < GSL::TestCase

  def test_speed_of_light
    c   = GSL::CONST::MKSA::SPEED_OF_LIGHT
    eps = GSL::CONST::MKSA::VACUUM_PERMITTIVITY
    mu  = GSL::CONST::MKSA::VACUUM_PERMEABILITY

    assert_rel c, 1.0 / GSL.sqrt(eps * mu), 1e-6, 'speed of light (mks)'
  end

  def test_light_year
    ly = GSL::CONST::CGSM::LIGHT_YEAR
    c  = GSL::CONST::CGSM::SPEED_OF_LIGHT
    y  = 365.2425 * GSL::CONST::CGSM::DAY

    assert_rel ly, c * y, 1e-6, 'light year (cgs)'
  end

  def test_kilo
    micro = GSL::CONST::NUM::MICRO
    mega  = GSL::CONST::NUM::MEGA
    kilo  = GSL::CONST::NUM::KILO

    assert_rel mega / kilo, 1 / (micro * kilo), 1e-10, 'kilo (mega/kilo, 1/(micro*kilo))'
  end

end