Free cookie consent management tool by TermsFeed Policy Generator

source: branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Tests/Components/PrintStackTests.cs @ 15189

Last change on this file since 15189 was 15189, checked in by pkimmesw, 7 years ago

#2665 Fixed small issues, testet benchmark suite, added INX Expressions

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