source: trunk/sources/HeuristicLab.Tests/HeuristicLab.IGraph/IGraphWrappersVectorTest.cs @ 14244

Last change on this file since 14244 was 14244, checked in by abeham, 5 years ago

#2651: worked on igraph integration, additional layout algorithms, density, page rank

  • added unit tests
File size: 1.9 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
4 *
5 * This file is part of HeuristicLab.
6 *
7 * HeuristicLab is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * HeuristicLab is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
19 */
20#endregion
21
22using HeuristicLab.IGraph.Wrappers;
23using Microsoft.VisualStudio.TestTools.UnitTesting;
24
25namespace HeuristicLab.Tests {
26  [TestClass]
27  public class IGraphWrappersVectorTest {
28    [TestMethod]
29    public void IGraphWrappersVectorConstructionAndFinalization() {
30      var vector = new Vector(7);
31      Assert.AreEqual(7, vector.Length);
32      Assert.AreEqual(0, vector[0]);
33      vector[0] = 4;
34      var other = new Vector(vector);
35      Assert.AreEqual(7, other.Length);
36      Assert.AreEqual(4, other[0]);
37    }
38
39    [TestMethod]
40    public void IGraphWrappersVectorGetSetTest() {
41      var vector = new Vector(5);
42      vector[0] = vector[1] = 4;
43      vector[2] = 3;
44      vector[3] = 1.5;
45      vector[4] = -0.5;
46      Assert.AreEqual(4, vector[0]);
47      Assert.AreEqual(4, vector[1]);
48      Assert.AreEqual(3, vector[2]);
49      Assert.AreEqual(1.5, vector[3]);
50      Assert.AreEqual(-0.5, vector[4]);
51
52      var netmat = vector.ToArray();
53      Assert.AreEqual(5, netmat.Length);
54      for (var i = 0; i < netmat.Length; i++)
55        Assert.AreEqual(vector[i], netmat[i]);
56    }
57  }
58}
Note: See TracBrowser for help on using the repository browser.