1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119
|
#!/usr/bin/env ruby
#
# Put description here
#
#
#
#
#
require 'swig_assert'
require 'cpp17_string_view'
include Cpp17_string_view
# Checking expected use of %typemap(in) std::string_view {}
test_value("Fee")
# Checking expected result of %typemap(out) std::string_view {}
raise RuntimeError unless test_value("Fi") == "Fi"
# Verify type-checking for %typemap(in) std::string_view {}
exceptionRaised = false
begin
test_value(0)
rescue TypeError
exceptionRaised = true
ensure
raise RuntimeError unless exceptionRaised
end
# Checking expected use of %typemap(in) const std::string_view & {}
test_const_reference("Fo")
# Checking expected result of %typemap(out) const std::string_view& {}
raise RuntimeError unless test_const_reference("Fum") == "Fum"
# Verify type-checking for %typemap(in) const std::string_view & {}
exceptionRaised = false
begin
test_const_reference(0)
rescue TypeError
exceptionRaised = true
ensure
raise RuntimeError unless exceptionRaised
end
#
# Input and output typemaps for pointers and non-const references to
# std::string_view are *not* supported; the following tests confirm
# that none of these cases are slipping through.
#
exceptionRaised = false
begin
test_pointer("foo")
rescue TypeError
exceptionRaised = true
ensure
raise RuntimeError unless exceptionRaised
end
result = test_pointer_out()
raise RuntimeError if result.is_a? String
exceptionRaised = false
begin
test_const_pointer("bar")
rescue TypeError
exceptionRaised = true
ensure
raise RuntimeError unless exceptionRaised
end
result = test_const_pointer_out()
raise RuntimeError if result.is_a? String
result = test_reference_out()
raise RuntimeError if result.is_a? String
# Member Strings
myStructure = Structure.new
if (myStructure.ConstMemberString != "const member string")
raise RuntimeError
end
if (Structure.ConstStaticMemberString != "const static member string")
raise RuntimeError
end
if (stdstringview_empty() != "")
puts "raise RuntimeError"
end
if (c_empty() != "")
raise RuntimeError
end
if (c_null() != nil)
raise RuntimeError
end
if (get_null(c_null()) != nil)
raise RuntimeError
end
if (get_null(c_empty()) != "non-null")
raise RuntimeError
end
if (get_null(stdstringview_empty()) != "non-null")
raise RuntimeError
end
|