mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-04-09 03:42:14 +01:00
Create and use FormattingStreamWriter
Prevents bugs causes by system cultures with different formatting
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using Xunit;
|
||||
|
||||
namespace Jellyfin.Extensions.Tests;
|
||||
|
||||
public static class FormattingStreamWriterTests
|
||||
{
|
||||
[Fact]
|
||||
public static void Shuffle_Valid_Correct()
|
||||
{
|
||||
Thread.CurrentThread.CurrentCulture = new CultureInfo("de-DE", false);
|
||||
using (var ms = new MemoryStream())
|
||||
using (var txt = new FormattingStreamWriter(ms, CultureInfo.InvariantCulture))
|
||||
{
|
||||
txt.Write("{0}", 3.14159);
|
||||
txt.Close();
|
||||
Assert.Equal("3.14159", Encoding.UTF8.GetString(ms.ToArray()));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user