Free cookie consent management tool by TermsFeed Policy Generator

source: branches/2895_PushGP_GenealogyAnalysis/HeuristicLab.Tests/Components/PrintStackTests.cs @ 17709

Last change on this file since 17709 was 15771, checked in by bburlacu, 7 years ago

#2895: Add solution skeleton for PushGP with genealogy analysis.

File size: 1.6 KB
RevLine 
[15771]1using System.Linq;
2using HeuristicLab.Problems.ProgramSynthesis;
3using Microsoft.VisualStudio.TestTools.UnitTesting;
[15189]4
[15771]5namespace HeuristicLab.Tests.Components {
[15189]6  [TestClass]
7  public class PrintStackTests {
8
9    private PrintStack printStack;
10
11    [TestInitialize]
12    public void BeforeTest() {
13      printStack = new PrintStack();
14    }
15
16    [TestMethod]
[15334]17    [TestProperty("Time", "Short")]
18    [TestCategory("ComponentTest")]
[15189]19    public void TestPushLong() {
20      printStack.Push(100L);
21
[15289]22      Assert.AreEqual(100L.ToString(), printStack.ToString());
[15189]23    }
24
25    [TestMethod]
[15334]26    [TestProperty("Time", "Short")]
27    [TestCategory("ComponentTest")]
[15189]28    public void TestPushDouble() {
29      printStack.Push(100.5D);
30
[15289]31      Assert.AreEqual(100.5D.ToString(), printStack.ToString());
[15189]32    }
33
34    [TestMethod]
[15334]35    [TestProperty("Time", "Short")]
36    [TestCategory("ComponentTest")]
[15189]37    public void TestAsStringsWithNewline() {
38      printStack.Push(100.5D);
39      printStack.Push(10);
40      printStack.NewLine();
41      printStack.Push("abc");
42      printStack.Push('d');
43
44      var lines = printStack.AsStrings().ToList();
45
46      Assert.AreEqual(2, lines.Count);
47      Assert.AreEqual("100,510", lines[0]);
48      Assert.AreEqual("abcd", lines[1]);
49    }
50
51    [TestMethod]
[15334]52    [TestProperty("Time", "Short")]
53    [TestCategory("ComponentTest")]
[15189]54    public void TestAsStringsWithoutNewline() {
55      printStack.Push(100.5D);
56      printStack.Push(10);
57
58      var lines = printStack.AsStrings().ToList();
59
60      Assert.AreEqual(1, lines.Count);
61      Assert.AreEqual("100,510", lines[0]);
62    }
63  }
64}
Note: See TracBrowser for help on using the repository browser.