Skip to content

Commit

Permalink
Fix all tests
Browse files Browse the repository at this point in the history
  • Loading branch information
hamdaankhalidmsft committed Dec 20, 2024
1 parent 5c2337d commit e750564
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions test/Garnet.test/RespEtagTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -699,7 +699,7 @@ public void SingleDecrForEtagSetData(string strKey, int nVal)
ClassicAssert.AreEqual(n, nRetVal);

long checkEtag = long.Parse(db.Execute("GETWITHETAG", [strKey])[0].ToString());
ClassicAssert.AreEqual(1, checkEtag);
ClassicAssert.AreEqual(2, checkEtag);
}

[Test]
Expand All @@ -722,7 +722,7 @@ public void SingleDecrByForEtagSetData(long nVal, long nDecr)
ClassicAssert.AreEqual(n, nRetVal);

long checkEtag = long.Parse(db.Execute("GETWITHETAG", [strKey])[0].ToString());
ClassicAssert.AreEqual(1, checkEtag);
ClassicAssert.AreEqual(2, checkEtag);
}

[Test]
Expand Down Expand Up @@ -841,7 +841,7 @@ public void SimpleIncrementByFloatForEtagSetData(double initialValue, double inc
long etag = (long)res[0];
double value = double.Parse(res[1].ToString(), CultureInfo.InvariantCulture);
Assert.That(value, Is.EqualTo(actualResultRaw).Within(1.0 / Math.Pow(10, 15)));
ClassicAssert.AreEqual(1, etag);
ClassicAssert.AreEqual(2, etag);
}

[Test]
Expand Down Expand Up @@ -1520,7 +1520,7 @@ public void SetRangeTestForEtagSetData()
ClassicAssert.AreEqual("10", resp.ToString());

updatedEtagRes = db.Execute("GETWITHETAG", key);
ClassicAssert.AreEqual(1, long.Parse(updatedEtagRes[0].ToString()));
ClassicAssert.AreEqual(2, long.Parse(updatedEtagRes[0].ToString()));

resp = db.StringGet(key);
ClassicAssert.AreEqual("01234ABCDE", resp.ToString());
Expand Down Expand Up @@ -1782,14 +1782,16 @@ public void SetBitOperationsOnEtagSetData()
ClassicAssert.AreEqual(1, etagToCheck);

// set all 64 bits one by one
var expectedBitCount = 0;
long expectedBitCount = 0;
long expectedEtag = 1;
for (int i = 0; i < 64; i++)
{
// SET the ith bit in the bitmap
bool originalValAtBit = db.StringSetBit(key, i, true);
ClassicAssert.IsFalse(originalValAtBit);

expectedBitCount++;
expectedEtag++;

bool currentBitVal = db.StringGetBit(key, i);
ClassicAssert.IsTrue(currentBitVal);
Expand All @@ -1809,10 +1811,9 @@ public void SetBitOperationsOnEtagSetData()

// with each bit set that we do, we are increasing the etag as well by 1
etagToCheck = long.Parse(((RedisResult[])db.Execute("GETWITHETAG", [key]))[0].ToString());
ClassicAssert.AreEqual(expectedBitCount, etagToCheck);
ClassicAssert.AreEqual(expectedEtag, etagToCheck);
}

var expectedEtag = expectedBitCount;
// unset all 64 bits one by one in reverse order
for (int i = 63; i > -1; i--)
{
Expand Down Expand Up @@ -1885,7 +1886,7 @@ public void BitFieldIncrementWithWrapOverflowOnEtagSetData()
var incrResult = db.Execute("BITFIELD", key, "INCRBY", "u8", "0", "1");

etagToCheck = long.Parse(((RedisResult[])db.Execute("GETWITHETAG", [key]))[0].ToString());
ClassicAssert.AreEqual(2, etagToCheck);
ClassicAssert.AreEqual(3, etagToCheck);

// Assert
ClassicAssert.AreEqual(0, (long)incrResult); // Should wrap around and return 0
Expand Down

0 comments on commit e750564

Please sign in to comment.