From 420584a46d757f22525682ecbb9e41b7b410d03a Mon Sep 17 00:00:00 2001
From: antirez <antirez@gmail.com>
Date: Fri, 18 Jul 2014 10:55:08 +0200
Subject: [PATCH] Test: small integer sharing depends on maxmemory policy.

---
 tests/unit/maxmemory.tcl | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/tests/unit/maxmemory.tcl b/tests/unit/maxmemory.tcl
index 2cde1d83..1431a2ac 100644
--- a/tests/unit/maxmemory.tcl
+++ b/tests/unit/maxmemory.tcl
@@ -1,4 +1,28 @@
 start_server {tags {"maxmemory"}} {
+    test "Without maxmemory small integers are shared" {
+        r config set maxmemory 0
+        r set a 1
+        assert {[r object refcount a] > 1}
+    }
+
+    test "With maxmemory and non-LRU policy integers are still shared" {
+        r config set maxmemory 1073741824
+        r config set maxmemory-policy allkeys-random
+        r set a 1
+        assert {[r object refcount a] > 1}
+    }
+
+    test "With maxmemory and LRU policy integers are not shared" {
+        r config set maxmemory 1073741824
+        r config set maxmemory-policy allkeys-lru
+        r set a 1
+        r config set maxmemory-policy volatile-lru
+        r set b 1
+        assert {[r object refcount a] == 1}
+        assert {[r object refcount b] == 1}
+        r config set maxmemory 0
+    }
+
     foreach policy {
         allkeys-random allkeys-lru volatile-lru volatile-random volatile-ttl
     } {