File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed
src/TestProject/IPNetworkTest Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -652,4 +652,29 @@ public void TestParseShouldReturnTrueWhenParsingACidrWithExtraCharacters()
652652 // This assert fails.
653653 Assert . IsTrue ( result ) ;
654654 }
655+
656+ /// <summary>
657+ /// Test TryParse with too many chars and sanitize
658+ /// </summary>
659+ [ TestMethod ]
660+ [ DataRow ( "10.11.0.0" , "NetworkAware" , "10.11.0.0/16" ) ]
661+ [ DataRow ( "10.11.0.0" , "ClassLess" , "10.11.0.0/32" ) ]
662+ [ DataRow ( "10.11.0.0" , "ClassFull" , "10.11.0.0/8" ) ]
663+ public void TestParse ( string ipnetwork , string guess , string expected )
664+ {
665+ var cidrGuess = CidrGuess . ClassLess ;
666+ if ( guess == "NetworkAware" )
667+ {
668+ cidrGuess = CidrGuess . NetworkAware ;
669+ }
670+ else if ( guess == "ClassFull" )
671+ {
672+ cidrGuess = CidrGuess . ClassFull ;
673+ }
674+ bool result = IPNetwork2 . TryParse ( ipnetwork , cidrGuess , out IPNetwork2 ipnetwork2 ) ;
675+ var ipnetworkExpected = IPNetwork2 . Parse ( expected ) ;
676+
677+ // This assert fails.
678+ Assert . AreEqual ( ipnetworkExpected , ipnetwork2 ) ;
679+ }
655680}
You can’t perform that action at this time.
0 commit comments