Skip to content
This repository was archived by the owner on Nov 12, 2025. It is now read-only.

Commit aa69161

Browse files
committed
Improve on accuracy
1 parent 6753184 commit aa69161

1 file changed

Lines changed: 49 additions & 0 deletions

File tree

src/test/java/com/searchcode/app/util/SlocCounterTest.java

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,53 @@ public void testBoundsExceptions() {
4747
SlocCounter.SlocCount slocCount = this.slocCounter.countStats(contents, language);
4848
assertThat(slocCount.complexity).isEqualTo(8);
4949
}
50+
51+
public void testTokeiTest() {
52+
String language = "Rust";
53+
String contents = "// 39 lines 32 code 2 comments 5 blanks\n" +
54+
"\n" +
55+
"/* /**/ */\n" +
56+
"fn main() {\n" +
57+
" let start = \"/*\";\n" +
58+
" loop {\n" +
59+
" if x.len() >= 2 && x[0] == '*' && x[1] == '/' { // found the */\n" +
60+
" break;\n" +
61+
" }\n" +
62+
" }\n" +
63+
"}\n" +
64+
"\n" +
65+
"fn foo() {\n" +
66+
" let this_ends = \"a \\\"test/*.\";\n" +
67+
" call1();\n" +
68+
" call2();\n" +
69+
" let this_does_not = /* a /* nested */ comment \" */\n" +
70+
" \"*/another /*test\n" +
71+
" call3();\n" +
72+
" */\";\n" +
73+
"}\n" +
74+
"\n" +
75+
"fn foobar() {\n" +
76+
" let does_not_start = // \"\n" +
77+
" \"until here,\n" +
78+
" test/*\n" +
79+
" test\"; // a quote: \"\n" +
80+
" let also_doesnt_start = /* \" */\n" +
81+
" \"until here,\n" +
82+
" test,*/\n" +
83+
" test\"; // another quote: \"\n" +
84+
"}\n" +
85+
"\n" +
86+
"fn foo() {\n" +
87+
" let a = 4; // /*\n" +
88+
" let b = 5;\n" +
89+
" let c = 6; // */\n" +
90+
"}\n" +
91+
"\n";
92+
93+
SlocCounter.SlocCount slocCount = this.slocCounter.countStats(contents, language);
94+
assertThat(slocCount.linesCount).isEqualTo(39);
95+
assertThat(slocCount.codeCount).isEqualTo(33);
96+
assertThat(slocCount.blankCount).isEqualTo(5);
97+
assertThat(slocCount.commentCount).isEqualTo(1);
98+
}
5099
}

0 commit comments

Comments
 (0)