Free cookie consent management tool by TermsFeed Policy Generator

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

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

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

File size: 1.6 KB
Line 
1using System.Linq;
2using HeuristicLab.Problems.ProgramSynthesis;
3using Microsoft.VisualStudio.TestTools.UnitTesting;
4
5namespace HeuristicLab.Tests.Components {
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]
17    [TestProperty("Time", "Short")]
18    [TestCategory("ComponentTest")]
19    public void TestPushLong() {
20      printStack.Push(100L);
21
22      Assert.AreEqual(100L.ToString(), printStack.ToString());
23    }
24
25    [TestMethod]
26    [TestProperty("Time", "Short")]
27    [TestCategory("ComponentTest")]
28    public void TestPushDouble() {
29      printStack.Push(100.5D);
30
31      Assert.AreEqual(100.5D.ToString(), printStack.ToString());
32    }
33
34    [TestMethod]
35    [TestProperty("Time", "Short")]
36    [TestCategory("ComponentTest")]
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]
52    [TestProperty("Time", "Short")]
53    [TestCategory("ComponentTest")]
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.