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:
parent
9502461ba2
commit
118977a57c
CodeStatistics/Handling/Languages/Java
CodeStatisticsTests
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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" />
|
||||
|
14
CodeStatisticsTests/Languages/Java/JavaParseUtilsTests.cs
Normal file
14
CodeStatisticsTests/Languages/Java/JavaParseUtilsTests.cs
Normal 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."));
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user