mirror of
https://github.com/revanced/revanced-patcher.git
synced 2025-05-03 06:04:25 +02:00
test: add test for multiple classes in jar
This commit is contained in:
parent
5f12bab5df
commit
6b1cec4a43
@ -23,4 +23,7 @@ dependencies {
|
||||
|
||||
tasks.test {
|
||||
useJUnitPlatform()
|
||||
testLogging {
|
||||
events("PASSED", "SKIPPED", "FAILED")
|
||||
}
|
||||
}
|
||||
|
@ -14,29 +14,31 @@ import java.io.PrintStream
|
||||
import kotlin.test.Test
|
||||
|
||||
internal class PatcherTest {
|
||||
private val testSigs: Array<Signature> = arrayOf(
|
||||
// Java:
|
||||
// public static void main(String[] args) {
|
||||
// System.out.println("Hello, world!");
|
||||
// }
|
||||
// Bytecode:
|
||||
// public static main(java.lang.String[] arg0) { // Method signature: ([Ljava/lang/String;)V
|
||||
// getstatic java/lang/System.out:java.io.PrintStream
|
||||
// ldc "Hello, world!" (java.lang.String)
|
||||
// invokevirtual java/io/PrintStream.println(Ljava/lang/String;)V
|
||||
// return
|
||||
// }
|
||||
Signature(
|
||||
"mainMethod",
|
||||
Type.VOID_TYPE,
|
||||
ACC_PUBLIC or ACC_STATIC,
|
||||
arrayOf(ExtraTypes.ArrayAny),
|
||||
arrayOf(
|
||||
LDC,
|
||||
INVOKEVIRTUAL
|
||||
companion object {
|
||||
val testSigs: Array<Signature> = arrayOf(
|
||||
// Java:
|
||||
// public static void main(String[] args) {
|
||||
// System.out.println("Hello, world!");
|
||||
// }
|
||||
// Bytecode:
|
||||
// public static main(java.lang.String[] arg0) { // Method signature: ([Ljava/lang/String;)V
|
||||
// getstatic java/lang/System.out:java.io.PrintStream
|
||||
// ldc "Hello, world!" (java.lang.String)
|
||||
// invokevirtual java/io/PrintStream.println(Ljava/lang/String;)V
|
||||
// return
|
||||
// }
|
||||
Signature(
|
||||
"mainMethod",
|
||||
Type.VOID_TYPE,
|
||||
ACC_PUBLIC or ACC_STATIC,
|
||||
arrayOf(ExtraTypes.ArrayAny),
|
||||
arrayOf(
|
||||
LDC,
|
||||
INVOKEVIRTUAL
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testPatcher() {
|
||||
@ -127,7 +129,7 @@ internal class PatcherTest {
|
||||
|
||||
// TODO Doesn't work, needs to be fixed.
|
||||
//@Test
|
||||
//fun noChanges() {
|
||||
//fun `test patcher with no changes`() {
|
||||
// val testData = PatcherTest::class.java.getResourceAsStream("/test1.jar")!!
|
||||
// val available = testData.available()
|
||||
// val patcher = Patcher(testData, testSigs)
|
||||
|
12
src/test/kotlin/net/revanced/patcher/ReaderTest.kt
Normal file
12
src/test/kotlin/net/revanced/patcher/ReaderTest.kt
Normal file
@ -0,0 +1,12 @@
|
||||
package net.revanced.patcher
|
||||
|
||||
import kotlin.test.Test
|
||||
|
||||
internal class ReaderTest {
|
||||
@Test
|
||||
fun `read jar containing multiple classes`() {
|
||||
val testData = PatcherTest::class.java.getResourceAsStream("/test2.jar")!!
|
||||
Patcher(testData, PatcherTest.testSigs) // reusing test sigs from PatcherTest
|
||||
testData.close()
|
||||
}
|
||||
}
|
BIN
src/test/resources/test2.jar
Normal file
BIN
src/test/resources/test2.jar
Normal file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user