From 9ae884bd5ef2f3a8ede0b00dc506f9c435662082 Mon Sep 17 00:00:00 2001 From: RipplB Date: Sat, 1 Jun 2024 21:46:20 +0200 Subject: [PATCH] Added unittest to new xsts functionalities --- .../analysis/config/XstsConfigBuilder.java | 2 +- ...lankInitFunc.kt => XstsControlInitFunc.kt} | 0 .../XstsCombineExtractUtilsUnitTest.kt | 35 +++++++++++++++++++ .../analysis/XstsControlInitFuncUnitTest.kt | 30 ++++++++++++++++ 4 files changed, 66 insertions(+), 1 deletion(-) rename subprojects/xsts/xsts-analysis/src/main/kotlin/hu/bme/mit/theta/xsts/analysis/{XstsBlankInitFunc.kt => XstsControlInitFunc.kt} (100%) create mode 100644 subprojects/xsts/xsts-analysis/src/test/kotlin/hu/bme/mit/theta/xsts/analysis/XstsCombineExtractUtilsUnitTest.kt create mode 100644 subprojects/xsts/xsts-analysis/src/test/kotlin/hu/bme/mit/theta/xsts/analysis/XstsControlInitFuncUnitTest.kt diff --git a/subprojects/xsts/xsts-analysis/src/main/java/hu/bme/mit/theta/xsts/analysis/config/XstsConfigBuilder.java b/subprojects/xsts/xsts-analysis/src/main/java/hu/bme/mit/theta/xsts/analysis/config/XstsConfigBuilder.java index 89cdfdc7cb..15fc3aae2e 100644 --- a/subprojects/xsts/xsts-analysis/src/main/java/hu/bme/mit/theta/xsts/analysis/config/XstsConfigBuilder.java +++ b/subprojects/xsts/xsts-analysis/src/main/java/hu/bme/mit/theta/xsts/analysis/config/XstsConfigBuilder.java @@ -372,7 +372,7 @@ XstsConfig, XstsAction, P> buildConfig() { public MultiAnalysisSide, S, XstsState, XstsAction, P, UnitPrec> getMultiSide() { return new MultiAnalysisSide<>( getAnalysis(), - XstsBlankInitFuncKt.xstsControlInitFunc(), + XstsControlInitFuncKt.xstsControlInitFunc(), XstsCombineExtractUtilsKt::xstsCombineStates, XstsCombineExtractUtilsKt::xstsExtractControlState, XstsCombineExtractUtilsKt::xstsExtractDataState, diff --git a/subprojects/xsts/xsts-analysis/src/main/kotlin/hu/bme/mit/theta/xsts/analysis/XstsBlankInitFunc.kt b/subprojects/xsts/xsts-analysis/src/main/kotlin/hu/bme/mit/theta/xsts/analysis/XstsControlInitFunc.kt similarity index 100% rename from subprojects/xsts/xsts-analysis/src/main/kotlin/hu/bme/mit/theta/xsts/analysis/XstsBlankInitFunc.kt rename to subprojects/xsts/xsts-analysis/src/main/kotlin/hu/bme/mit/theta/xsts/analysis/XstsControlInitFunc.kt diff --git a/subprojects/xsts/xsts-analysis/src/test/kotlin/hu/bme/mit/theta/xsts/analysis/XstsCombineExtractUtilsUnitTest.kt b/subprojects/xsts/xsts-analysis/src/test/kotlin/hu/bme/mit/theta/xsts/analysis/XstsCombineExtractUtilsUnitTest.kt new file mode 100644 index 0000000000..024a6f014f --- /dev/null +++ b/subprojects/xsts/xsts-analysis/src/test/kotlin/hu/bme/mit/theta/xsts/analysis/XstsCombineExtractUtilsUnitTest.kt @@ -0,0 +1,35 @@ +/* + * Copyright 2024 Budapest University of Technology and Economics + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package hu.bme.mit.theta.xsts.analysis + +import hu.bme.mit.theta.analysis.pred.PredState +import hu.bme.mit.theta.analysis.unit.UnitPrec +import hu.bme.mit.theta.analysis.unit.UnitState +import org.junit.jupiter.api.Test + +class XstsCombineExtractUtilsUnitTest { + + val dataState = PredState.of() + val controlState = XstsState.of(UnitState.getInstance(), true, false) + val xstsState = XstsState.of(dataState, true, false) + + @Test + fun `Utils work as expected`() { + assert(xstsCombineStates(controlState, dataState) == xstsState) + assert(xstsExtractControlState(xstsState) == controlState) + assert(xstsExtractDataState(xstsState) == dataState) + assert(xstsExtractControlPrec(UnitPrec.getInstance()) == UnitPrec.getInstance()) + } +} \ No newline at end of file diff --git a/subprojects/xsts/xsts-analysis/src/test/kotlin/hu/bme/mit/theta/xsts/analysis/XstsControlInitFuncUnitTest.kt b/subprojects/xsts/xsts-analysis/src/test/kotlin/hu/bme/mit/theta/xsts/analysis/XstsControlInitFuncUnitTest.kt new file mode 100644 index 0000000000..f297730e51 --- /dev/null +++ b/subprojects/xsts/xsts-analysis/src/test/kotlin/hu/bme/mit/theta/xsts/analysis/XstsControlInitFuncUnitTest.kt @@ -0,0 +1,30 @@ +/* + * Copyright 2024 Budapest University of Technology and Economics + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package hu.bme.mit.theta.xsts.analysis + +import hu.bme.mit.theta.analysis.expl.ExplPrec +import hu.bme.mit.theta.analysis.unit.UnitState +import org.junit.jupiter.api.Test + +class XstsControlInitFuncUnitTest { + + @Test + fun `Returns single unitstate`() { + val result = xstsControlInitFunc().getInitStates(ExplPrec.empty()) + + assert(result.size == 1) + assert(result.single().state == UnitState.getInstance()) + } +} \ No newline at end of file