/
niceSOFT
/
swig
Обзор
Документация
Войти
/
niceSOFT
/
swig
Код
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
Examples/test-suite/ruby/director_binary_string_rev_len_runme.rb
29 строк
764 B
William S Fulton
Ruby: fix flaky director_binary_string_rev_len test
07 июл 2026, 11:30
07 июл 2026, 11:30
4ac5b4d
Код
Авторство
О чём код?
#!/usr/bin/env ruby # # Put description here # require 'swig_assert' require 'director_binary_string_rev_len' class DirectorBinaryStringCallback < Director_binary_string_rev_len::Callback def run(dataBufferAA) ret = 0 unless dataBufferAA.nil? dataBufferAA.each_char do |c| ret += c.ord * 2 end end return ret end end # Keep a reference to the director object in a local variable so that Ruby's GC # does not collect it while the C++ Caller still holds a (non-owning) pointer to # it - see the sibling director_binary_string test which does the same. callback = DirectorBinaryStringCallback.new caller = Director_binary_string_rev_len::Caller.new(callback) sum = caller.call() raise RuntimeError if sum != 9*2*8