Skip to content

Commit

Permalink
Merge pull request #32 from creeperlv/develop
Browse files Browse the repository at this point in the history
1.30.31.0
  • Loading branch information
creeperlv authored Aug 2, 2024
2 parents e0fced5 + 26a559a commit 58f45b4
Show file tree
Hide file tree
Showing 5 changed files with 649 additions and 451 deletions.
18 changes: 12 additions & 6 deletions LibCLCC.NET.NUnit/LibCLCC.NET.NUnit.csproj
Original file line number Diff line number Diff line change
@@ -1,19 +1,25 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>

<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.2" />
<PackageReference Include="NUnit" Version="3.13.3" />
<PackageReference Include="NUnit3TestAdapter" Version="4.2.1" />
<PackageReference Include="NUnit.Analyzers" Version="3.3.0" />
<PackageReference Include="coverlet.collector" Version="3.1.2" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
<PackageReference Include="NUnit" Version="4.1.0" />
<PackageReference Include="NUnit3TestAdapter" Version="4.6.0" />
<PackageReference Include="NUnit.Analyzers" Version="4.2.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="6.0.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
Expand Down
171 changes: 107 additions & 64 deletions LibCLCC.NET.NUnit/RefStringTests.cs
Original file line number Diff line number Diff line change
@@ -1,74 +1,117 @@
using LibCLCC.NET.Data;
using System.Diagnostics;

namespace LibCLCC.NET.NUnit
{
public class RefStringTests
{
string ori = "/A/B/C//D\\E";
[SetUp]
public void Setup()
{
}
[Test]
public void ParsingTest()
{
string input = "ASD123.001DEF";
RefString A = input;
A.Offset = 3;
A.Length = 3;
{
Assert.Multiple(() =>
{
Assert.That(A.TryParse(out int v), Is.True);
Assert.That(v, Is.EqualTo(123));
});
}
public class RefStringTests
{
string ori = "/A/B/C//D\\E";
[SetUp]
public void Setup()
{
}
[Test]
public void SubStringTest()
{
string str = "This is a sentence. A very long sentence.";
RefString rstr = str;
var SubString0 = rstr.Substring(0, 4);
{
string str2 = "This";
Assert.That(SubString0 == str2);
}
{
string str2 = "That";
Assert.That(SubString0 != str2);
}
{
string str2 = "Tha";
Assert.That(SubString0 != str2);
}
{
string str2 = "This is not equal.";
Assert.That(SubString0 != str2);
}
var SubString1 = rstr.Substring(5);
{
Assert.That(SubString1 == str.Substring(5));
}
{
Assert.That(SubString1 == ((RefString)str).Substring(5));
}
{
Assert.That(SubString1.StartsWith("is"));
}
}
[Test]
public void EndsWithTest()
{
RefString rstr = "new RefString()";
RefString R0 = "()";
Assert.That(rstr.EndsWith(R0));
Assert.That(rstr.Substring(2).EndsWith(R0));
Assert.That(rstr.Substring(0,3).EndsWith("ew"));
}
[Test]
public void ParsingTest()
{
string input = "ASD123.001DEF";
RefString A = input;
A.Offset = 3;
A.Length = 3;
{
Assert.Multiple(() =>
{
Assert.That(A.TryParse(out int v), Is.True);
Assert.That(v, Is.EqualTo(123));
});
}

A.Length += 4;
{
Assert.Multiple(() =>
{
Assert.That(A.TryParse(out float v), Is.True);
Assert.That(v, Is.EqualTo(123.001f));
});
}
A.Length += 4;
{
Assert.Multiple(() =>
{
Assert.That(A.TryParse(out float v), Is.True);
Assert.That(v, Is.EqualTo(123.001f));
});
}

A.Length += 1;
{
Assert.Multiple(() =>
{
Assert.That(A.TryParse(out double v), Is.True);
Assert.That(v, Is.EqualTo(123.001));
});
}
A.Length += 1;
{
Assert.Multiple(() =>
{
Assert.That(A.TryParse(out double v), Is.True);
Assert.That(v, Is.EqualTo(123.001));
});
}

string Testee_00 = "ASD";
string Testee_01 = "DEF";
A.Offset=0;
A.Length=input.Length;
Assert.Multiple(() =>
{
Assert.That(A.StartsWith(Testee_00), Is.True);
Assert.That(A.StartsWith(Testee_01), Is.False);
Assert.That(A.EndsWith(Testee_00), Is.False);
Assert.That(A.EndsWith(Testee_01), Is.True);
});
}
string Testee_00 = "ASD";
string Testee_01 = "DEF";
A.Offset = 0;
A.Length = input.Length;
Assert.Multiple(() =>
{
Assert.That(A.StartsWith(Testee_00), Is.True);
Assert.That(A.StartsWith(Testee_01), Is.False);
Assert.That(A.EndsWith(Testee_00), Is.False);
Assert.That(A.EndsWith(Testee_01), Is.True);
});
}

[Test]
public void DataTypeTest()
{
RefString BaseString0 = new RefString(ori, 0, ori.Length);
var e = BaseString0.Split('/', '\\');
var comp = ori.Split('/', '\\');
int i = 0;
while (e.MoveNext())
{
var c = e.Current.FinalizeString();
Assert.That(c, Is.EqualTo(comp[i]));
i++;
}
[Test]
public void DataTypeTest()
{
RefString BaseString0 = new RefString(ori, 0, ori.Length);
var e = BaseString0.Split('/', '\\');
var comp = ori.Split('/', '\\');
int i = 0;
while (e.MoveNext())
{
var c = e.Current.FinalizeString();
Assert.That(c, Is.EqualTo(comp[i]));
i++;
}

}
}
}
}
}
Loading

0 comments on commit 58f45b4

Please sign in to comment.