Added tests for format 21c

git-svn-id: https://smali.googlecode.com/svn/trunk@111 55b6fa8a-2a1e-11de-a435-ffa8d773f76a
This commit is contained in:
JesusFreke@JesusFreke.com 2009-06-07 00:15:00 +00:00
parent e80e6a7eb7
commit be0579b153
4 changed files with 242 additions and 0 deletions

View File

@ -0,0 +1,210 @@
.class public LFormat21c;
.super Ljava/lang/Object;
.source "Format21c.smali"
.method public constructor <init>()V
.registers 1
invoke-direct {p0}, Ljava/lang/Object;-><init>()V
return-void
.end method
.method public test_const-string()V
.registers 2
.annotation runtime Lorg/junit/Test;
.end annotation
const-string v0, "test"
const-string v1, "test"
invoke-static {v0, v1}, Lorg/junit/Assert;->assertEquals(Ljava/lang/Object;Ljava/lang/Object;)V
return-void
.end method
.method public test_const-class()V
.registers 2
.annotation runtime Lorg/junit/Test;
.end annotation
const-class v0, Ljava/io/PrintStream;
invoke-virtual {v0}, Ljava/lang/Class;->toString()Ljava/lang/String;
move-result-object v1
const-string v0, "class java.io.PrintStream"
invoke-static {v0, v1}, Lorg/junit/Assert;->assertEquals(Ljava/lang/Object;Ljava/lang/Object;)V
return-void
.end method
.method public test_check-cast-fail()V
.registers 2
.annotation runtime Lorg/junit/Test;
.end annotation
tryStart:
const-string v0, "test"
check-cast v0, Ljava/io/PrintStream;
tryEnd:
.catch Ljava/lang/ClassCastException; {tryStart: .. tryEnd:} handler:
#the check-cast didn't throw an exception as expected
invoke-static {}, Lorg/junit/Assert;->fail()V
handler:
return-void
.end method
.method public test_check-cast-success()V
.registers 2
.annotation runtime Lorg/junit/Test;
.end annotation
tryStart:
const-string v0, "test"
check-cast v0, Ljava/lang/Object;
tryEnd:
.catch Ljava/lang/ClassCastException; {tryStart: .. tryEnd:} handler:
return-void
handler:
#the check-cast incorrectlly threw an exception as expected
invoke-static {}, Lorg/junit/Assert;->fail()V
return-void
.end method
.method public test_new-instance()V
.registers 3
.annotation runtime Lorg/junit/Test;
.end annotation
const-string v0, "test"
new-instance v1, LStringWrapper;
invoke-direct {v1, v0}, LStringWrapper;-><init>(Ljava/lang/String;)V
invoke-virtual {v1}, LStringWrapper;->getValue()Ljava/lang/String;
move-result-object v2
invoke-static {v0, v2}, Lorg/junit/Assert;->assertEquals(Ljava/lang/Object;Ljava/lang/Object;)V
return-void
.end method
.method public test-sput__sget()V
.registers 2
.annotation runtime Lorg/junit/Test;
.end annotation
const v0, 23
sput v0, LStaticFields;->staticField:I
sget v1, LStaticFields;->staticField:I
invoke-static {v0, v1}, LAssert;->assertEquals(II)V
return-void
.end method
.method public test-sput-object__sget-object()V
.registers 2
.annotation runtime Lorg/junit/Test;
.end annotation
const-string v0, "a string"
sput-object v0, LStaticFields;->staticObjectField:Ljava/lang/String;
sget-object v1, LStaticFields;->staticObjectField:Ljava/lang/String;
invoke-static {v0, v1}, Lorg/junit/Assert;->assertEquals(Ljava/lang/Object;Ljava/lang/Object;)V
return-void
.end method
.method public test-sput-wide__sget-wide()V
.registers 4
.annotation runtime Lorg/junit/Test;
.end annotation
const-wide v0, 0x200000000L
sput-wide v0, LStaticFields;->staticWideField:J
sget-wide v2, LStaticFields;->staticWideField:J
invoke-static {v0, v1, v2, v3}, Lorg/junit/Assert;->assertEquals(JJ)V
return-void
.end method
.method public test-sput-boolean__sget-boolean_true()V
.registers 2
.annotation runtime Lorg/junit/Test;
.end annotation
const v0, 1
sput-boolean v0, LStaticFields;->staticBooleanField:Z
sget-boolean v1, LStaticFields;->staticBooleanField:Z
invoke-static {v1}, Lorg/junit/Assert;->assertTrue(Z)V
return-void
.end method
.method public test-sput-boolean__sget-boolean_false()V
.registers 2
.annotation runtime Lorg/junit/Test;
.end annotation
const v0, 0
sput-boolean v0, LStaticFields;->staticBooleanField:Z
sget-boolean v1, LStaticFields;->staticBooleanField:Z
invoke-static {v1}, Lorg/junit/Assert;->assertFalse(Z)V
return-void
.end method
.method public test-sput-byte__sget-byte()V
.registers 2
.annotation runtime Lorg/junit/Test;
.end annotation
const v0, 120T
sput-byte v0, LStaticFields;->staticByteField:B
sget-byte v1, LStaticFields;->staticByteField:B
invoke-static {v0, v1}, LAssert;->assertEquals(II)V
return-void
.end method
.method public test-sput-char__sget-char()V
.registers 2
.annotation runtime Lorg/junit/Test;
.end annotation
const v0, 'a'
sput-char v0, LStaticFields;->staticCharField:C
sget-char v1, LStaticFields;->staticCharField:C
invoke-static {v0, v1}, LAssert;->assertEquals(II)V
return-void
.end method
.method public test-sput-short__sget-short()V
.registers 2
.annotation runtime Lorg/junit/Test;
.end annotation
const v0, 1234S
sput-short v0, LStaticFields;->staticShortField:S
sget-short v1, LStaticFields;->staticShortField:S
invoke-static {v0, v1}, LAssert;->assertEquals(II)V
return-void
.end method

View File

@ -0,0 +1,10 @@
.class public LStaticFields;
.super Ljava/lang/Object;
.field public static staticField:I
.field public static staticWideField:J
.field public static staticObjectField:Ljava/lang/String;
.field public static staticBooleanField:Z
.field public static staticByteField:B
.field public static staticCharField:C
.field public static staticShortField:S

View File

@ -0,0 +1,21 @@
.class public LStringWrapper;
.super Ljava/lang/Object;
.field private stringValue:Ljava/lang/String;
.method public constructor <init>(Ljava/lang/String;)V
.registers 2
invoke-direct {p0}, Ljava/lang/Object;-><init>()V
iput-object p1, p0, LStringWrapper;->stringValue:Ljava/lang/String;
return-void
.end method
.method public getValue()Ljava/lang/String;
.registers 2
iget-object v0, p0, LStringWrapper;->stringValue:Ljava/lang/String;
return-object v0
.end method

View File

@ -28,6 +28,7 @@
LFormat11x;,
LFormat12x;,
LFormat20t;,
LFormat21c;,
LFormat21h;,
LFormat21s;,
LFormat21t;,