Skip to content

Commit

Permalink
Update testsuite
Browse files Browse the repository at this point in the history
  • Loading branch information
beutlich committed Jan 5, 2025
1 parent 01327dc commit d6d6bea
Show file tree
Hide file tree
Showing 8 changed files with 107 additions and 2 deletions.
8 changes: 8 additions & 0 deletions ExternData/Resources/Test/Test_ED_CSV.cc
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
/* Test_ED_CSV.cc - CSV functions tester
*
* Copyright (C) 2015-2025, Thomas Beutlich
* All rights reserved.
*
* SPDX-License-Identifier: BSD-2-Clause
*/

#include "../Include/ED_CSVFile.h"
#include "Constants.h"
#include <gtest/gtest.h>
Expand Down
8 changes: 8 additions & 0 deletions ExternData/Resources/Test/Test_ED_INI.cc
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
/* Test_ED_INI.cc - INI functions tester
*
* Copyright (C) 2015-2025, Thomas Beutlich
* All rights reserved.
*
* SPDX-License-Identifier: BSD-2-Clause
*/

#include "../Include/ED_INIFile.h"
#include "Constants.h"
#include <gtest/gtest.h>
Expand Down
8 changes: 8 additions & 0 deletions ExternData/Resources/Test/Test_ED_JSON.cc
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
/* Test_ED_JSON.cc - JSON functions tester
*
* Copyright (C) 2015-2025, Thomas Beutlich
* All rights reserved.
*
* SPDX-License-Identifier: BSD-2-Clause
*/

#include "../Include/ED_JSONFile.h"
#include "Constants.h"
#include <gtest/gtest.h>
Expand Down
53 changes: 51 additions & 2 deletions ExternData/Resources/Test/Test_ED_MAT.cc
Original file line number Diff line number Diff line change
@@ -1,16 +1,65 @@
/* Test_ED_MAT.cc - MAT functions tester
*
* Copyright (C) 2015-2025, Thomas Beutlich
* All rights reserved.
*
* SPDX-License-Identifier: BSD-2-Clause
*/

#include "../Include/ED_MATFile.h"
#include "Constants.h"
#include <array>
#include <gtest/gtest.h>

namespace
{

TEST(ED_MAT, Create) {
auto handle = ED_createMAT("../Examples/test_v7.3.mat", verbose_on);
class MATFiles
: public ::testing::TestWithParam<const char *> {
protected:
void SetUp() override {}
void TearDown() override {}
};

TEST_P(MATFiles, Create) {
auto handle = ED_createMAT(GetParam(), verbose_on);
ASSERT_NE(nullptr, handle);
ED_destroyMAT(handle);
}

TEST_P(MATFiles, GetArray2DDimensions) {
auto handle = ED_createMAT(GetParam(), verbose_on);
ASSERT_NE(nullptr, handle);
int m, n;
ED_getArray2DDimensionsFromMAT(handle, "table1", &m, &n);
EXPECT_EQ(m, 3);
EXPECT_EQ(n, 2);
ED_destroyMAT(handle);
}

TEST_P(MATFiles, GetDoubleArray2D) {
auto handle = ED_createMAT(GetParam(), verbose_on);
ASSERT_NE(nullptr, handle);
auto table = std::array<double, 6>{};
ED_getDoubleArray2DFromMAT(handle, "table1", table.data(), 3, 2);
EXPECT_EQ(table[0], 0);
EXPECT_EQ(table[1], 0);
EXPECT_EQ(table[2], 0.5);
EXPECT_EQ(table[3], 0.25);
EXPECT_EQ(table[4], 1);
EXPECT_EQ(table[5], 1);
ED_destroyMAT(handle);
}

INSTANTIATE_TEST_SUITE_P(
ED_MAT, MATFiles,
::testing::Values(
"../Examples/test_v4.mat",
"../Examples/test_v6.mat",
"../Examples/test_v7.mat",
"../Examples/test_v7.3.mat")
);

} // namespace

int main(int argc, char **argv)
Expand Down
8 changes: 8 additions & 0 deletions ExternData/Resources/Test/Test_ED_XLS.cc
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
/* Test_ED_XLS.cc - XLS functions tester
*
* Copyright (C) 2015-2025, Thomas Beutlich
* All rights reserved.
*
* SPDX-License-Identifier: BSD-2-Clause
*/

#include "../Include/ED_XLSFile.h"
#include "Constants.h"
#include <gtest/gtest.h>
Expand Down
8 changes: 8 additions & 0 deletions ExternData/Resources/Test/Test_ED_XLSX.cc
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
/* Test_ED_XLSX.cc - XLSX functions tester
*
* Copyright (C) 2015-2025, Thomas Beutlich
* All rights reserved.
*
* SPDX-License-Identifier: BSD-2-Clause
*/

#include "../Include/ED_XLSXFile.h"
#include "Constants.h"
#include <gtest/gtest.h>
Expand Down
8 changes: 8 additions & 0 deletions ExternData/Resources/Test/Test_ED_XML.cc
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
/* Test_ED_XML.cc - XML functions tester
*
* Copyright (C) 2015-2025, Thomas Beutlich
* All rights reserved.
*
* SPDX-License-Identifier: BSD-2-Clause
*/

#include "../Include/ED_XMLFile.h"
#include "Constants.h"
#include <gtest/gtest.h>
Expand Down
8 changes: 8 additions & 0 deletions ExternData/Resources/Test/Test_ED_XML2.cc
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
/* Test_ED_XML2.cc - XML2 functions tester
*
* Copyright (C) 2015-2025, Thomas Beutlich
* All rights reserved.
*
* SPDX-License-Identifier: BSD-2-Clause
*/

#include "../Include/ED_XML2File.h"
#include "Constants.h"
#include <gtest/gtest.h>
Expand Down

0 comments on commit d6d6bea

Please sign in to comment.