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
33 | 33 |
FXWindow* owner
|
34 | 34 |
}
|
35 | 35 |
|
|
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 |
|
36 | 45 |
/* Type-checking rules */
|
37 | 46 |
%typecheck(SWIG_TYPECHECK_STRING) const FXString&, FXuchar *data {
|
38 | 47 |
$1 = (NIL_P($input) || TYPE($input) == T_STRING) ? 1 : 0;
|
35 | 35 |
assert(size2.w == -(@size2.w) && size2.h == -(@size2.h))
|
36 | 36 |
end
|
37 | 37 |
|
|
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 |
|
38 | 50 |
def test_add
|
39 | 51 |
assert_equal(FXSize.new(1, 2) + FXSize.new(3, 4), FXSize.new(4, 6))
|
40 | 52 |
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
|
43 | 43 |
|
44 | 44 |
def test_FXREDVAL
|
45 | 45 |
assert_equal(1, Fox.FXREDVAL(Fox.FXRGB(1, 0, 0)))
|
|
46 |
assert_equal(10, Fox.FXREDVAL(Fox.FXRGB(10.6, 0, 0)))
|
46 | 47 |
end
|
47 | 48 |
|
48 | 49 |
def test_FXGREENVAL
|
|
55 | 56 |
|
56 | 57 |
def test_FXALPHAVAL
|
57 | 58 |
assert_equal(1, Fox.FXALPHAVAL(Fox.FXRGBA(0, 0, 0, 1)))
|
|
59 |
assert_equal(10, Fox.FXALPHAVAL(Fox.FXRGBA(0, 0, 0, 10.6)))
|
58 | 60 |
end
|
59 | 61 |
|
60 | 62 |
def test_FXRGBACOMPVAL
|