public void Initialize_CheckDimension_EqualsGivenDimension(uint givenDimension) { var vec = new DirectSum <T, TStruct>(givenDimension); Assert.IsNotNull(vec); Assert.AreEqual(givenDimension, vec.Dimension); }
public void Indexer_SettingToHighDimension_ThrowsVectorException( uint dimension, uint index) { var value = default(T); var vec = new DirectSum <T, TStruct>(dimension); Assert.IsNotNull(vec); Assert.Throws <LinearAlgebraException>(() => vec[index] = value); }
public void Parse_ValidParse_EqualsExpected <TSet, TStruct, TParser> ( TSet hack1, TStruct hack2, TParser hack3, DirectSumParser <TSet, TStruct, TParser> parser, String stringInput, DirectSum <TSet, TStruct> expected) where TStruct : IStructure, new() where TParser : IParser <TSet>, new() { var result = parser.Parse(stringInput); Assert.IsNotNull(result); Assert.AreEqual(expected, result); }
/// <summary> /// Parse the specified stringInput. /// </summary> /// <param name="inputString">String input.</param> /// <returns>A new direct sum with the specified values in the string.</returns> /// <exception cref="NotSupportedException">Thrown if the string is not valid to parse.</exception> public DirectSum <T, TStruct> Parse(String inputString) { var matchArray = Regex.Split(inputString, ","); if (matchArray.Length <= 0) { throw new NotSupportedException("No match"); } var tuple = new DirectSum <T, TStruct>((uint)matchArray.Length); for (uint i = 0; i < matchArray.Length; i++) { tuple[i] = this._typeParser.Parse(matchArray[i]); } return(tuple); }