Skip to content

Commit

Permalink
Added test case for BigInteger
Browse files Browse the repository at this point in the history
  • Loading branch information
oxisto committed Dec 13, 2024
1 parent e05e23a commit 21e2010
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ import kotlin.test.assertNotNull
import org.neo4j.ogm.annotation.Relationship
import picocli.CommandLine

fun createTranslationResult(): Pair<Application, TranslationResult> {
fun createTranslationResult(file: String = "client.cpp"): Pair<Application, TranslationResult> {
val topLevel = Paths.get("src").resolve("test").resolve("resources").toAbsolutePath()
val path = topLevel.resolve("client.cpp").toAbsolutePath()
val path = topLevel.resolve(file).toAbsolutePath()

val cmd = CommandLine(Application::class.java)
cmd.parseArgs(path.toString())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,17 @@
*/
package de.fraunhofer.aisec.cpg_vis_neo4j

import de.fraunhofer.aisec.cpg.graph.functions
import de.fraunhofer.aisec.cpg.graph.*
import de.fraunhofer.aisec.cpg.graph.statements.expressions.Literal
import java.math.BigInteger
import kotlin.test.Test
import kotlin.test.assertEquals
import kotlin.test.assertIs
import org.junit.jupiter.api.Tag

@Tag("integration")
class Neo4JTest {
@Test
@Throws(InterruptedException::class)
fun testPush() {
val (application, translationResult) = createTranslationResult()

Expand All @@ -42,4 +44,17 @@ class Neo4JTest {

application.pushToNeo4j(translationResult)
}

@Test
fun testPushVeryLong() {
val (application, translationResult) = createTranslationResult("very_long.cpp")

assertEquals(1, translationResult.variables.size)

val lit = translationResult.variables["l"]?.initializer
assertIs<Literal<BigInteger>>(lit)
assertEquals(BigInteger("10958011617037158669"), lit.value)

application.pushToNeo4j(translationResult)
}
}
1 change: 1 addition & 0 deletions cpg-neo4j/src/test/resources/very_long.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
unsigned long long l = 10958011617037158669ull;

0 comments on commit 21e2010

Please sign in to comment.