-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d751e08
commit 9f78b7a
Showing
20 changed files
with
543 additions
and
24 deletions.
There are no files selected for viewing
Binary file modified
BIN
-48 Bytes
(100%)
src/FolkerKinzel.Strings.Doku.de/Help/FolkerKinzel.Strings.Doku.de.chm
Binary file not shown.
Binary file modified
BIN
+20.9 KB
(110%)
src/FolkerKinzel.Strings.Reference.en/Help/FolkerKinzel.Strings.Reference.en.chm
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
dotnet test /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura /p:CoverletOutput=./reports/ /p:ExcludeByAttribute=\"Obsolete,GeneratedCode,CompilerGenerated\" /p:SkipAutoProps=true /p:DoesNotReturnAttribute="DoesNotReturnAttribute" | ||
reportgenerator -reports:./reports/coverage.netcoreapp2.1.cobertura.xml -targetdir:./reports/html/ | ||
reportgenerator -reports:./reports/coverage.cobertura.xml -targetdir:./reports/html/ | ||
cd reports/html/ | ||
index.htm |
41 changes: 41 additions & 0 deletions
41
src/FolkerKinzel.Strings.Tests/DecoderValidationFallbackTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using FolkerKinzel.Strings; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace FolkerKinzel.Strings.Tests; | ||
|
||
[TestClass()] | ||
public class DecoderValidationFallbackTests | ||
{ | ||
[TestMethod()] | ||
public void ResetTest() | ||
{ | ||
var fb = new DecoderValidationFallback(); | ||
Assert.IsFalse(fb.HasError); | ||
|
||
var enc = Encoding.GetEncoding("UTF-8", EncoderFallback.ReplacementFallback, fb); | ||
using var stream = new MemoryStream(new byte[] { 129, 142, 210, 184}); | ||
using var reader = new StreamReader(stream, enc, false); | ||
string s = reader.ReadToEnd(); | ||
Assert.IsTrue(fb.HasError); | ||
fb.Reset(); | ||
Assert.IsFalse(fb.HasError); | ||
} | ||
|
||
[TestMethod()] | ||
public void CreateFallbackBufferTest() | ||
{ | ||
var fb = new DecoderValidationFallback(); | ||
DecoderFallbackBuffer buf1 = fb.CreateFallbackBuffer(); | ||
DecoderFallbackBuffer buf2 = fb.CreateFallbackBuffer(); | ||
Assert.AreSame(buf1, buf2); | ||
|
||
buf1.Reset(); | ||
Assert.AreEqual(0, buf1.Remaining); | ||
Assert.IsFalse(buf1.MovePrevious()); | ||
} | ||
} |
4 changes: 2 additions & 2 deletions
4
src/FolkerKinzel.Strings.Tests/FolkerKinzel.Strings.Tests.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
|
||
namespace FolkerKinzel.Strings.Tests; | ||
|
||
[TestClass] | ||
public class StreamExtensionTests | ||
{ | ||
private readonly byte[] _validUtf8 = new byte[] { 17, 4, 42 }; | ||
private readonly byte[] _noUtf8 = new byte[] { 129, 142, 210, 184 }; | ||
private readonly byte[] _bom = new byte[] { 0xEF, 0xBB, 0xBF }; | ||
|
||
|
||
[TestMethod] | ||
[ExpectedException(typeof(ArgumentNullException))] | ||
public void IsUtf8Test1() | ||
{ | ||
Stream? str = null; | ||
str!.IsUtf8(); | ||
} | ||
|
||
|
||
[TestMethod] | ||
public void IsUtf8Test2() | ||
{ | ||
using var str = new MemoryStream(); | ||
Assert.IsFalse(str.IsUtf8(count: 0)); | ||
} | ||
|
||
[TestMethod] | ||
public void IsUtf8Test3() | ||
{ | ||
using var str = new MemoryStream(_validUtf8.Concat(_validUtf8).ToArray()); | ||
Assert.IsFalse(str.IsUtf8(count: 0, leaveOpen: true)); | ||
str.Position = 0; | ||
Assert.IsTrue(str.IsUtf8()); | ||
} | ||
|
||
[TestMethod] | ||
public void IsUtf8Test4() | ||
{ | ||
|
||
using (var str1 = new MemoryStream(_noUtf8)) | ||
{ | ||
Assert.IsFalse(str1.IsUtf8()); | ||
} | ||
|
||
using (var str2 = new MemoryStream(_bom)) | ||
{ | ||
Assert.IsTrue(str2.IsUtf8Valid()); | ||
} | ||
|
||
var concat = new List<byte>(_bom); | ||
concat.AddRange(_noUtf8); | ||
|
||
var concatBytes = concat.ToArray(); | ||
|
||
using var str3 = new MemoryStream(concatBytes); | ||
|
||
Assert.IsTrue(str3.IsUtf8(leaveOpen: true)); | ||
str3.Position = 0; | ||
Assert.IsFalse(str3.IsUtf8Valid()); | ||
} | ||
|
||
[TestMethod] | ||
public void IsUtf8Test5() | ||
{ | ||
var list = new List<byte>(_validUtf8); | ||
list.AddRange(_noUtf8); | ||
using var stream = new MemoryStream(list.ToArray()); | ||
Assert.IsFalse(stream.IsUtf8()); | ||
} | ||
|
||
|
||
[TestMethod] | ||
[ExpectedException(typeof(ArgumentOutOfRangeException))] | ||
public void IsUtf8ValidTest1() | ||
{ | ||
using var str = new MemoryStream(_validUtf8); | ||
_ = str.IsUtf8Valid(count: 0); | ||
} | ||
|
||
[TestMethod] | ||
[ExpectedException(typeof(ArgumentNullException))] | ||
public void IsUtf8ValidTest2() | ||
{ | ||
Stream? str = null; | ||
str!.IsUtf8Valid(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.