1 | using System.Linq;
|
---|
2 | using HeuristicLab.Problems.ProgramSynthesis;
|
---|
3 | using Microsoft.VisualStudio.TestTools.UnitTesting;
|
---|
4 |
|
---|
5 | namespace 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 | }
|
---|