Sha256: 1c6753ab8115a885ac966a44151fd2e04801717c0c5d9cc82effeb1f3b7551ba

Contents?: true

Size: 1.7 KB

Versions: 4

Compression:

Stored size: 1.7 KB

Contents

require 'spec_helper'
require 'gdal/data_type'

RSpec.describe GDAL::DataType do
  describe '.size' do
    context 'with valid data type' do
      it 'returns the size' do
        expect(described_class.size(:GDT_Byte)).to eq 8
      end
    end

    context 'with invalid data type' do
      it 'raises an ArgumentError' do
        expect do
          described_class.size(:Bob)
        end.to raise_exception(ArgumentError)
      end
    end
  end

  describe '.complex?' do
    context 'with valid, complex data type' do
      it 'returns true' do
        expect(described_class.complex?(:GDT_CFloat64)).to eq true
      end
    end

    context 'with valid, simple data type' do
      it 'returns true' do
        expect(described_class.complex?(:GDT_Float64)).to eq false
      end
    end

    context 'with invalid data type' do
      it 'raises an ArgumentError' do
        expect do
          described_class.complex?(:Bob)
        end.to raise_exception(ArgumentError)
      end
    end
  end

  describe '.name' do
    context 'with valid data type' do
      it 'returns the name' do
        expect(described_class.name(:GDT_Byte)).to eq 'Byte'
      end
    end

    context 'with invalid data type' do
      it 'raises an ArgumentError' do
        expect do
          described_class.name(:Bob)
        end.to raise_exception(ArgumentError)
      end
    end
  end

  describe '.by_name' do
    context 'with valid data type name' do
      it 'returns the data type' do
        expect(described_class.by_name('Byte')).to eq :GDT_Byte
      end
    end

    context 'with invalid data type name' do
      it 'returns :GDT_Unknown' do
        expect(described_class.by_name('Bob')).to eq :GDT_Unknown
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
ffi-gdal-1.0.0.beta7 spec/unit/gdal/data_type_spec.rb
ffi-gdal-1.0.0.beta6 spec/unit/gdal/data_type_spec.rb
ffi-gdal-1.0.0.beta5 spec/unit/gdal/data_type_spec.rb
ffi-gdal-1.0.0.beta4 spec/unit/gdal/data_type_spec.rb