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
2d189505
Commit
2d189505
authored
Jul 17, 2014
by
Skylot
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
core: add some integration tests
parent
50d31444
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
142 additions
and
0 deletions
+142
-0
TestParamAnnotations.java
...jadx/tests/internal/annotations/TestParamAnnotations.java
+46
-0
TestVarArgAnnotation.java
...jadx/tests/internal/annotations/TestVarArgAnnotation.java
+48
-0
TestAnonymousClass4.java
...t/java/jadx/tests/internal/inner/TestAnonymousClass4.java
+48
-0
No files found.
jadx-core/src/test/java/jadx/tests/internal/annotations/TestParamAnnotations.java
0 → 100644
View file @
2d189505
package
jadx
.
tests
.
internal
.
annotations
;
import
jadx.api.InternalJadxTest
;
import
jadx.core.dex.nodes.ClassNode
;
import
java.lang.annotation.ElementType
;
import
java.lang.annotation.Retention
;
import
java.lang.annotation.RetentionPolicy
;
import
java.lang.annotation.Target
;
import
org.junit.Test
;
import
static
org
.
hamcrest
.
CoreMatchers
.
containsString
;
import
static
org
.
junit
.
Assert
.
assertThat
;
public
class
TestParamAnnotations
extends
InternalJadxTest
{
public
static
class
TestCls
{
@Target
({
ElementType
.
PARAMETER
})
@Retention
(
RetentionPolicy
.
RUNTIME
)
public
static
@interface
A
{
int
i
()
default
7
;
}
void
test1
(
@A
int
i
)
{
}
void
test2
(
int
i
,
@A
int
j
)
{
}
void
test3
(
@A
(
i
=
5
)
int
i
)
{
}
}
@Test
public
void
test
()
{
ClassNode
cls
=
getClassNode
(
TestCls
.
class
);
String
code
=
cls
.
getCode
().
toString
();
System
.
out
.
println
(
code
);
assertThat
(
code
,
containsString
(
"void test1(@A int i) {"
));
assertThat
(
code
,
containsString
(
"void test2(int i, @A int j) {"
));
assertThat
(
code
,
containsString
(
"void test3(@A(i = 5) int i) {"
));
}
}
jadx-core/src/test/java/jadx/tests/internal/annotations/TestVarArgAnnotation.java
0 → 100644
View file @
2d189505
package
jadx
.
tests
.
internal
.
annotations
;
import
jadx.api.InternalJadxTest
;
import
jadx.core.dex.nodes.ClassNode
;
import
org.junit.Test
;
import
static
org
.
hamcrest
.
CoreMatchers
.
containsString
;
import
static
org
.
junit
.
Assert
.
assertThat
;
public
class
TestVarArgAnnotation
extends
InternalJadxTest
{
public
static
class
TestCls
{
void
test1
(
int
...
a
)
{
}
void
test2
(
int
i
,
Object
...
a
)
{
}
void
test3
(
int
[]
a
)
{
}
void
call
()
{
test1
(
1
,
2
);
test2
(
3
,
"1"
,
7
);
test3
(
new
int
[]{
5
,
8
});
}
}
@Test
public
void
test
()
{
ClassNode
cls
=
getClassNode
(
TestCls
.
class
);
String
code
=
cls
.
getCode
().
toString
();
System
.
out
.
println
(
code
);
assertThat
(
code
,
containsString
(
"void test1(int... a) {"
));
assertThat
(
code
,
containsString
(
"void test2(int i, Object... a) {"
));
// TODO:
assertThat
(
code
,
containsString
(
"test1(new int[]{1, 2});"
));
assertThat
(
code
,
containsString
(
"test2(3, objArr);"
));
// negative case
assertThat
(
code
,
containsString
(
"void test3(int[] a) {"
));
assertThat
(
code
,
containsString
(
"test3(new int[]{5, 8});"
));
}
}
jadx-core/src/test/java/jadx/tests/internal/inner/TestAnonymousClass4.java
0 → 100644
View file @
2d189505
package
jadx
.
tests
.
internal
.
inner
;
import
jadx.api.InternalJadxTest
;
import
jadx.core.dex.nodes.ClassNode
;
import
org.junit.Test
;
import
static
jadx
.
tests
.
utils
.
JadxMatchers
.
containsOne
;
import
static
jadx
.
tests
.
utils
.
JadxMatchers
.
countString
;
import
static
org
.
junit
.
Assert
.
assertThat
;
public
class
TestAnonymousClass4
extends
InternalJadxTest
{
public
static
class
TestCls
{
public
static
class
Inner
{
private
int
f
;
private
double
d
;
public
void
test
()
{
new
Thread
()
{
{
f
=
1
;
}
@Override
public
void
run
()
{
d
=
7.5
;
}
}.
start
();
}
}
}
@Test
public
void
test
()
{
ClassNode
cls
=
getClassNode
(
TestCls
.
class
);
String
code
=
cls
.
getCode
().
toString
();
System
.
out
.
println
(
code
);
assertThat
(
code
,
containsOne
(
indent
(
3
)
+
"new Thread() {"
));
assertThat
(
code
,
containsOne
(
indent
(
4
)
+
"{"
));
assertThat
(
code
,
containsOne
(
"f = 1;"
));
assertThat
(
code
,
countString
(
2
,
indent
(
4
)
+
"}"
));
assertThat
(
code
,
containsOne
(
indent
(
4
)
+
"public void run() {"
));
assertThat
(
code
,
containsOne
(
"d = 7.5"
));
assertThat
(
code
,
containsOne
(
indent
(
3
)
+
"}.start();"
));
}
}
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