|
| 1 | +package org.utbot.examples.taint |
| 2 | + |
| 3 | +import org.junit.jupiter.api.Test |
| 4 | +import org.utbot.framework.plugin.api.TaintAnalysisError |
| 5 | +import org.utbot.taint.TaintConfigurationProviderResources |
| 6 | +import org.utbot.testcheckers.eq |
| 7 | +import org.utbot.testcheckers.ge |
| 8 | +import org.utbot.testing.UtValueTestCaseCheckerForTaint |
| 9 | +import org.utbot.testing.isException |
| 10 | + |
| 11 | +internal class TaintCleanerConditionsTest : UtValueTestCaseCheckerForTaint( |
| 12 | + testClass = TaintCleanerConditions::class, |
| 13 | + taintConfigurationProvider = TaintConfigurationProviderResources("taint/TaintCleanerConditionsConfig.yaml") |
| 14 | +) { |
| 15 | + @Test |
| 16 | + fun testTaintBadArg() { |
| 17 | + checkWithException( |
| 18 | + TaintCleanerConditions::badArg, |
| 19 | + ge(2), // success & taint error |
| 20 | + { r -> r.isException<TaintAnalysisError>() }, |
| 21 | + ) |
| 22 | + } |
| 23 | + |
| 24 | + @Test |
| 25 | + fun testTaintBadReturn() { |
| 26 | + checkWithException( |
| 27 | + TaintCleanerConditions::badReturn, |
| 28 | + ge(2), // success & taint error |
| 29 | + { r -> r.isException<TaintAnalysisError>() }, |
| 30 | + ) |
| 31 | + } |
| 32 | + |
| 33 | + @Test |
| 34 | + fun testTaintBadThis() { |
| 35 | + checkWithException( |
| 36 | + TaintCleanerConditions::badThis, |
| 37 | + ge(2), // success & taint error |
| 38 | + { r -> r.isException<TaintAnalysisError>() }, |
| 39 | + ) |
| 40 | + } |
| 41 | + |
| 42 | + @Test |
| 43 | + fun testTaintGoodArg() { |
| 44 | + check( |
| 45 | + TaintCleanerConditions::goodArg, |
| 46 | + eq(1), // only success |
| 47 | + ) |
| 48 | + } |
| 49 | + |
| 50 | + @Test |
| 51 | + fun testTaintGoodReturn() { |
| 52 | + check( |
| 53 | + TaintCleanerConditions::goodReturn, |
| 54 | + eq(1), // only success |
| 55 | + ) |
| 56 | + } |
| 57 | + |
| 58 | + @Test |
| 59 | + fun testTaintGoodThis() { |
| 60 | + check( |
| 61 | + TaintCleanerConditions::goodThis, |
| 62 | + eq(1), // only success |
| 63 | + ) |
| 64 | + } |
| 65 | +} |
0 commit comments