diff --git a/cpg-neo4j/src/test/kotlin/de/fraunhofer/aisec/cpg_vis_neo4j/ApplicationTest.kt b/cpg-neo4j/src/test/kotlin/de/fraunhofer/aisec/cpg_vis_neo4j/ApplicationTest.kt index bf40cdb2a8..e121a98116 100644 --- a/cpg-neo4j/src/test/kotlin/de/fraunhofer/aisec/cpg_vis_neo4j/ApplicationTest.kt +++ b/cpg-neo4j/src/test/kotlin/de/fraunhofer/aisec/cpg_vis_neo4j/ApplicationTest.kt @@ -43,9 +43,9 @@ import kotlin.test.assertNotNull import org.neo4j.ogm.annotation.Relationship import picocli.CommandLine -fun createTranslationResult(): Pair { +fun createTranslationResult(file: String = "client.cpp"): Pair { 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()) diff --git a/cpg-neo4j/src/test/kotlin/de/fraunhofer/aisec/cpg_vis_neo4j/Neo4JTest.kt b/cpg-neo4j/src/test/kotlin/de/fraunhofer/aisec/cpg_vis_neo4j/Neo4JTest.kt index a77d2d0269..91d2d937d3 100644 --- a/cpg-neo4j/src/test/kotlin/de/fraunhofer/aisec/cpg_vis_neo4j/Neo4JTest.kt +++ b/cpg-neo4j/src/test/kotlin/de/fraunhofer/aisec/cpg_vis_neo4j/Neo4JTest.kt @@ -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() @@ -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>(lit) + assertEquals(BigInteger("10958011617037158669"), lit.value) + + application.pushToNeo4j(translationResult) + } } diff --git a/cpg-neo4j/src/test/resources/very_long.cpp b/cpg-neo4j/src/test/resources/very_long.cpp new file mode 100644 index 0000000000..406c77bf2a --- /dev/null +++ b/cpg-neo4j/src/test/resources/very_long.cpp @@ -0,0 +1 @@ +unsigned long long l = 10958011617037158669ull; \ No newline at end of file