Skip to content

Commit

Permalink
Unit tests compiling
Browse files Browse the repository at this point in the history
Tests that use copy constructor changed to test copy method.

Unit tests compile but failing. Probably initializer_list
construction issue.
  • Loading branch information
bendudson committed Feb 8, 2024
1 parent 182c21b commit 058faee
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 18 deletions.
2 changes: 1 addition & 1 deletion tests/unit/src/test_bout++.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ TEST(BoutInitialiseFunctions, SetRunStartInfo) {

bout::experimental::setRunStartInfo(options);

auto run_section = options["run"];
auto& run_section = options["run"];

ASSERT_TRUE(run_section.isSection());
EXPECT_TRUE(run_section.isSet("version"));
Expand Down
26 changes: 13 additions & 13 deletions tests/unit/sys/test_options.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -602,23 +602,23 @@ TEST_F(OptionsTest, OptionsMacroConstReference) {
EXPECT_EQ(val, 42);
}

/// Copy constructor copies value
/// Copy method copies value
TEST_F(OptionsTest, CopyOption) {
Options option1;

option1 = 42;

Options option2(option1);
Options option2(option1.copy());

EXPECT_EQ(option2.as<int>(), 42);
}

/// Copy constructor makes independent copy
/// Copy method makes independent copy
TEST_F(OptionsTest, CopyOptionDistinct) {
Options option1;
option1 = 42;

Options option2(option1);
Options option2(option1.copy());

option1.force(23);

Expand All @@ -632,7 +632,7 @@ TEST_F(OptionsTest, CopySection) {

option1["key"] = 42; // option1 now a section

Options option2(option1);
Options option2(option1.copy());

EXPECT_EQ(option2["key"].as<int>(), 42);
}
Expand All @@ -643,7 +643,7 @@ TEST_F(OptionsTest, CopySectionParent) {

option1["key"] = 42;

Options option2(option1);
Options option2(option1.copy());

EXPECT_TRUE(&option2["key"].parent() == &option2);
}
Expand All @@ -653,7 +653,7 @@ TEST_F(OptionsTest, AssignOption) {

option1 = 42;

option2 = option1;
option2 = option1.copy();

EXPECT_EQ(option2.as<int>(), 42);
}
Expand All @@ -663,7 +663,7 @@ TEST_F(OptionsTest, AssignSection) {

option1["key"] = 42;

option2 = option1;
option2 = option1.copy();

EXPECT_EQ(option2["key"].as<int>(), 42);
EXPECT_TRUE(option2["key"].isValue());
Expand All @@ -675,7 +675,7 @@ TEST_F(OptionsTest, AssignSectionReplace) {
option1["key"] = 42;
option2["key"] = 23;

option2 = option1;
option2 = option1.copy();

EXPECT_EQ(option2["key"].as<int>(), 42);
}
Expand All @@ -685,7 +685,7 @@ TEST_F(OptionsTest, AssignSectionParent) {

option1["key"] = 42;

option2 = option1;
option2 = option1.copy();

EXPECT_TRUE(&option2["key"].parent() == &option2);
}
Expand All @@ -695,7 +695,7 @@ TEST_F(OptionsTest, AssignSubSection) {

option1["key1"] = 42;

option2["key2"] = option1;
option2["key2"] = option1.copy();

EXPECT_EQ(option2["key2"]["key1"].as<int>(), 42);
}
Expand All @@ -705,7 +705,7 @@ TEST_F(OptionsTest, AssignSubSectionParent) {

option1["key1"] = 42;

option2["key2"] = option1;
option2["key2"] = option1.copy();

EXPECT_EQ(&option2["key2"].parent(), &option2);
EXPECT_EQ(&option2["key2"]["key1"].parent(), &option2["key2"]);
Expand Down Expand Up @@ -1042,7 +1042,7 @@ TEST_F(OptionsTest, DocStringNotCopied) {
Options option;
option = 32;

Options option2 = option;
Options option2 = option.copy();

int value = option2.doc("test value");

Expand Down
8 changes: 4 additions & 4 deletions tests/unit/sys/test_optionsreader.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ test6 = h2`+`:on`e-`more # Escape sequences in the middle
OptionsReader reader;
reader.read(Options::getRoot(), filename);

auto options = Options::root()["tests"];
auto& options = Options::root()["tests"];

EXPECT_EQ(options["test1"].as<int>(), 3);
EXPECT_EQ(options["test2"].as<int>(), 15);
Expand Down Expand Up @@ -398,7 +398,7 @@ twopi = 2 * π # Unicode symbol defined for pi
OptionsReader reader;
reader.read(Options::getRoot(), filename);

auto options = Options::root()["tests"];
auto& options = Options::root()["tests"];

EXPECT_EQ(options["結果"].as<int>(), 8);
EXPECT_DOUBLE_EQ(options["value"].as<BoutReal>(), 1.3 * (1 + 3));
Expand All @@ -425,7 +425,7 @@ value = [a = 1,
OptionsReader reader;
reader.read(Options::getRoot(), filename.c_str());

auto options = Options::root();
auto& options = Options::root();

EXPECT_EQ(options["result"].as<int>(), 6);
EXPECT_EQ(options["value"].as<int>(), 5);
Expand All @@ -452,7 +452,7 @@ value = [a = 1,
OptionsReader reader;
reader.read(Options::getRoot(), filename.c_str());

auto options = Options::root();
auto& options = Options::root();

EXPECT_EQ(options["result"].as<int>(), 6);
EXPECT_EQ(options["value"].as<int>(), 5);
Expand Down

0 comments on commit 058faee

Please sign in to comment.