Free cookie consent management tool by TermsFeed Policy Generator

source: branches/GeneralizedQAP/UnitTests/TSPLIBInstanceProviderTest.cs @ 7489

Last change on this file since 7489 was 7470, checked in by abeham, 13 years ago

#1614

  • Removed incompatible problem linhp318.tsp (contains fixed edges)
  • Fixed AssemblyInfo for TSPLIB
  • Added unit tests
  • Worked on assignment / solution view
File size: 2.2 KB
Line 
1using System;
2using System.Text;
3using HeuristicLab.Problems.Instances.TSPLIB;
4using Microsoft.VisualStudio.TestTools.UnitTesting;
5
6namespace UnitTests {
7  [TestClass()]
8  public class TSPLIBInstanceProviderTest {
9
10    [TestMethod()]
11    public void GetTSPLIBTSPInstanceTest() {
12      var target = new TSPLIBTSPInstanceProvider();
13      StringBuilder erroneousInstances = new StringBuilder();
14      int count = 0;
15      foreach (var id in target.GetInstanceDescriptors()) {
16        try {
17          target.GetInstance(id);
18        } catch (Exception ex) {
19          erroneousInstances.AppendLine(id.Name + ": " + ex.Message);
20        }
21        count++;
22      }
23      Assert.IsTrue(count > 0, "No problem instances were found.");
24      Assert.IsTrue(erroneousInstances.Length == 0, "Some instances could not be parsed: " + Environment.NewLine + erroneousInstances.ToString());
25    }
26
27    [TestMethod()]
28    public void GetTSPLIBATSPInstanceTest() {
29      var target = new TSPLIBATSPInstanceProvider();
30      StringBuilder erroneousInstances = new StringBuilder();
31      int count = 0;
32      foreach (var id in target.GetInstanceDescriptors()) {
33        try {
34          target.GetInstance(id);
35        } catch (Exception ex) {
36          erroneousInstances.AppendLine(id.Name + ": " + ex.Message);
37        }
38        count++;
39      }
40      Assert.IsTrue(count > 0, "No problem instances were found.");
41      Assert.IsTrue(erroneousInstances.Length == 0, "Some instances could not be parsed: " + Environment.NewLine + erroneousInstances.ToString());
42    }
43
44    [TestMethod()]
45    public void GetTSPLIBCVRPInstanceTest() {
46      var target = new TSPLIBCVRPInstanceProvider();
47      StringBuilder erroneousInstances = new StringBuilder();
48      int count = 0;
49      foreach (var id in target.GetInstanceDescriptors()) {
50        try {
51          target.GetInstance(id);
52        } catch (Exception ex) {
53          erroneousInstances.AppendLine(id.Name + ": " + ex.Message);
54        }
55        count++;
56      }
57      Assert.IsTrue(count > 0, "No problem instances were found.");
58      Assert.IsTrue(erroneousInstances.Length == 0, "Some instances could not be parsed: " + Environment.NewLine + erroneousInstances.ToString());
59    }
60  }
61}
Note: See TracBrowser for help on using the repository browser.