Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update newline character #1419

Merged
merged 17 commits into from
Dec 2, 2024
Merged
Prev Previous commit
Next Next commit
add unittest
  • Loading branch information
alinpahontu2912 authored Nov 28, 2024
commit e3c3add625dbf95beaca669221d08cad179a795f
16 changes: 16 additions & 0 deletions test/TorchSharpTest/TestTorchTensor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,22 @@ public void TestToString1()
Assert.Equal("[2x2], type = Float32, device = cpu", str);
}

[Fact]
[TestOf(nameof(TensorExtensionMethods.print))]
public void TestTensorPrint()
alinpahontu2912 marked this conversation as resolved.
Show resolved Hide resolved
{
Tensor t = torch.zeros(2, 2);
string expectedOutput = t.ToString(TensorStringStyle.Default, "g5", 100, null, "\n");
using (var sw = new StringWriter())
{
Console.SetOut(sw);
t.print();
var result = sw.ToString().Trim();
Assert.Equal(expectedOutput, result);
}

}

[Fact]
[TestOf(nameof(Tensor.ToString))]
public void Test1DToCSharpString()
Expand Down