Sha256: fe4982c03cbdcf598fc6202d8cbbb99613d7f0bd5ba6a172f7ef7cb7ae8ed234

Contents?: true

Size: 1.73 KB

Versions: 9

Compression:

Stored size: 1.73 KB

Contents

# frozen_string_literal: true

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

9 entries across 9 versions & 1 rubygems

Version Path
ffi-gdal-1.0.0.beta16 spec/unit/gdal/data_type_spec.rb
ffi-gdal-1.0.0.beta15 spec/unit/gdal/data_type_spec.rb
ffi-gdal-1.0.0.beta14 spec/unit/gdal/data_type_spec.rb
ffi-gdal-1.0.0.beta13 spec/unit/gdal/data_type_spec.rb
ffi-gdal-1.0.0.beta12 spec/unit/gdal/data_type_spec.rb
ffi-gdal-1.0.0.beta11 spec/unit/gdal/data_type_spec.rb
ffi-gdal-1.0.0.beta10 spec/unit/gdal/data_type_spec.rb
ffi-gdal-1.0.0.beta9 spec/unit/gdal/data_type_spec.rb
ffi-gdal-1.0.0.beta8 spec/unit/gdal/data_type_spec.rb