Codebase list ruby-fxruby / ab7bab0
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 3360c669df027835ca8a06e69574478a4faa8d51. Lars Kanis 10 years ago
5 changed file(s) with 50 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
138138
139139 def create
140140 super
141 @shutter.width = (1.25*@shutter.width).to_i
141 @shutter.width = 1.25*@shutter.width
142142 show(PLACEMENT_SCREEN)
143143 end
144144 end
3333 FXWindow* owner
3434 }
3535
36 %typemap(in) FXchar "$1 = NUM2INT($input);";
37 %typemap(in) FXuchar "$1 = NUM2UINT($input);";
38 %typemap(in) FXshort "$1 = NUM2INT($input);";
39 %typemap(in) FXushort "$1 = NUM2UINT($input);";
40 %typemap(in) FXint "$1 = NUM2INT($input);";
41 %typemap(in) FXuint "$1 = NUM2UINT($input);";
42 %typemap(in) FXlong "$1 = NUM2LONG($input);";
43 %typemap(in) FXulong "$1 = NUM2ULONG($input);";
44
3645 /* Type-checking rules */
3746 %typecheck(SWIG_TYPECHECK_STRING) const FXString&, FXuchar *data {
3847 $1 = (NIL_P($input) || TYPE($input) == T_STRING) ? 1 : 0;
3535 assert(size2.w == -(@size2.w) && size2.h == -(@size2.h))
3636 end
3737
38 def test_float
39 @size1.w = 2.8
40 @size2.h = 5.8
41 assert_equal(2, @size1.w)
42 assert_equal(5, @size2.h)
43 end
44
45 def test_invalid_type
46 assert_raise(TypeError){ @size1.w = nil }
47 assert_raise(TypeError){ @size2.h = true }
48 end
49
3850 def test_add
3951 assert_equal(FXSize.new(1, 2) + FXSize.new(3, 4), FXSize.new(4, 6))
4052 end
0 require 'test/unit'
1 require 'fox16'
2 require 'testcase'
3
4 class TC_FXWindow < Fox::TestCase
5 include Fox
6
7 def setup
8 super(self.class.name)
9 @window = FXWindow.new(mainWindow)
10 end
11
12 def test_width_accessor
13 pos = @window.width
14 assert_instance_of(Fixnum, pos)
15 @window.width = pos + 1
16 assert_equal(pos + 1, @window.width)
17 @window.width = pos + 2.7
18 assert_equal(pos + 2, @window.width)
19 assert_kind_of(Integer, @window.width)
20 end
21
22 def test_width_invalid
23 assert_raise(TypeError){ @window.width = nil }
24 end
25 end
4343
4444 def test_FXREDVAL
4545 assert_equal(1, Fox.FXREDVAL(Fox.FXRGB(1, 0, 0)))
46 assert_equal(10, Fox.FXREDVAL(Fox.FXRGB(10.6, 0, 0)))
4647 end
4748
4849 def test_FXGREENVAL
5556
5657 def test_FXALPHAVAL
5758 assert_equal(1, Fox.FXALPHAVAL(Fox.FXRGBA(0, 0, 0, 1)))
59 assert_equal(10, Fox.FXALPHAVAL(Fox.FXRGBA(0, 0, 0, 10.6)))
5860 end
5961
6062 def test_FXRGBACOMPVAL