Free cookie consent management tool by TermsFeed Policy Generator

source: addons/HeuristicLab.PushGP/HeuristicLab.Tests/Components/PrintStackTests.cs @ 18051

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

#2665 Testet Problems, Testet error functions, Small fixes, Created HL files

File size: 1.6 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    [TestProperty("Time", "Short")]
20    [TestCategory("ComponentTest")]
21    public void TestPushLong() {
22      printStack.Push(100L);
23
24      Assert.AreEqual(100L.ToString(), printStack.ToString());
25    }
26
27    [TestMethod]
28    [TestProperty("Time", "Short")]
29    [TestCategory("ComponentTest")]
30    public void TestPushDouble() {
31      printStack.Push(100.5D);
32
33      Assert.AreEqual(100.5D.ToString(), printStack.ToString());
34    }
35
36    [TestMethod]
37    [TestProperty("Time", "Short")]
38    [TestCategory("ComponentTest")]
39    public void TestAsStringsWithNewline() {
40      printStack.Push(100.5D);
41      printStack.Push(10);
42      printStack.NewLine();
43      printStack.Push("abc");
44      printStack.Push('d');
45
46      var lines = printStack.AsStrings().ToList();
47
48      Assert.AreEqual(2, lines.Count);
49      Assert.AreEqual("100,510", lines[0]);
50      Assert.AreEqual("abcd", lines[1]);
51    }
52
53    [TestMethod]
54    [TestProperty("Time", "Short")]
55    [TestCategory("ComponentTest")]
56    public void TestAsStringsWithoutNewline() {
57      printStack.Push(100.5D);
58      printStack.Push(10);
59
60      var lines = printStack.AsStrings().ToList();
61
62      Assert.AreEqual(1, lines.Count);
63      Assert.AreEqual("100,510", lines[0]);
64    }
65  }
66}
Note: See TracBrowser for help on using the repository browser.