Skip to content

Commit

Permalink
update test data and clean up debug lines
Browse files Browse the repository at this point in the history
  • Loading branch information
cheroy-ntia committed Dec 10, 2024
1 parent cc956f6 commit 4896398
Show file tree
Hide file tree
Showing 8 changed files with 297 additions and 335 deletions.
2 changes: 1 addition & 1 deletion GitHubRepoPublicReleaseApproval.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ for that branch. The following must login to GitHub and approve that pull reques
before the pull request can be merged and this repo made public:

* Project Lead: Kozma Jr, William
* Supervising Division Chief or Release Authority: TODO-TEMPLATE
* Supervising Division Chief or Release Authority: Chris Anderson
48 changes: 22 additions & 26 deletions tests/LFMFGTestUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,28 +18,24 @@
*
*****************************************************************************/
std::vector<LFMFInputsAndResult> ReadLFMFInputsAndResult(const std::string &filename) {

std::vector<LFMFInputsAndResult> testData;
std::string dataDir = GetDirectory("data");
std::ifstream file(dataDir + filename);
LFMFInputsAndResult d {}; // struct to store data from a single line of CSV

std::vector<LFMFInputsAndResult> testData;
std::string dataDir = GetDirectory("data");
std::ifstream file(dataDir + filename);
LFMFInputsAndResult d {
}; // struct to store data from a single line of CSV
try {
std::vector<std::vector<std::string>> csvRows = readCSV(file);
if (csvRows.size() <= 1) {
return testData;
}

std::vector<std::vector<std::string>> csvRows = readCSV(file);
if (csvRows.size() <= 1) {
return testData;
}

typedef std::vector<std::vector<std::string> >::size_type row_vec_size_t;
typedef std::vector<std::string>::size_type cell_vec_size_t;

for (row_vec_size_t r = 1; r < csvRows.size(); r++) {
int c = 0;
if (r % 100 == 0) {
std::cout << " Test instance: " << r << std::endl;
}
for (cell_vec_size_t i = 0; i < csvRows[0].size(); i++) {
if (csvRows[r].size() > 1) {
for (cell_vec_size_t i = 0; i < csvRows[r].size(); i++) {
try {
if (csvRows[0][i] == "h_tx__meter") {
d.h_tx__meter = std::stod(csvRows[r][i]);
Expand Down Expand Up @@ -82,35 +78,35 @@ std::vector<LFMFInputsAndResult> ReadLFMFInputsAndResult(const std::string &file
d.expectedReturn = std::stoi(csvRows[r][i]);
}
if (csvRows[0][i] == "A_btl__db") {
d.expectedResult.A_btl__db = stringToDouble(csvRows[r][i]);
d.expectedResult.A_btl__db
= stringToDouble(csvRows[r][i]);
c++;
}
if (csvRows[0][i] == "E_dBuVm") {
d.expectedResult.E_dBuVm = stringToDouble(csvRows[r][i]);
d.expectedResult.E_dBuVm
= stringToDouble(csvRows[r][i]);
c++;
}
if (csvRows[0][i] == "P_rx__dbm") {
d.expectedResult.P_rx__dbm = stringToDouble(csvRows[r][i]);
d.expectedResult.P_rx__dbm
= stringToDouble(csvRows[r][i]);
c++;
}
if (csvRows[0][i] == "method") {
d.expectedResult.method = static_cast<SolutionMethod>(std::stoi(csvRows[r][i]));
d.expectedResult.method = static_cast<SolutionMethod>(
std::stoi(csvRows[r][i])
);
c++;
}
} catch (const char *msg) {

Check warning on line 101 in tests/LFMFGTestUtils.cpp

View workflow job for this annotation

GitHub Actions / windows-latest / x64 / CMake 3.21

'msg': unreferenced local variable [D:\a\LFMF\LFMF\build\release\tests\LFMFTest.vcxproj]

Check warning on line 101 in tests/LFMFGTestUtils.cpp

View workflow job for this annotation

GitHub Actions / windows-latest / x64 / CMake latest

'msg': unreferenced local variable [D:\a\LFMF\LFMF\build\release\tests\LFMFTest.vcxproj]

Check warning on line 101 in tests/LFMFGTestUtils.cpp

View workflow job for this annotation

GitHub Actions / windows-latest / x86 / CMake 3.21

'msg': unreferenced local variable [D:\a\LFMF\LFMF\build\release\tests\LFMFTest.vcxproj]

Check warning on line 101 in tests/LFMFGTestUtils.cpp

View workflow job for this annotation

GitHub Actions / windows-latest / x86 / CMake latest

'msg': unreferenced local variable [D:\a\LFMF\LFMF\build\release\tests\LFMFTest.vcxproj]
// Code to handle the exception
std::cerr << "Error: " << r << ", " << csvRows[r][i]
<< std::endl;
std::cerr << "Error: " << r << ", " << csvRows[r][i] << std::endl;
}
}
if (c == 13) {
testData.push_back(d);
}

}
} catch (const char *msg) {
// Code to handle the exception
std::cerr << "Error: " << std::endl;
}
}
return testData;
}
Expand Down
10 changes: 0 additions & 10 deletions tests/TestLFMFPolarizationHorizontal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,9 @@ class TestLFMFPolarizationHorizontal: public ::testing::Test {
TEST_F(TestLFMFPolarizationHorizontal, FlatEarthCurveMethodEquivalentToMatLAB) {
// Ensure test data was loaded
EXPECT_NE(static_cast<int>(testData.size()), 0);
int i = 0;
for (const auto &data : testData) {
if (data.expectedResult.method == METHOD__FLAT_EARTH_CURVE) {
i++;
Result result;
if (i % 100 == 0) {
std::cout << " Test instance: " << i << std::endl;
}
int rtn = LFMF(
data.h_tx__meter,
data.h_rx__meter,
Expand Down Expand Up @@ -73,14 +68,9 @@ TEST_F(TestLFMFPolarizationHorizontal, FlatEarthCurveMethodEquivalentToMatLAB) {
TEST_F(TestLFMFPolarizationHorizontal, ResidueSeriesMethodEquivalentToMatLAB) {
// Ensure test data was loaded
EXPECT_NE(static_cast<int>(testData.size()), 0);
int i = 0;
for (const auto &data : testData) {
if (data.expectedResult.method == METHOD__RESIDUE_SERIES) {
i++;
Result result;
if (i % 100 == 0) {
std::cout << " Test instance: " << i << std::endl;
}
int rtn = LFMF(
data.h_tx__meter,
data.h_rx__meter,
Expand Down
10 changes: 0 additions & 10 deletions tests/TestLFMFPolarizationHorizontalMax.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,9 @@ class TestLFMFPolarizationHorizontalMax: public ::testing::Test {
TEST_F(TestLFMFPolarizationHorizontalMax, FlatEarthCurveMethodEquivalentToMatLAB) {
// Ensure test data was loaded
EXPECT_NE(static_cast<int>(testData.size()), 0);
int i = 0;
for (const auto &data : testData) {
if (data.expectedResult.method == METHOD__FLAT_EARTH_CURVE) {
i++;
Result result;
if (i % 100 == 0) {
std::cout << " Test instance: " << i << std::endl;
}
int rtn = LFMF(
data.h_tx__meter,
data.h_rx__meter,
Expand Down Expand Up @@ -73,14 +68,9 @@ TEST_F(TestLFMFPolarizationHorizontalMax, FlatEarthCurveMethodEquivalentToMatLAB
TEST_F(TestLFMFPolarizationHorizontalMax, ResidueSeriesMethodEquivalentToMatLAB) {
// Ensure test data was loaded
EXPECT_NE(static_cast<int>(testData.size()), 0);
int i = 0;
for (const auto &data : testData) {
if (data.expectedResult.method == METHOD__RESIDUE_SERIES) {
i++;
Result result;
if (i % 100 == 0) {
std::cout << " Test instance: " << i << std::endl;
}
int rtn = LFMF(
data.h_tx__meter,
data.h_rx__meter,
Expand Down
10 changes: 0 additions & 10 deletions tests/TestLFMFPolarizationVertical.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,9 @@ class TestLFMFPolarizationVertical: public ::testing::Test {
TEST_F(TestLFMFPolarizationVertical, FlatEarthCurveMethodEquivalentToMatLAB) {
// Ensure test data was loaded
EXPECT_NE(static_cast<int>(testData.size()), 0);
int i = 0;
for (const auto &data : testData) {
if (data.expectedResult.method == METHOD__FLAT_EARTH_CURVE) {
i++;
Result result;
if (i % 100 == 0) {
std::cout << " Test instance: " << i << std::endl;
}
int rtn = LFMF(
data.h_tx__meter,
data.h_rx__meter,
Expand Down Expand Up @@ -73,14 +68,9 @@ TEST_F(TestLFMFPolarizationVertical, FlatEarthCurveMethodEquivalentToMatLAB) {
TEST_F(TestLFMFPolarizationVertical, ResidueSeriesMethodEquivalentToMatLAB) {
// Ensure test data was loaded
EXPECT_NE(static_cast<int>(testData.size()), 0);
int i = 0;
for (const auto &data : testData) {
if (data.expectedResult.method == METHOD__RESIDUE_SERIES) {
i++;
Result result;
if (i % 100 == 0) {
std::cout << " Test instance: " << i << std::endl;
}
int rtn = LFMF(
data.h_tx__meter,
data.h_rx__meter,
Expand Down
10 changes: 0 additions & 10 deletions tests/TestLFMFPolarizationVerticalMax.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,9 @@ class TestLFMFPolarizationVerticalMax: public ::testing::Test {
TEST_F(TestLFMFPolarizationVerticalMax, FlatEarthCurveMethodEquivalentToMatLAB) {
// Ensure test data was loaded
EXPECT_NE(static_cast<int>(testData.size()), 0);
int i = 0;
for (const auto &data : testData) {
if (data.expectedResult.method == METHOD__FLAT_EARTH_CURVE) {
i++;
Result result;
if (i % 100 == 0) {
std::cout << " Test instance: " << i << std::endl;
}
int rtn = LFMF(
data.h_tx__meter,
data.h_rx__meter,
Expand Down Expand Up @@ -73,14 +68,9 @@ TEST_F(TestLFMFPolarizationVerticalMax, FlatEarthCurveMethodEquivalentToMatLAB)
TEST_F(TestLFMFPolarizationVerticalMax, ResidueSeriesMethodEquivalentToMatLAB) {
// Ensure test data was loaded
EXPECT_NE(static_cast<int>(testData.size()), 0);
int i = 0;
for (const auto &data : testData) {
if (data.expectedResult.method == METHOD__RESIDUE_SERIES) {
i++;
Result result;
if (i % 100 == 0) {
std::cout << " Test instance: " << i << std::endl;
}
int rtn = LFMF(
data.h_tx__meter,
data.h_rx__meter,
Expand Down
Loading

0 comments on commit 4896398

Please sign in to comment.