Skip to content

Commit 23b2056

Browse files
committed
fix bug in ucell test
1 parent 08f559d commit 23b2056

File tree

1 file changed

+34
-18
lines changed

1 file changed

+34
-18
lines changed

source/module_cell/test/unitcell_test.cpp

Lines changed: 34 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1094,8 +1094,23 @@ TEST_F(UcellDeathTest, ReadOrbFileWarning)
10941094
ofs_running.close();
10951095
remove("tmp_readorbfile");
10961096
}
1097+
class UcellTestReadStru : public ::testing::Test
1098+
{
1099+
protected:
1100+
std::unique_ptr<UnitCell> ucell{new UnitCell};
1101+
std::string output;
1102+
void SetUp() override
1103+
{
1104+
ucell->ntype = 2;
1105+
ucell->orbital_fn.resize(ucell->ntype);
1106+
}
1107+
void TearDown() override
1108+
{
1109+
ucell->orbital_fn.shrink_to_fit();
1110+
}
1111+
};
10971112

1098-
TEST_F(UcellTest, ReadAtomSpecies)
1113+
TEST_F(UcellTestReadStru, ReadAtomSpecies)
10991114
{
11001115
std::string fn = "./support/STRU_MgO";
11011116
std::ifstream ifa(fn.c_str());
@@ -1191,7 +1206,7 @@ TEST_F(UcellDeathTest, ReadAtomSpeciesWarning4)
11911206
remove("read_atom_species.tmp");
11921207
}
11931208

1194-
TEST_F(UcellTest, ReadAtomSpeciesLatName)
1209+
TEST_F(UcellTestReadStru, ReadAtomSpeciesLatName)
11951210
{
11961211
ucell->ntype = 2;
11971212
ucell->atoms = new Atom[ucell->ntype];
@@ -1249,7 +1264,7 @@ TEST_F(UcellDeathTest, ReadAtomSpeciesWarning5)
12491264
remove("read_atom_species.tmp");
12501265
}
12511266

1252-
TEST_F(UcellTest, ReadAtomPositionsS1)
1267+
TEST_F(UcellTestReadStru, ReadAtomPositionsS1)
12531268
{
12541269
std::string fn = "./support/STRU_MgO";
12551270
std::ifstream ifa(fn.c_str());
@@ -1280,7 +1295,7 @@ TEST_F(UcellTest, ReadAtomPositionsS1)
12801295
remove("read_atom_positions.warn");
12811296
}
12821297

1283-
TEST_F(UcellTest, ReadAtomPositionsS2)
1298+
TEST_F(UcellTestReadStru, ReadAtomPositionsS2)
12841299
{
12851300
std::string fn = "./support/STRU_MgO";
12861301
std::ifstream ifa(fn.c_str());
@@ -1311,7 +1326,7 @@ TEST_F(UcellTest, ReadAtomPositionsS2)
13111326
remove("read_atom_positions.warn");
13121327
}
13131328

1314-
TEST_F(UcellTest, ReadAtomPositionsS4Noncolin)
1329+
TEST_F(UcellTestReadStru, ReadAtomPositionsS4Noncolin)
13151330
{
13161331
std::string fn = "./support/STRU_MgO";
13171332
std::ifstream ifa(fn.c_str());
@@ -1343,7 +1358,7 @@ TEST_F(UcellTest, ReadAtomPositionsS4Noncolin)
13431358
remove("read_atom_positions.warn");
13441359
}
13451360

1346-
TEST_F(UcellTest, ReadAtomPositionsS4Colin)
1361+
TEST_F(UcellTestReadStru, ReadAtomPositionsS4Colin)
13471362
{
13481363
std::string fn = "./support/STRU_MgO";
13491364
std::ifstream ifa(fn.c_str());
@@ -1375,7 +1390,7 @@ TEST_F(UcellTest, ReadAtomPositionsS4Colin)
13751390
remove("read_atom_positions.warn");
13761391
}
13771392

1378-
TEST_F(UcellTest, ReadAtomPositionsC)
1393+
TEST_F(UcellTestReadStru, ReadAtomPositionsC)
13791394
{
13801395
std::string fn = "./support/STRU_MgO_c";
13811396
std::ifstream ifa(fn.c_str());
@@ -1406,7 +1421,7 @@ TEST_F(UcellTest, ReadAtomPositionsC)
14061421
remove("read_atom_positions.warn");
14071422
}
14081423

1409-
TEST_F(UcellTest, ReadAtomPositionsCA)
1424+
TEST_F(UcellTestReadStru, ReadAtomPositionsCA)
14101425
{
14111426
std::string fn = "./support/STRU_MgO_ca";
14121427
std::ifstream ifa(fn.c_str());
@@ -1437,7 +1452,7 @@ TEST_F(UcellTest, ReadAtomPositionsCA)
14371452
remove("read_atom_positions.warn");
14381453
}
14391454

1440-
TEST_F(UcellTest, ReadAtomPositionsCACXY)
1455+
TEST_F(UcellTestReadStru, ReadAtomPositionsCACXY)
14411456
{
14421457
std::string fn = "./support/STRU_MgO_cacxy";
14431458
std::ifstream ifa(fn.c_str());
@@ -1468,7 +1483,7 @@ TEST_F(UcellTest, ReadAtomPositionsCACXY)
14681483
remove("read_atom_positions.warn");
14691484
}
14701485

1471-
TEST_F(UcellTest, ReadAtomPositionsCACXZ)
1486+
TEST_F(UcellTestReadStru, ReadAtomPositionsCACXZ)
14721487
{
14731488
std::string fn = "./support/STRU_MgO_cacxz";
14741489
std::ifstream ifa(fn.c_str());
@@ -1499,7 +1514,7 @@ TEST_F(UcellTest, ReadAtomPositionsCACXZ)
14991514
remove("read_atom_positions.warn");
15001515
}
15011516

1502-
TEST_F(UcellTest, ReadAtomPositionsCACYZ)
1517+
TEST_F(UcellTestReadStru, ReadAtomPositionsCACYZ)
15031518
{
15041519
std::string fn = "./support/STRU_MgO_cacyz";
15051520
std::ifstream ifa(fn.c_str());
@@ -1530,7 +1545,7 @@ TEST_F(UcellTest, ReadAtomPositionsCACYZ)
15301545
remove("read_atom_positions.warn");
15311546
}
15321547

1533-
TEST_F(UcellTest, ReadAtomPositionsCACXYZ)
1548+
TEST_F(UcellTestReadStru, ReadAtomPositionsCACXYZ)
15341549
{
15351550
std::string fn = "./support/STRU_MgO_cacxyz";
15361551
std::ifstream ifa(fn.c_str());
@@ -1561,7 +1576,7 @@ TEST_F(UcellTest, ReadAtomPositionsCACXYZ)
15611576
remove("read_atom_positions.warn");
15621577
}
15631578

1564-
TEST_F(UcellTest, ReadAtomPositionsCAU)
1579+
TEST_F(UcellTestReadStru, ReadAtomPositionsCAU)
15651580
{
15661581
std::string fn = "./support/STRU_MgO_cau";
15671582
std::ifstream ifa(fn.c_str());
@@ -1593,7 +1608,7 @@ TEST_F(UcellTest, ReadAtomPositionsCAU)
15931608
remove("read_atom_positions.warn");
15941609
}
15951610

1596-
TEST_F(UcellTest, ReadAtomPositionsAutosetMag)
1611+
TEST_F(UcellTestReadStru, ReadAtomPositionsAutosetMag)
15971612
{
15981613
std::string fn = "./support/STRU_MgO";
15991614
std::ifstream ifa(fn.c_str());
@@ -1647,7 +1662,7 @@ TEST_F(UcellTest, ReadAtomPositionsAutosetMag)
16471662
remove("read_atom_positions.warn");
16481663
}
16491664

1650-
TEST_F(UcellTest, ReadAtomPositionsWarning1)
1665+
TEST_F(UcellTestReadStru, ReadAtomPositionsWarning1)
16511666
{
16521667
std::string fn = "./support/STRU_MgO_WarningC1";
16531668
std::ifstream ifa(fn.c_str());
@@ -1690,7 +1705,7 @@ TEST_F(UcellTest, ReadAtomPositionsWarning1)
16901705
remove("read_atom_positions.warn");
16911706
}
16921707

1693-
TEST_F(UcellTest, ReadAtomPositionsWarning2)
1708+
TEST_F(UcellTestReadStru, ReadAtomPositionsWarning2)
16941709
{
16951710
std::string fn = "./support/STRU_MgO_WarningC2";
16961711
std::ifstream ifa(fn.c_str());
@@ -1727,7 +1742,7 @@ TEST_F(UcellTest, ReadAtomPositionsWarning2)
17271742
remove("read_atom_positions.warn");
17281743
}
17291744

1730-
TEST_F(UcellTest, ReadAtomPositionsWarning3)
1745+
TEST_F(UcellTestReadStru, ReadAtomPositionsWarning3)
17311746
{
17321747
std::string fn = "./support/STRU_MgO_WarningC3";
17331748
std::ifstream ifa(fn.c_str());
@@ -1773,6 +1788,7 @@ TEST_F(UcellDeathTest, ReadAtomPositionsWarning4)
17731788
// mandatory preliminaries
17741789
ucell->ntype = 2;
17751790
ucell->atoms = new Atom[ucell->ntype];
1791+
ucell->orbital_fn.resize(ucell->ntype);
17761792
ucell->set_atom_flag = true;
17771793
PARAM.input.test_pseudo_cell = 2;
17781794
PARAM.input.basis_type = "lcao";
@@ -1795,7 +1811,7 @@ TEST_F(UcellDeathTest, ReadAtomPositionsWarning4)
17951811
remove("read_atom_positions.warn");
17961812
}
17971813

1798-
TEST_F(UcellTest, ReadAtomPositionsWarning5)
1814+
TEST_F(UcellTestReadStru, ReadAtomPositionsWarning5)
17991815
{
18001816
std::string fn = "./support/STRU_MgO";
18011817
std::ifstream ifa(fn.c_str());

0 commit comments

Comments
 (0)