Skip to content

Commit

Permalink
test(resp): ajoute un test pour l'encodage de strings
Browse files Browse the repository at this point in the history
  • Loading branch information
MattEstHaut committed May 30, 2024
1 parent 0a4a7ee commit 0eb4239
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions tests/Shared.UnitTests/Resp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,22 @@ public void StringDecode(string input, string expected)

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

[Theory]
[InlineData("+OK\r\n")]
[InlineData("-NOT OK\r\n")]
[InlineData("$5\r\nHELLO\r\n")]
[InlineData("$6\r\n\nWORLD\r\n")]
[InlineData("$0\r\n\r\n")]
public void StringEncodeDecode(string input)
{

using var stream = new MemoryStream(Encoding.UTF8.GetBytes(input));
using var reader = new StreamReader(stream);

var item = Item.Decode(reader);
var encoded = item.Encode();

Assert.Equal(input, encoded);
}
}

0 comments on commit 0eb4239

Please sign in to comment.