Skip to content
Snippets Groups Projects
Commit ab7bab0a authored by Lars Kanis's avatar Lars Kanis
Browse files

Revert "width is a integer value, this is enforced by swig-2.0"

Add test cases for non Integer assignment to FXuchar, FXshort and FXint.

It's typically possible to assign Float values to methods expecting
Integers and we also shouldn't break compatibility.

This reverts commit 3360c669.
parent 5b1fe82f
No related branches found
No related tags found
No related merge requests found
......@@ -139,7 +139,7 @@ class ShutterWindow < FXMainWindow
def create
super
@shutter.width = (1.25*@shutter.width).to_i
@shutter.width = 1.25*@shutter.width
show(PLACEMENT_SCREEN)
end
end
......
......@@ -34,6 +34,15 @@
FXWindow* owner
}
%typemap(in) FXchar "$1 = NUM2INT($input);";
%typemap(in) FXuchar "$1 = NUM2UINT($input);";
%typemap(in) FXshort "$1 = NUM2INT($input);";
%typemap(in) FXushort "$1 = NUM2UINT($input);";
%typemap(in) FXint "$1 = NUM2INT($input);";
%typemap(in) FXuint "$1 = NUM2UINT($input);";
%typemap(in) FXlong "$1 = NUM2LONG($input);";
%typemap(in) FXulong "$1 = NUM2ULONG($input);";
/* Type-checking rules */
%typecheck(SWIG_TYPECHECK_STRING) const FXString&, FXuchar *data {
$1 = (NIL_P($input) || TYPE($input) == T_STRING) ? 1 : 0;
......
......@@ -36,6 +36,18 @@ class TC_FXSize < Test::Unit::TestCase
assert(size2.w == -(@size2.w) && size2.h == -(@size2.h))
end
def test_float
@size1.w = 2.8
@size2.h = 5.8
assert_equal(2, @size1.w)
assert_equal(5, @size2.h)
end
def test_invalid_type
assert_raise(TypeError){ @size1.w = nil }
assert_raise(TypeError){ @size2.h = true }
end
def test_add
assert_equal(FXSize.new(1, 2) + FXSize.new(3, 4), FXSize.new(4, 6))
end
......
require 'test/unit'
require 'fox16'
require 'testcase'
class TC_FXWindow < Fox::TestCase
include Fox
def setup
super(self.class.name)
@window = FXWindow.new(mainWindow)
end
def test_width_accessor
pos = @window.width
assert_instance_of(Fixnum, pos)
@window.width = pos + 1
assert_equal(pos + 1, @window.width)
@window.width = pos + 2.7
assert_equal(pos + 2, @window.width)
assert_kind_of(Integer, @window.width)
end
def test_width_invalid
assert_raise(TypeError){ @window.width = nil }
end
end
......@@ -44,6 +44,7 @@ class TC_Misc < Test::Unit::TestCase
def test_FXREDVAL
assert_equal(1, Fox.FXREDVAL(Fox.FXRGB(1, 0, 0)))
assert_equal(10, Fox.FXREDVAL(Fox.FXRGB(10.6, 0, 0)))
end
def test_FXGREENVAL
......@@ -56,6 +57,7 @@ class TC_Misc < Test::Unit::TestCase
def test_FXALPHAVAL
assert_equal(1, Fox.FXALPHAVAL(Fox.FXRGBA(0, 0, 0, 1)))
assert_equal(10, Fox.FXALPHAVAL(Fox.FXRGBA(0, 0, 0, 10.6)))
end
def test_FXRGBACOMPVAL
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment