<commit_before># frozen_string_literal: true

require "gir_ffi_test_helper"

GirFFI.setup :Regress
GirFFI.setup :Gio

describe GObject::Value do
  describe "::Struct" do
    describe "layout" do
      let(:layout) { GObject::Value::Struct.layout }

      it "consists of :g_type and :data" do
        _(layout.members).must_equal [:g_type, :data]
      end

      it "has an array as its second element" do
        types = layout.fields.map(&:type)
        _(types[1].class).must_equal FFI::Type::Array
      end
    end
  end

  describe ".for_gtype" do
    it "handles char" do
      gv = GObject::Value.for_gtype GObject::TYPE_CHAR
      _(gv.current_gtype).must_equal GObject::TYPE_CHAR
    end

    it "handles invalid type" do
      gv = GObject::Value.for_gtype GObject::TYPE_INVALID
      _(gv.current_gtype).must_equal GObject::TYPE_INVALID
    end

    it "handles void type" do
      gv = GObject::Value.for_gtype GObject::TYPE_NONE
      _(gv.current_gtype).must_equal GObject::TYPE_INVALID<commit_msg>Avoid calling FFI::Struct.layout in tests<commit_after># frozen_string_literal: true

require "gir_ffi_test_helper"

GirFFI.setup :Regress
GirFFI.setup :Gio

describe GObject::Value do
  describe "::Struct" do
    let(:struct) { GObject::Value::Struct }

    it "has the members :g_type and :data" do
      _(struct.members).must_equal [:g_type, :data]
    end
  end

  describe ".for_gtype" do
    it "handles char" do
      gv = GObject::Value.for_gtype GObject::TYPE_CHAR
      _(gv.current_gtype).must_equal GObject::TYPE_CHAR
    end

    it "handles invalid type" do
      gv = GObject::Value.for_gtype GObject::TYPE_INVALID
      _(gv.current_gtype).must_equal GObject::TYPE_INVALID
    end

    it "handles void type" do
      gv = GObject::Value.for_gtype GObject::TYPE_NONE
      _(gv.current_gtype).must_equal GObject::TYPE_INVALID
{'fraction_non_alphanumeric': 0.10398706896551724, 'fraction_numerical': 0.0005387931034482759, 'mean_word_length': 3.5072815533980584, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6177144', 'n_tokens_mistral': 655, 'n_tokens_neox': 643, 'n_words': 148}