Skip to content

Commit

Permalink
test(resp): ajoute un test pour le décodage de strings
Browse files Browse the repository at this point in the history
  • Loading branch information
MattEstHaut committed May 30, 2024
1 parent de0a444 commit 0a4a7ee
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions tests/Shared.UnitTests/Resp.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using System.Text;
using Shared.Resp;

namespace Shared.unitTests;

public class RespTests
{
[Theory]
[InlineData("+OK\r\n", "OK")]
[InlineData("-NOT OK\r\n", "NOT OK")]
[InlineData("$5\r\nHELLO\r\n", "HELLO")]
[InlineData("$6\r\n\nWORLD\r\n", "\nWORLD")]
[InlineData("$0\r\n\r\n", "")]
public void StringDecode(string input, string expected)
{
using var stream = new MemoryStream(Encoding.UTF8.GetBytes(input));
using var reader = new StreamReader(stream);

var result = Item.Decode(reader);

Assert.Equal(expected, result.ToString());
}
}

0 comments on commit 0a4a7ee

Please sign in to comment.