From 59a4054df49061d53a58d1f8e1957b4940cff636 Mon Sep 17 00:00:00 2001 From: Kenta Murata Date: Sun, 31 Jan 2021 14:41:44 +0900 Subject: [PATCH] Add test to reproduce the issue reported in GH-66 --- test/fiddle/test_cstruct.rb | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 test/fiddle/test_cstruct.rb diff --git a/test/fiddle/test_cstruct.rb b/test/fiddle/test_cstruct.rb new file mode 100644 index 00000000..d71cc495 --- /dev/null +++ b/test/fiddle/test_cstruct.rb @@ -0,0 +1,20 @@ +# frozen_string_literal: true +begin + require_relative 'helper' +rescue LoadError +end + +module Fiddle + class TestStruct < TestCase + # https://github.com/ruby/fiddle/issues/66 + def test_clone_gh_66 + s = Fiddle::Importer.struct(["int i"]) + a = s.malloc + a.i = 10 + b = a.clone + b.i = 20 + assert_equal({a: 10, b: 20}, + {a: a.i, b: b.i}) + end + end +end