Commit 74f62580 authored by Marc Gravell's avatar Marc Gravell

Merge pull request #5 from matteobaglini/master

Fix: Null RedisValue from boolean value
parents 732cea8c eb2608cc
using System.Linq;
using NUnit.Framework;
namespace StackExchange.Redis.Tests
{
[TestFixture]
public class Bits : TestBase
{
[Test]
public void BasicOps()
{
using (var conn = Create())
{
var db = conn.GetDatabase();
RedisKey key = Me();
db.KeyDelete(key, CommandFlags.FireAndForget);
db.StringSetBit(key, 10, true);
Assert.True(db.StringGetBit(key, 10));
Assert.False(db.StringGetBit(key, 11));
}
}
}
}
\ No newline at end of file
...@@ -42,6 +42,13 @@ public void TestValues() ...@@ -42,6 +42,13 @@ public void TestValues()
RedisValue i8 = 1L; RedisValue i8 = 1L;
CheckNotNull(i8); CheckNotNull(i8);
RedisValue bool1 = true;
CheckNotNull(bool1);
RedisValue bool2 = false;
CheckNotNull(bool2);
RedisValue bool3 = true;
CheckNotNull(bool3);
CheckSame(a0, a0); CheckSame(a0, a0);
CheckSame(a1, a1); CheckSame(a1, a1);
CheckSame(a0, a1); CheckSame(a0, a1);
...@@ -53,6 +60,9 @@ public void TestValues() ...@@ -53,6 +60,9 @@ public void TestValues()
CheckSame(i4, i4); CheckSame(i4, i4);
CheckSame(i8, i8); CheckSame(i8, i8);
CheckSame(i4, i8); CheckSame(i4, i8);
CheckSame(bool1, bool3);
CheckNotSame(bool1, bool2);
} }
private void CheckSame(RedisValue x, RedisValue y) private void CheckSame(RedisValue x, RedisValue y)
......
...@@ -62,6 +62,7 @@ ...@@ -62,6 +62,7 @@
<ItemGroup> <ItemGroup>
<Compile Include="AsyncTests.cs" /> <Compile Include="AsyncTests.cs" />
<Compile Include="BasicOps.cs" /> <Compile Include="BasicOps.cs" />
<Compile Include="Bits.cs" />
<Compile Include="Cluster.cs" /> <Compile Include="Cluster.cs" />
<Compile Include="Commands.cs" /> <Compile Include="Commands.cs" />
<Compile Include="ConnectionShutdown.cs" /> <Compile Include="ConnectionShutdown.cs" />
......
...@@ -274,7 +274,7 @@ internal RedisValue Assert() ...@@ -274,7 +274,7 @@ internal RedisValue Assert()
/// </summary> /// </summary>
public static implicit operator RedisValue(bool value) public static implicit operator RedisValue(bool value)
{ {
return value ? new RedisValue(1, null) : new RedisValue(0, null); return value ? new RedisValue(1, IntegerSentinel) : new RedisValue(0, IntegerSentinel);
} }
/// <summary> /// <summary>
/// Creates a new RedisValue from a Boolean /// Creates a new RedisValue from a Boolean
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment