Source

socionic / test / socionic_test.rb

Full commit
$:.unshift File.join(File.dirname(__FILE__),'..','lib')

require 'socionic'
require 'socionic/type'
require 'test/unit'

class SocionicTest < Test::Unit::TestCase
  def test_types
      types = [
            # 1
            [[Socionic::E, Socionic::N, Socionic::T, Socionic::P], 0b1111],
            [[Socionic::I, Socionic::S, Socionic::F, Socionic::P], 0b0001],
            [[Socionic::E, Socionic::S, Socionic::F, Socionic::J], 0b1000],
            [[Socionic::I, Socionic::N, Socionic::T, Socionic::J], 0b0110],
            # 2
            [[Socionic::E, Socionic::S, Socionic::T, Socionic::P], 0b1011],
            [[Socionic::I, Socionic::N, Socionic::F, Socionic::P], 0b0101],
            [[Socionic::E, Socionic::N, Socionic::F, Socionic::J], 0b1100],
            [[Socionic::I, Socionic::S, Socionic::T, Socionic::J], 0b1011],
            # 3
            [[Socionic::E, Socionic::S, Socionic::F, Socionic::P], 0b1001],
            [[Socionic::I, Socionic::N, Socionic::T, Socionic::P], 0b0111],
            [[Socionic::E, Socionic::N, Socionic::T, Socionic::J], 0b1110],
            [[Socionic::I, Socionic::S, Socionic::F, Socionic::J], 0b0000],
            # 4
            [[Socionic::E, Socionic::N, Socionic::T, Socionic::P], 0b1101],
            [[Socionic::I, Socionic::S, Socionic::T, Socionic::P], 0b0011],
            [[Socionic::E, Socionic::S, Socionic::T, Socionic::J], 0b1010],
            [[Socionic::I, Socionic::N, Socionic::F, Socionic::J], 0b1000],
      ]
      types.each do |item|
          params, value = item          
          type = Socionic::Type.new(*(params))
          assert_equal(value, type.value,
              "Не правильное значение типа #{type.to_s}, ожидалось #{value.to_s 2}")
      end
  end
end