about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2011-02-22 19:24:55 -0800
committerEric Wong <normalperson@yhbt.net>2011-02-23 13:14:28 -0800
commitdf3d3a0b09f05249aff9f25f558f988bfcad8874 (patch)
treec7812b1a69cd0acf95a93e4974483dcbccee8e1e
parentdb192979f096d0153ad14e530e1e2e193289c7e0 (diff)
downloadraindrops-df3d3a0b09f05249aff9f25f558f988bfcad8874.tar.gz
This is the highest number a counter may be incremented to
before it overflows.
-rw-r--r--ext/raindrops/raindrops.c3
-rw-r--r--test/test_raindrops.rb6
2 files changed, 9 insertions, 0 deletions
diff --git a/ext/raindrops/raindrops.c b/ext/raindrops/raindrops.c
index 599f39d..766ee02 100644
--- a/ext/raindrops/raindrops.c
+++ b/ext/raindrops/raindrops.c
@@ -203,6 +203,9 @@ void Init_raindrops_ext(void)
 #endif
         rb_define_const(cRaindrops, "SIZE", SIZET2NUM(raindrop_size));
 
+        /* the maximum value a raindrop counter can hold */
+        rb_define_const(cRaindrops, "MAX", ULONG2NUM((unsigned long)-1));
+
         rb_define_alloc_func(cRaindrops, alloc);
 
         rb_define_method(cRaindrops, "initialize", init, 1);
diff --git a/test/test_raindrops.rb b/test/test_raindrops.rb
index aab1f14..6686796 100644
--- a/test/test_raindrops.rb
+++ b/test/test_raindrops.rb
@@ -4,6 +4,12 @@ require 'raindrops'
 
 class TestRaindrops < Test::Unit::TestCase
 
+  def test_raindrop_counter_max
+    assert_kind_of Integer, Raindrops::MAX
+    assert Raindrops::MAX > 0
+    printf "Raindrops::MAX = 0x%x\n", Raindrops::MAX
+  end
+
   def test_raindrop_size
     assert_kind_of Integer, Raindrops::SIZE
     assert Raindrops::SIZE > 0