Skip to content

Commit

Permalink
Fix compiler warnings in gtest test suite
Browse files Browse the repository at this point in the history
  • Loading branch information
speth committed Jul 2, 2023
1 parent 4b8173c commit 3b2ce47
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 31 deletions.
10 changes: 5 additions & 5 deletions test/clib/test_clib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,11 @@ TEST(ct, soln_objects)

int thermo = soln_thermo(ref2);
ASSERT_EQ(thermo, 2);
ASSERT_EQ(thermo_nSpecies(thermo), 10);
ASSERT_EQ(thermo_nSpecies(thermo), 10u);

int kin = soln_kinetics(ref2);
ASSERT_EQ(kin, 1);
ASSERT_EQ(kin_nReactions(kin), 29);
ASSERT_EQ(kin_nReactions(kin), 29u);

int trans = soln_kinetics(ref2);
ASSERT_EQ(trans, 1);
Expand Down Expand Up @@ -138,7 +138,7 @@ TEST(ct, new_interface_auto)
int surf = soln_newInterface("ptcombust.yaml", "Pt_surf", 0, adj.data());
ASSERT_EQ(surf, 1);

ASSERT_EQ(soln_nAdjacent(surf), 1);
ASSERT_EQ(soln_nAdjacent(surf), 1u);
int gas = soln_adjacent(surf, 0);
ASSERT_EQ(gas, 0);

Expand All @@ -156,7 +156,7 @@ TEST(ct, thermo)
int thermo = thermo_newFromFile("gri30.yaml", "gri30");
ASSERT_GE(thermo, 0);
size_t nsp = thermo_nSpecies(thermo);
ASSERT_EQ(nsp, 53);
ASSERT_EQ(nsp, 53u);

ret = thermo_setTemperature(thermo, 500);
ASSERT_EQ(ret, 0);
Expand All @@ -179,7 +179,7 @@ TEST(ct, kinetics)
ASSERT_GE(kin, 0);

size_t nr = kin_nReactions(kin);
ASSERT_EQ(nr, 325);
ASSERT_EQ(nr, 325u);

thermo_equilibrate(thermo, "HP", 0, 1e-9, 50000, 1000, 0);
double T = thermo_temperature(thermo);
Expand Down
2 changes: 1 addition & 1 deletion test/clib/test_ctonedim.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ TEST(ctonedim, freeflame_from_parts)
ASSERT_GE(ret, 0);
}

ASSERT_EQ(domain_nPoints(flow), nz + 1);
ASSERT_EQ(domain_nPoints(flow), static_cast<size_t>(nz + 1));
comp = static_cast<int>(domain_componentIndex(dom, "T"));
double Tprev = sim1D_value(flame, dom, comp, 0);
for (size_t n = 0; n < domain_nPoints(flow); n++) {
Expand Down
26 changes: 13 additions & 13 deletions test/general/test_composite.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ TEST(SolutionArray, empty)
AnyValue vec;
vec = arr->getComponent("T");
ASSERT_TRUE(vec.isVector<double>());
ASSERT_EQ(vec.vectorSize(), 0);
ASSERT_EQ(vec.vectorSize(), 0u);

vec = arr->getComponent("H2");
ASSERT_TRUE(vec.isVector<double>());
ASSERT_EQ(vec.vectorSize(), 0);
ASSERT_EQ(vec.vectorSize(), 0u);

ASSERT_THROW(arr->getAuxiliary(0), CanteraError);
ASSERT_THROW(arr->getComponent("foo"), CanteraError);
Expand All @@ -65,11 +65,11 @@ TEST(SolutionArray, simple)
AnyValue vec;
vec = arr->getComponent("T");
ASSERT_TRUE(vec.isVector<double>());
ASSERT_EQ(vec.vectorSize(), 5);
ASSERT_EQ(vec.vectorSize(), 5u);

vec = arr->getComponent("H2");
ASSERT_TRUE(vec.isVector<double>());
ASSERT_EQ(vec.vectorSize(), 5);
ASSERT_EQ(vec.vectorSize(), 5u);

ASSERT_THROW(arr->getComponent("foo"), CanteraError);

Expand Down Expand Up @@ -157,7 +157,7 @@ TEST(SolutionArray, extraEmpty) {
arr->setComponent("spam", any);
any = arr->getComponent("spam");
ASSERT_TRUE(any.isVector<double>());
ASSERT_EQ(any.asVector<double>().size(), 0);
ASSERT_EQ(any.asVector<double>().size(), 0u);
arr->setComponent("spam", AnyValue());
any = arr->getComponent("spam");
ASSERT_TRUE(any.is<void>());
Expand All @@ -177,7 +177,7 @@ TEST(SolutionArray, extraSingle) {
// set entire component
any = vector<double>({3.1415});
ASSERT_TRUE(any.isVector<double>());
ASSERT_EQ(any.asVector<double>().size(), 1);
ASSERT_EQ(any.asVector<double>().size(), 1u);

// reset
arr->setComponent("spam", AnyValue());
Expand All @@ -189,7 +189,7 @@ TEST(SolutionArray, extraSingle) {
arr->setComponent("spam", any);
any = arr->getComponent("spam");
ASSERT_TRUE(any.isVector<long int>());
ASSERT_EQ(any.asVector<long int>().size(), 1);
ASSERT_EQ(any.asVector<long int>().size(), 1u);
any = 2;
arr->setComponent("spam", any);
any = vector<double>({2.});
Expand All @@ -201,7 +201,7 @@ TEST(SolutionArray, extraSingle) {
arr->setComponent("spam", any);
any = arr->getComponent("spam");
ASSERT_TRUE(any.isVector<string>());
ASSERT_EQ(any.asVector<string>().size(), 1);
ASSERT_EQ(any.asVector<string>().size(), 1u);

// replace/initialize using default values: vectors
any = vector<long int>({3, 4, 5});
Expand All @@ -210,8 +210,8 @@ TEST(SolutionArray, extraSingle) {
arr->setComponent("spam", any);
any = arr->getComponent("spam");
ASSERT_TRUE(any.isMatrix<long int>());
ASSERT_EQ(any.matrixShape().first, 1);
ASSERT_EQ(any.matrixShape().second, 3);
ASSERT_EQ(any.matrixShape().first, 1u);
ASSERT_EQ(any.matrixShape().second, 3u);

// attempt to reset with empty vector
arr->setComponent("spam", AnyValue());
Expand Down Expand Up @@ -380,10 +380,10 @@ void testMultiCol(SolutionArray& arr, const vector<T>& value, bool sliced=false)
AnyValue extra;
extra = arr.getComponent("spam");
ASSERT_TRUE(extra.isMatrix<T>());
ASSERT_EQ(extra.matrixShape().first, arr.size());
ASSERT_EQ(extra.matrixShape().first, static_cast<size_t>(arr.size()));
ASSERT_EQ(extra.matrixShape().second, any.vectorSize());
for (int i = 0; i < size; ++i) {
for (int j = 0; j < value.size(); ++j) {
for (size_t j = 0; j < value.size(); ++j) {
ASSERT_EQ(extra.asVector<vector<T>>()[i][j], value[j]);
}
}
Expand All @@ -408,7 +408,7 @@ void testMultiCol(SolutionArray& arr, const vector<T>& value, bool sliced=false)
ASSERT_EQ(arr.size(), 2 * size);
ASSERT_EQ(len(extra.asVector<vector<T>>()), 2 * size);
for (int i = 0; i < size; ++i) {
for (int j = 0; j < value.size(); ++j) {
for (size_t j = 0; j < value.size(); ++j) {
ASSERT_EQ(extra.asVector<vector<T>>()[i][j], value[j]);
ASSERT_EQ(extra.asVector<vector<T>>()[i + size][j], defaultValue);
}
Expand Down
2 changes: 1 addition & 1 deletion test/general/test_containers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ TEST(AnyMap, nestedVectorsToYaml)
for (size_t j = 0; j < 4; j++) {
strings.back().push_back(words[(i + 3 * j) % words.size()]);
booleans.back().push_back(i == j);
integers.back().push_back(6*i + j);
integers.back().push_back(static_cast<int>(6*i + j));
}
}
AnyMap original;
Expand Down
16 changes: 8 additions & 8 deletions test/general/test_serialization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ TEST(YamlWriter, formatDouble)
{
AnyMap m;
int count;
float delta;
double delta;

// check least significant digit
// default precision is 15 (see AnyMap.cpp::getPrecision)
Expand Down Expand Up @@ -49,7 +49,7 @@ TEST(YamlWriter, formatDoubleExp)
{
AnyMap m;
int count;
float delta;
double delta;

// check least significant digit
// default precision is 15 (see AnyMap.cpp::getPrecision)
Expand Down Expand Up @@ -572,8 +572,8 @@ TEST(Storage, writeData)

// matrices
any = vector<vector<double>>({{1.1, 2.2, 3.3}, {4.4, 5.5, 6.6}});
EXPECT_EQ(any.matrixShape().first, 2);
EXPECT_EQ(any.matrixShape().second, 3);
EXPECT_EQ(any.matrixShape().first, 2u);
EXPECT_EQ(any.matrixShape().second, 3u);
file->writeData("test", "double-matrix", any);
any = vector<vector<long int>>({{1, 2}, {3, 4}, {5, 6}});
file->writeData("test", "integer-matrix", any);
Expand All @@ -586,7 +586,7 @@ TEST(Storage, writeData)

// invalid vectors of vectors (irregular shape)
any = vector<vector<double>>({{1.1, 2.2}, {3.3}});
EXPECT_EQ(any.matrixShape().first, 2);
EXPECT_EQ(any.matrixShape().first, 2u);
EXPECT_EQ(any.matrixShape().second, npos);
EXPECT_THROW(file->writeData("test", "invalid3", any), CanteraError);
any = vector<vector<long int>>({{1, 2}, {3, 4, 5}, {6}});
Expand Down Expand Up @@ -657,19 +657,19 @@ TEST(Storage, readData)

auto data = file->readData("test", "double-vector", 3);
ASSERT_TRUE(data.isVector<double>());
ASSERT_EQ(data.asVector<double>().size(), 3);
ASSERT_EQ(data.asVector<double>().size(), 3u);
// need to know length
EXPECT_THROW(file->readData("test", "double-vector", 4), CanteraError);

data = file->readData("test", "integer-vector", 4, 0);
ASSERT_TRUE(data.isVector<long int>());
ASSERT_EQ(data.asVector<long int>().size(), 4);
ASSERT_EQ(data.asVector<long int>().size(), 4u);
// invalid number of columns
EXPECT_THROW(file->readData("test", "integer-vector", 4, 2), CanteraError);

data = file->readData("test", "string-vector", 2);
ASSERT_TRUE(data.isVector<string>());
ASSERT_EQ(data.asVector<string>().size(), 2);
ASSERT_EQ(data.asVector<string>().size(), 2u);

data = file->readData("test", "double-matrix", 2);
ASSERT_TRUE(data.isMatrix<double>());
Expand Down
4 changes: 2 additions & 2 deletions test/oneD/test_oneD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ TEST(onedim, freeflame)
// set up simulation
vector<shared_ptr<Domain1D>> domains { inlet, flow, outlet };
Sim1D flame(domains);
int dom = flame.domainIndex("flow");
int dom = static_cast<int>(flame.domainIndex("flow"));
ASSERT_EQ(dom, 1);

// set up initial guess
Expand Down Expand Up @@ -92,7 +92,7 @@ TEST(onedim, freeflame)
flame.save("gtest-freeflame.h5", "cpp", "Solution from C++ interface", true);
}

ASSERT_EQ(flow->nPoints(), nz + 1);
ASSERT_EQ(flow->nPoints(), static_cast<size_t>(nz + 1));
size_t comp = flow->componentIndex("T");
double Tprev = flame.value(dom, comp, 0);
for (size_t n = 0; n < flow->nPoints(); n++) {
Expand Down
2 changes: 1 addition & 1 deletion test/zeroD/test_zeroD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ TEST(AdaptivePreconditionerTests, test_adaptive_precon_utils)
precon.setIlutDropTol(droptol);
EXPECT_NEAR(precon.ilutDropTol(), droptol, tol);

double fillfactor = testSize/2;
int fillfactor = static_cast<int>(testSize) / 2;
precon.setIlutFillFactor(fillfactor);
EXPECT_NEAR(precon.ilutFillFactor(), fillfactor, tol);

Expand Down

0 comments on commit 3b2ce47

Please sign in to comment.