Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
J
jadx
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open-source
jadx
Commits
ebf78226
Commit
ebf78226
authored
May 01, 2014
by
Skylot
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use spock framework for unit tests
parent
7669fa15
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
134 additions
and
3 deletions
+134
-3
build.gradle
build.gradle
+4
-2
build.gradle
jadx-core/build.gradle
+5
-0
SignatureParser.java
...main/java/jadx/core/dex/nodes/parser/SignatureParser.java
+1
-1
TestSignatureParser.groovy
...ore/src/test/groovy/jadx/tests/TestSignatureParser.groovy
+87
-0
TestStringUtils.groovy
jadx-core/src/test/groovy/jadx/tests/TestStringUtils.groovy
+37
-0
No files found.
build.gradle
View file @
ebf78226
...
...
@@ -5,6 +5,7 @@ apply plugin: 'sonar-runner'
subprojects
{
apply
plugin:
'java'
apply
plugin:
'groovy'
apply
plugin:
'jacoco'
apply
plugin:
'coveralls'
...
...
@@ -30,8 +31,10 @@ subprojects {
dependencies
{
compile
'org.slf4j:slf4j-api:1.7.7'
testCompile
'junit:junit:4.11'
testCompile
'org.mockito:mockito-core:1.9.5'
testCompile
'org.spockframework:spock-core:0.7-groovy-2.0'
testCompile
'ch.qos.logback:logback-classic:1.1.2'
}
...
...
@@ -47,14 +50,13 @@ subprojects {
}
}
// setup coveralls (http://coveralls.io/)
// see http://github.com/kt3k/coveralls-gradle-plugin
buildscript
{
repositories
{
mavenCentral
()
}
dependencies
{
// setup coveralls (http://coveralls.io/) see http://github.com/kt3k/coveralls-gradle-plugin
classpath
'org.kt3k.gradle.plugin:coveralls-gradle-plugin:0.4.0'
}
}
...
...
jadx-core/build.gradle
View file @
ebf78226
...
...
@@ -5,3 +5,8 @@ dependencies {
runtime
files
(
jadxClasspath
)
}
task
packTests
(
type:
Jar
)
{
classifier
=
'tests'
from
sourceSets
.
test
.
output
}
jadx-core/src/main/java/jadx/core/dex/nodes/parser/SignatureParser.java
View file @
ebf78226
...
...
@@ -208,7 +208,7 @@ public class SignatureParser {
*/
public
Map
<
ArgType
,
List
<
ArgType
>>
consumeGenericMap
()
{
if
(!
lookAhead
(
'<'
))
{
return
null
;
return
Collections
.
emptyMap
()
;
}
Map
<
ArgType
,
List
<
ArgType
>>
map
=
new
LinkedHashMap
<
ArgType
,
List
<
ArgType
>>(
2
);
consume
(
'<'
);
...
...
jadx-core/src/test/groovy/jadx/tests/TestSignatureParser.groovy
0 → 100644
View file @
ebf78226
package
jadx.tests
import
jadx.core.dex.instructions.args.ArgType
import
jadx.core.dex.nodes.parser.SignatureParser
import
spock.lang.Specification
import
static
jadx
.
core
.
dex
.
instructions
.
args
.
ArgType
.*
class
TestSignatureParser
extends
Specification
{
def
"simple types"
()
{
expect:
new
SignatureParser
(
str
).
consumeType
()
==
result
where:
str
|
result
""
|
null
"I"
|
INT
"[I"
|
array
(
INT
)
"Ljava/lang/Object;"
|
OBJECT
"[Ljava/lang/Object;"
|
array
(
OBJECT
)
"[[I"
|
array
(
array
(
INT
))
}
def
"generics"
()
{
expect:
new
SignatureParser
(
str
).
consumeType
()
==
result
where:
str
|
result
"TD;"
|
genericType
(
"D"
)
"La<TV;Lb;>;"
|
generic
(
"La;"
,
genericType
(
"V"
),
object
(
"b"
))
"La<Lb<Lc;>;>;"
|
generic
(
"La;"
,
generic
(
"Lb;"
,
object
(
"Lc;"
)))
"La<TD;>.c;"
|
genericInner
(
generic
(
"La;"
,
genericType
(
"D"
)),
"c"
,
null
)
"La<Lb;>.c<TV;>;"
|
genericInner
(
generic
(
"La;"
,
object
(
"Lb;"
)),
"c"
,
genericType
(
"V"
))
}
def
"inner generic"
()
{
expect:
new
SignatureParser
(
str
).
consumeType
().
getObject
()
==
result
where:
str
|
result
"La<TV;>.LinkedHashIterator<Lb\$c<Ls;TV;>;>;"
|
"a\$LinkedHashIterator"
}
def
"wildcards"
()
{
expect:
new
SignatureParser
(
"La<$s>;"
).
consumeType
()
==
generic
(
"La;"
,
r
as
ArgType
[])
where:
s
|
r
"*"
|
wildcard
()
"+Lb;"
|
wildcard
(
object
(
"b"
),
1
)
"-Lb;"
|
wildcard
(
object
(
"b"
),
-
1
)
"+TV;"
|
wildcard
(
genericType
(
"V"
),
1
)
"-TV;"
|
wildcard
(
genericType
(
"V"
),
-
1
)
"**"
|
[
wildcard
(),
wildcard
()]
"*Lb;"
|
[
wildcard
(),
object
(
"b"
)]
"*TV;"
|
[
wildcard
(),
genericType
(
"V"
)]
"TV;*"
|
[
genericType
(
"V"
),
wildcard
()]
"Lb;*"
|
[
object
(
"b"
),
wildcard
()]
"***"
|
[
wildcard
(),
wildcard
(),
wildcard
()]
"*Lb;*"
|
[
wildcard
(),
object
(
"b"
),
wildcard
()]
}
def
"generic map"
()
{
expect:
new
SignatureParser
(
str
).
consumeGenericMap
()
==
result
.
collectEntries
{
[
genericType
(
it
.
key
),
it
.
value
]
}
where:
str
|
result
""
|
[:]
"<T:Ljava/lang/Object;>"
|
[
"T"
:
[]]
"<K:Ljava/lang/Object;LongType:Ljava/lang/Object;>"
|
[
"K"
:
[],
"LongType"
:
[]]
"<ResultT:Ljava/lang/Exception;:Ljava/lang/Object;>"
|
[
"ResultT"
:
[
object
(
"java.lang.Exception"
)]]
}
def
"method args"
()
{
when:
def
argTypes
=
new
SignatureParser
(
"(Ljava/util/List<*>;)V"
).
consumeMethodArgs
()
then:
argTypes
.
size
()
==
1
argTypes
.
get
(
0
)
==
generic
(
"Ljava/util/List;"
,
wildcard
())
}
}
jadx-core/src/test/groovy/jadx/tests/TestStringUtils.groovy
0 → 100644
View file @
ebf78226
package
jadx.tests
import
jadx.core.utils.StringUtils
import
spock.lang.Specification
class
TestStringUtils
extends
Specification
{
def
"unescape string"
()
{
expect:
StringUtils
.
unescapeString
(
input
)
==
"\"$expected\""
where:
input
|
expected
""
|
""
"'"
|
"'"
"a"
|
"a"
"\n"
|
"\\n"
"\t"
|
"\\t"
"\r"
|
"\\r"
"\b"
|
"\\b"
"\f"
|
"\\f"
"\\"
|
"\\\\"
"\""
|
"\\\""
"\u1234"
|
"\\u1234"
}
def
"unescape char"
()
{
expect:
StringUtils
.
unescapeChar
(
input
as
char
)
==
"'$expected'"
where:
input
|
expected
'a'
|
"a"
'\n'
|
"\\n"
'\''
|
"\\\'"
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment