1
0
mirror of https://github.com/chylex/Code-Statistics.git synced 2025-03-15 00:15:42 +01:00

Add JavaParseUtils.FullToSimpleName with unit tests

This commit is contained in:
chylex 2016-02-22 16:40:14 +01:00
parent 9502461ba2
commit 118977a57c
3 changed files with 20 additions and 0 deletions
CodeStatistics/Handling/Languages/Java
CodeStatisticsTests

View File

@ -13,5 +13,10 @@ namespace CodeStatistics.Handling.Languages.Java{
processed = RegexCommentMulti.Replace(processed,"");
return processed;
}
public static string FullToSimpleName(string fullName){
int lastDot = fullName.LastIndexOf('.');
return lastDot == -1 ? fullName : lastDot < fullName.Length-1 ? fullName.Substring(lastDot+1) : string.Empty;
}
}
}

View File

@ -56,6 +56,7 @@
<Compile Include="CodeParserTests.cs" />
<Compile Include="CollectionsTests.cs" />
<Compile Include="IOUtilsTests.cs" />
<Compile Include="Languages\Java\JavaParseUtilsTests.cs" />
<Compile Include="ParseUtilsTests.cs" />
<Compile Include="StringUtilsTests.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />

View File

@ -0,0 +1,14 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using CodeStatistics.Handling.Languages.Java;
namespace CodeStatisticsTests.Languages.Java{
[TestClass]
public class JavaParseUtilsTests{
[TestMethod]
public void TestFullToSimpleName(){
Assert.AreEqual("SimpleName",JavaParseUtils.FullToSimpleName("this.is.a.full.name.SimpleName"));
Assert.AreEqual("SimpleName",JavaParseUtils.FullToSimpleName("SimpleName"));
Assert.AreEqual(string.Empty,JavaParseUtils.FullToSimpleName("broken.name."));
}
}
}