Migrate to dotnet8 and fix warnings
This commit is contained in:
@@ -7,60 +7,75 @@ public class ByteArraySearcherTests
|
||||
[Fact]
|
||||
public void Contains__EmptyNeedle_ReturnsTrue()
|
||||
{
|
||||
byte[] haystack = { 1, 2, 3, 4, 5 };
|
||||
// --- Arrange
|
||||
byte[] haystack = [1, 2, 3, 4, 5,];
|
||||
byte[] needle = Array.Empty<byte>();
|
||||
ByteArraySearcher searcher = new(needle);
|
||||
|
||||
// --- Act
|
||||
bool result = searcher.Contains(haystack);
|
||||
|
||||
// --- Assert
|
||||
Assert.True(result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Contains__NeedleAtBeginning_ReturnsTrue()
|
||||
{
|
||||
byte[] haystack = { 1, 2, 3, 4, 5 };
|
||||
byte[] needle = { 1, 2, 3 };
|
||||
// --- Arrange
|
||||
byte[] haystack = [1, 2, 3, 4, 5,];
|
||||
byte[] needle = [1, 2, 3,];
|
||||
ByteArraySearcher searcher = new(needle);
|
||||
|
||||
// --- Act
|
||||
bool result = searcher.Contains(haystack);
|
||||
|
||||
// --- Assert
|
||||
Assert.True(result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Contains__NeedleInMiddle_ReturnsTrue()
|
||||
{
|
||||
byte[] haystack = { 1, 2, 3, 4, 5 };
|
||||
byte[] needle = { 3, 4 };
|
||||
// --- Arrange
|
||||
byte[] haystack = [1, 2, 3, 4, 5,];
|
||||
byte[] needle = [3, 4,];
|
||||
ByteArraySearcher searcher = new(needle);
|
||||
|
||||
// --- Act
|
||||
bool result = searcher.Contains(haystack);
|
||||
|
||||
// --- Assert
|
||||
Assert.True(result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Contains__NeedleAtEnd_ReturnsTrue()
|
||||
{
|
||||
byte[] haystack = { 1, 2, 3, 4, 5 };
|
||||
byte[] needle = { 4, 5 };
|
||||
// --- Arrange
|
||||
byte[] haystack = [1, 2, 3, 4, 5,];
|
||||
byte[] needle = [4, 5,];
|
||||
ByteArraySearcher searcher = new(needle);
|
||||
|
||||
// --- Act
|
||||
bool result = searcher.Contains(haystack);
|
||||
|
||||
// --- Assert
|
||||
Assert.True(result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Contains__NeedleNotPresent_ReturnsFalse()
|
||||
{
|
||||
byte[] haystack = { 1, 2, 3, 4, 5 };
|
||||
byte[] needle = { 5, 6, 7 };
|
||||
// --- Arrange
|
||||
byte[] haystack = [1, 2, 3, 4, 5,];
|
||||
byte[] needle = [5, 6, 7,];
|
||||
ByteArraySearcher searcher = new(needle);
|
||||
|
||||
// --- Act
|
||||
bool result = searcher.Contains(haystack);
|
||||
|
||||
// --- Assert
|
||||
Assert.False(result);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@ namespace CvsLib;
|
||||
|
||||
public class CsvFieldIndexerTests
|
||||
{
|
||||
|
||||
#region GenerateIndex
|
||||
|
||||
[Fact]
|
||||
@@ -51,10 +50,11 @@ public class CsvFieldIndexerTests
|
||||
public void GenerateIndex__TwoLinesOfPainText__TwoRows()
|
||||
{
|
||||
// --- Arrange
|
||||
StringReader sr = new("""
|
||||
Hello World
|
||||
Hello World
|
||||
""");
|
||||
StringReader sr = new(
|
||||
"""
|
||||
Hello World
|
||||
Hello World
|
||||
""");
|
||||
|
||||
// --- Act
|
||||
CsvFieldIndexer indexer = new();
|
||||
@@ -80,10 +80,11 @@ public class CsvFieldIndexerTests
|
||||
public void GenerateIndex__TwoLinesOfQuotedText__TwoRows()
|
||||
{
|
||||
// --- Arrange
|
||||
StringReader sr = new("""
|
||||
"Hello World"
|
||||
"Hello World"
|
||||
""");
|
||||
StringReader sr = new(
|
||||
"""
|
||||
"Hello World"
|
||||
"Hello World"
|
||||
""");
|
||||
|
||||
// --- Act
|
||||
CsvFieldIndexer indexer = new();
|
||||
@@ -109,10 +110,11 @@ public class CsvFieldIndexerTests
|
||||
public void GenerateIndex__TwoLinesWithTwoQuotedColumns__TwoRowsTwoFields()
|
||||
{
|
||||
// --- Arrange
|
||||
StringReader sr = new("""
|
||||
"Hello","World"
|
||||
"Hello","World"
|
||||
""");
|
||||
StringReader sr = new(
|
||||
"""
|
||||
"Hello","World"
|
||||
"Hello","World"
|
||||
""");
|
||||
|
||||
// --- Act
|
||||
CsvFieldIndexer indexer = new();
|
||||
@@ -142,10 +144,11 @@ public class CsvFieldIndexerTests
|
||||
public void GenerateIndex__TwoLinesWithTwoQuotedColumnsWithUnicode__TwoRowsTwoFields()
|
||||
{
|
||||
// --- Arrange
|
||||
StringReader sr = new("""
|
||||
"Hélló","Wórld"
|
||||
"Hélló","Wórld"
|
||||
""");
|
||||
StringReader sr = new(
|
||||
"""
|
||||
"Hélló","Wórld"
|
||||
"Hélló","Wórld"
|
||||
""");
|
||||
|
||||
// --- Act
|
||||
CsvFieldIndexer indexer = new();
|
||||
@@ -174,15 +177,16 @@ public class CsvFieldIndexerTests
|
||||
#endregion GenerateIndex
|
||||
|
||||
#region Search
|
||||
|
||||
|
||||
[Fact]
|
||||
public void Search__TwoLinesWithTwoQuotedColumns__OneIndexFirstRow()
|
||||
{
|
||||
// --- Arrange
|
||||
string strText = """
|
||||
"Hello","test"
|
||||
"Hello","World"
|
||||
""";
|
||||
const string strText =
|
||||
"""
|
||||
"Hello","test"
|
||||
"Hello","World"
|
||||
""";
|
||||
StringReader sr = new(strText);
|
||||
CsvFieldIndexer indexer = new();
|
||||
indexer.GenerateIndex(sr);
|
||||
@@ -202,10 +206,11 @@ public class CsvFieldIndexerTests
|
||||
public void Search__TwoLinesWithTwoQuotedColumns__OneIndexSecondRow()
|
||||
{
|
||||
// --- Arrange
|
||||
string strText = """
|
||||
"Hello","World"
|
||||
"Hello","test"
|
||||
""";
|
||||
const string strText =
|
||||
"""
|
||||
"Hello","World"
|
||||
"Hello","test"
|
||||
""";
|
||||
StringReader sr = new(strText);
|
||||
CsvFieldIndexer indexer = new();
|
||||
indexer.GenerateIndex(sr);
|
||||
@@ -225,10 +230,11 @@ public class CsvFieldIndexerTests
|
||||
public void Search__TwoLinesWithTwoQuotedColumnsTwoMatches__OneIndexSecondRow()
|
||||
{
|
||||
// --- Arrange
|
||||
string strText = """
|
||||
"Hello","World"
|
||||
"test","test"
|
||||
""";
|
||||
const string strText =
|
||||
"""
|
||||
"Hello","World"
|
||||
"test","test"
|
||||
""";
|
||||
StringReader sr = new(strText);
|
||||
CsvFieldIndexer indexer = new();
|
||||
indexer.GenerateIndex(sr);
|
||||
@@ -243,7 +249,7 @@ public class CsvFieldIndexerTests
|
||||
Assert.Single(indexes);
|
||||
Assert.Equal(16, indexes[0]);
|
||||
}
|
||||
|
||||
|
||||
#endregion Search
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<RootNamespace>CvsLib</RootNamespace>
|
||||
|
||||
Reference in New Issue
Block a user