[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[libcaca] Re: [PATCH] ruby/caca-display.c: Use UINT2NUM instead of NUM2UINT.



I have no idea, why that got sent 3 times, please only look at the last email. 

Sorry about that.

-Tony

On Sat, Sep 10, 2011 at 11:18 AM, Tony Miller <mcfiredrill@gmail.com> wrote:
This patch fixes some functions in ruby/caca-display.c that incorrectly use
NUM2UINT instead of UINT2NUM.

I wrote some tests that use these functions.

The patch is the latest commit in this repo as well:
git://github.com/mcfiredrill/libcaca.git

-Tony

---
 ruby/caca-display.c  |   10 +++++-----
 ruby/t/tc_display.rb |   17 +++++++++++++++++
 2 files changed, 22 insertions(+), 5 deletions(-)

diff --git a/ruby/caca-display.c b/ruby/caca-display.c
index 80f90d3..6556c4d 100644
--- a/ruby/caca-display.c
+++ b/ruby/caca-display.c
@@ -114,17 +114,17 @@ static VALUE set_time2(VALUE self, VALUE t)

 static VALUE get_time(VALUE self)
 {
-    return NUM2UINT(caca_get_display_time(_SELF));
+    return UINT2NUM(caca_get_display_time(_SELF));
 }

 static VALUE get_width(VALUE self)
 {
-    return NUM2UINT(caca_get_display_width(_SELF));
+    return UINT2NUM(caca_get_display_width(_SELF));
 }

 static VALUE get_height(VALUE self)
 {
-    return NUM2UINT(caca_get_display_height(_SELF));
+    return UINT2NUM(caca_get_display_height(_SELF));
 }

 static VALUE set_title(VALUE self, VALUE t)
@@ -144,12 +144,12 @@ static VALUE set_title2(VALUE self, VALUE t)

 static VALUE get_mouse_x(VALUE self)
 {
-    return NUM2UINT(caca_get_mouse_x(_SELF));
+    return UINT2NUM(caca_get_mouse_x(_SELF));
 }

 static VALUE get_mouse_y(VALUE self)
 {
-    return NUM2UINT(caca_get_mouse_y(_SELF));
+    return UINT2NUM(caca_get_mouse_y(_SELF));
 }

 static VALUE set_mouse(VALUE self, VALUE visible)
diff --git a/ruby/t/tc_display.rb b/ruby/t/tc_display.rb
index ff2b64e..8bd3f17 100644
--- a/ruby/t/tc_display.rb
+++ b/ruby/t/tc_display.rb
@@ -31,4 +31,21 @@ class TC_Canvas < Test::Unit::TestCase
        d = Caca::Display.new()
        d.cursor = 1
    end
+    def test_get_mouse_coordinates
+        c = Caca::Canvas.new(3, 3)
+        d = Caca::Display.new(c)
+        assert_not_nil(d.mouse_x)
+        assert_not_nil(d.mouse_y)
+    end
+    def test_get_display_dimensions
+        c = Caca::Canvas.new(3, 3)
+        d = Caca::Display.new(c)
+        assert_not_nil(d.height)
+        assert_not_nil(d.width)
+    end
+    def test_get_time
+        c = Caca::Canvas.new(3, 3)
+        d = Caca::Display.new(c)
+        assert_not_nil(d.time)
+    end
 end
--
1.7.6