Skip to content
Snippets Groups Projects

Add tests for Convert package

Merged Paul Nitzke requested to merge ConvertTest into master
4 files
+ 263
0
Compare changes
  • Side-by-side
  • Inline
Files
4
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Antlr4.Runtime;
using System.Xml.Linq;
using NUnit.Framework;
using SparseTransform.DataStructures;
using SparseTransform.Convert;
namespace SparseTransform.Tests.Library.Convert
{
public class DotWriterTests
{
[Test]
public void writerTestBipartite()
{
DotWriter writer = new DotWriter();
BipartiteGraph graph = new BipartiteGraph();
graph.AddEdge(1, 1);
graph.AddEdge(1, 2);
graph.AddEdge(1, 5);
graph.AddEdge(2, 3);
graph.AddEdge(3, 2);
graph.AddEdge(3, 3);
graph.AddEdge(3, 4);
graph.AddEdge(4, 1);
graph.AddEdge(5, 4);
graph.AddEdge(5, 5);
string[] lines = writer.Write(graph).Split(
new string[] { "\r\n", "\r", "\n" },
StringSplitOptions.None
);
Assert.That(lines[2], Is.EqualTo("\tc_1 [shape=circle, style=filled]"));
Assert.That(lines[4], Is.EqualTo("\tc_3 [shape=circle, style=filled]"));
Assert.That(lines[5], Is.EqualTo("\tc_4 [shape=circle, style=filled]"));
Assert.That(lines[13], Is.EqualTo("\tc_2 -- {r_3};"));
Assert.That(lines[15], Is.EqualTo("\tc_4 -- {r_1};"));
}
[Test]
public void writerTestAdjacency()
{
DotWriter writer = new DotWriter();
AdjacencyGraph graph = new AdjacencyGraph();
graph.AddEdge(1, 2);
graph.AddEdge(1, 5);
graph.AddEdge(3, 2);
graph.AddEdge(3, 4);
graph.AddEdge(4, 1);
graph.AddEdge(5, 4);
string[] lines = writer.Write(graph).Split(
new string[] { "\r\n", "\r", "\n" },
StringSplitOptions.None
);
Assert.That(lines[2], Is.EqualTo("\tc_2 [shape=circle, style=filled]"));
Assert.That(lines[4], Is.EqualTo("\tc_4 [shape=circle, style=filled]"));
Assert.That(lines[5], Is.EqualTo("\tc_5 [shape=circle, style=filled]"));
Assert.That(lines[7], Is.EqualTo("\tc_3 -- {c_2};"));
Assert.That(lines[9], Is.EqualTo("\tc_5 -- {c_1 c_4};"));
}
}
}
Loading