Skip to content

Commit

Permalink
Merge branch 'fix-configuration-generation' into jan-dev
Browse files Browse the repository at this point in the history
  • Loading branch information
danjujan committed Oct 23, 2023
2 parents 3f79bae + 0f33534 commit 90071d4
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 0 deletions.
21 changes: 21 additions & 0 deletions unittests/Solver/ConfigurationFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

#include "vara/Feature/ConstraintBuilder.h"
#include "vara/Feature/FeatureModelBuilder.h"

#include "Utils/UnittestHelper.h"
#include "gtest/gtest.h"

namespace vara::solver {
Expand Down Expand Up @@ -51,6 +53,25 @@ TEST(ConfigurationFactory, GetAllConfigurations) {
EXPECT_EQ(ConfigResult.extractValue().size(), 6 * 63);
}

TEST(ConfigurationFactory, GetAllConfigurations2) {
auto FM = feature::loadFeatureModel(
getTestResource("test_three_optional_features.xml"));
auto ConfigResult = ConfigurationFactory::getAllConfigs(*FM);
EXPECT_TRUE(ConfigResult);
auto Configs = ConfigResult.extractValue();

EXPECT_EQ(Configs.size(), 8);

auto ConfigsStrings = std::vector<string>();
for (auto &config : Configs) {
ConfigsStrings.push_back(config.get()->dumpToString());
}

auto UniqueConfigs =
std::set<string>(ConfigsStrings.begin(), ConfigsStrings.end());
EXPECT_EQ(Configs.size(), UniqueConfigs.size());
}

TEST(ConfigurationFactory, GetNConfigurations) {
auto FM = getFeatureModel();
auto ConfigResult = ConfigurationFactory::getNConfigs(*FM, 100);
Expand Down
1 change: 1 addition & 0 deletions unittests/resources/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ set(FEATURE_LIB_TEST_FILES
xml/test_output_string.xml
xml/test_revision_range.xml
xml/test_step_function.xml
xml/test_three_optional_features.xml
xml/test_with_whitespaces.xml
yml/dune_configs.yml
)
Expand Down
29 changes: 29 additions & 0 deletions unittests/resources/xml/test_three_optional_features.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE vm SYSTEM "vm.dtd">
<vm name="SingleLocalSingle" root="root">
<binaryOptions>
<configurationOption>
<name>root</name>
<parent></parent>
<optional>False</optional>
</configurationOption>
<configurationOption>
<name>A</name>
<outputString>A</outputString>
<parent>root</parent>
<optional>True</optional>
</configurationOption>
<configurationOption>
<name>B</name>
<outputString>B</outputString>
<parent>root</parent>
<optional>True</optional>
</configurationOption>
<configurationOption>
<name>C</name>
<outputString>C</outputString>
<parent>root</parent>
<optional>True</optional>
</configurationOption>
</binaryOptions>
</vm>

0 comments on commit 90071d4

Please sign in to comment.