-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[JVM-frontend] Add unit test for jvm frontend
Signed-off-by: Arthur Chan <arthur.chan@adalogics.com>
- Loading branch information
1 parent
0c3b682
commit 184d59b
Showing
4 changed files
with
265 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package simple; | ||
|
||
import com.code_intelligence.jazzer.api.FuzzedDataProvider; | ||
|
||
class SimpleClass { | ||
public SimpleClass() { | ||
System.out.println("Default Constructor Called"); | ||
} | ||
|
||
public SimpleClass(String param) { | ||
System.out.println("Constructor with parameter called: " + param.toUpperCase()); | ||
} | ||
|
||
public void simpleMethod() { | ||
System.out.println("Simple Method Called"); | ||
} | ||
|
||
public void unreachableMethod() { | ||
System.out.println("Unreachable Method in SimpleClass"); | ||
} | ||
} | ||
|
||
public class Fuzzer { | ||
public static void fuzzerTestOneInput(FuzzedDataProvider data) { | ||
SimpleClass sc = new SimpleClass(data.consumeString(10)); | ||
sc.simpleMethod(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package polymorphism; | ||
|
||
import com.code_intelligence.jazzer.api.FuzzedDataProvider; | ||
|
||
interface Animal { | ||
void sound(); | ||
} | ||
|
||
class Dog implements Animal { | ||
public Dog() { | ||
System.out.println("Dog Constructor Called: " + Math.random()); | ||
} | ||
|
||
public Dog(String name) { | ||
System.out.println("Dog Constructor with name: " + name.toLowerCase()); | ||
} | ||
|
||
public void sound() { | ||
System.out.println("Bark"); | ||
} | ||
|
||
public void unreachableDogMethod() { | ||
System.out.println("Unreachable Method in Dog"); | ||
} | ||
} | ||
|
||
class Cat implements Animal { | ||
public Cat() { | ||
System.out.println("Cat Constructor Called: " + Math.random()); | ||
} | ||
|
||
public Cat(String name) { | ||
System.out.println("Cat Constructor with name: " + name.toUpperCase()); | ||
} | ||
|
||
public void sound() { | ||
System.out.println("Meow"); | ||
} | ||
|
||
public void unreachableCatMethod() { | ||
System.out.println("Unreachable Method in Cat"); | ||
} | ||
} | ||
|
||
public class Fuzzer { | ||
public static void fuzzerTestOneInput(FuzzedDataProvider data) { | ||
Animal animal; | ||
if ("dog".equals(data.consumeString(10))) { | ||
animal = new Dog(data.consumeString(10)); | ||
} else { | ||
animal = new Cat(data.consumeString(10)); | ||
} | ||
animal.sound(); | ||
} | ||
} |
Oops, something went wrong.