Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • icon-libraries/libfortran-support
1 result
Show changes
Commits on Source (3)
  • Yen-Chen Chen's avatar
    Fix header check is always true (!67) · 14b226f5
    Yen-Chen Chen authored
    
    <!--
    ICON
    
    ---------------------------------------------------------------
    Copyright (C) 2004-2024, DWD, MPI-M, DKRZ, KIT, ETH, MeteoSwiss
    Contact information: icon-model.org
    
    See AUTHORS.TXT for a list of authors
    See LICENSES/ for license information
    SPDX-License-Identifier: CC0-1.0
    ---------------------------------------------------------------
    -->
    
    ## What is the bug
    The header check macros are always true
    ## How do you fix it
    Make it configured to the same as the CMake variable, where the presence of the header is checked.
    
    ## How urgent is the bugfix
    - [ ] I need it as soon as possible
    - [x] I can wait for a couple of days
    - [ ] None of my current codes is directly affected
    
    ## Mandatory steps before review
    - [x] Gitlab CI passes _(Hint: use `make format` for linting)_ 
    - [x] Bugfix is covered by additional unit tests
    - [x] Mark the merge request as ready by removing `Draft:`
    
    ## Mandatory steps before merge
    - [x] Test coverage does not decrease
    - [ ] Reviewed by a maintainer
    - [ ] Incorporate review suggestions
    - [ ] Remember to edit the commit message and select the proper changelog category (feature/bugfix/other)
    
    **You are not supposed to merge this request by yourself, the maintainers of fortan-support take care of this action!**
    
    Approved-by: default avatarJonas Jucker <jonas.jucker@env.ethz.ch>
    Merged-by: default avatarJonas Jucker <jonas.jucker@env.ethz.ch>
    Changelog: bugfix
    14b226f5
  • Yen-Chen Chen's avatar
    Add missing C tests (!66) · 03b240df
    Yen-Chen Chen authored
    <!--
    ICON
    
    ---------------------------------------------------------------
    Copyright (C) 2004-2024, DWD, MPI-M, DKRZ, KIT, ETH, MeteoSwiss
    Contact information: icon-model.org
    
    See AUTHORS.TXT for a list of authors
    See LICENSES/ for license information
    SPDX-License-Identifier: CC0-1.0
    ---------------------------------------------------------------
    -->
    
    ## What is the new feature
    Continue adding C tests. This MR closes #6
    
    
    ## How is it implemented
    
    
    ## Mandatory steps before review
    - [x] Gitlab CI passes _(Hint: use `make format` for linting)_ 
    - [x] New feature is covered by additional unit tests
    - [x] Mark the merge request as ready by removing `Draft:`
    
    ## Mandatory steps before merge
    - [x] Test coverage does not decrease
    - [x] Reviewed by a maintainer
    - [x] Incorporate review suggestions
    - [ ] Remember to edit the commit message and select the proper changelog category (feature/bugfix/other)
    
    **You are not supposed to merge this request by yourself, the maintainers of fortan-support take care of this action!**
    
    Approved-by: default avatarJonas Jucker <jonas.jucker@env.ethz.ch>
    Approved-by: default avatarTerry Cojean <terry.cojean@kit.edu>
    Merged-by: default avatarYen-Chen Chen <yen-chen.chen@kit.edu>
    Changelog: other
    03b240df
  • Yen-Chen Chen's avatar
    Add test for fortran_tools (!68) · ea5751bf
    Yen-Chen Chen authored
    
    <!--
    ICON
    
    ---------------------------------------------------------------
    Copyright (C) 2004-2024, DWD, MPI-M, DKRZ, KIT, ETH, MeteoSwiss
    Contact information: icon-model.org
    
    See AUTHORS.TXT for a list of authors
    See LICENSES/ for license information
    SPDX-License-Identifier: CC0-1.0
    ---------------------------------------------------------------
    -->
    
    ## What is the new feature
    _Please describe your feature in a couple of words._
    ## How is it implemented
    _Describe important implementation details of the feature._
    
    ## Mandatory steps before review
    - [x] Gitlab CI passes _(Hint: use `make format` for linting)_ 
    - [x] New feature is covered by additional unit tests
    - [x] Mark the merge request as ready by removing `Draft:`
    
    ## Mandatory steps before merge
    - [x] Test coverage does not decrease
    - [x] Reviewed by a maintainer
    - [x] Incorporate review suggestions
    - [ ] Remember to edit the commit message and select the proper changelog category (feature/bugfix/other)
    
    **You are not supposed to merge this request by yourself, the maintainers of fortan-support take care of this action!**
    
    Approved-by: default avatarJonas Jucker <jonas.jucker@env.ethz.ch>
    Merged-by: default avatarJonas Jucker <jonas.jucker@env.ethz.ch>
    Changelog: other
    ea5751bf
......@@ -11,8 +11,8 @@
macro(add_icon_c_test test_name file_names)
add_executable("CTest_${test_name}" ${file_names})
target_link_libraries("CTest_${test_name}" PRIVATE fortran-support::fortran-support GTest::gtest_main)
target_link_libraries("CTest_${test_name}" PRIVATE fortran-support::fortran-support GTest::gtest_main stdc++fs)
add_test(NAME "CTest_${test_name}" COMMAND "CTest_${test_name}")
set_property(TEST "CTest_${test_name}" PROPERTY LABELS C)
set_target_properties("CTest_${test_name}" PROPERTIES CXX_STANDARD 14 CXX_STANDARD_REQUIRED ON)
set_target_properties("CTest_${test_name}" PROPERTIES CXX_STANDARD 17 CXX_STANDARD_REQUIRED ON)
endmacro()
......@@ -13,6 +13,7 @@ include(CheckIncludeFiles)
check_include_files("execinfo.h" HAVE_EXECINFO_H)
check_include_files("link.h" HAVE_LINK_H)
check_include_files("unwind.h" HAVE_UNWIND_H)
check_include_files("sys/resource.h" HAVE_GETRUSAGE)
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/config.h.in
......
......@@ -9,10 +9,10 @@
// SPDX-License-Identifier: BSD-3-Clause
// ---------------------------------------------------------------
#cmakedefine HAVE_EXECINFO_H 1
#cmakedefine HAVE_EXECINFO_H @HAVE_EXECINFO_H@
#cmakedefine HAVE_LINK_H 1
#cmakedefine HAVE_LINK_H @HAVE_LINK_H@
#cmakedefine HAVE_UNWIND_H 1
#cmakedefine HAVE_UNWIND_H @HAVE_UNWIND_H@
#cmakedefine HAVE_PTHREAD_H 1
#cmakedefine HAVE_GETRUSAGE @HAVE_GETRUSAGE@
// ICON
//
// ---------------------------------------------------------------
// Copyright (C) 2004-2024, DWD, MPI-M, DKRZ, KIT, ETH, MeteoSwiss
// Contact information: icon-model.org
//
// See AUTHORS.TXT for a list of authors
// See LICENSES/ for license information
// SPDX-License-Identifier: BSD-3-Clause
// ---------------------------------------------------------------
#ifndef NML_ANNOTATE_H
#define NML_ANNOTATE_H
#ifdef __cplusplus
extern "C" {
#endif
int util_annotate_nml(char *in_filename, char *out_filename);
#ifdef __cplusplus
}
#endif
#endif // NML_ANNOTATE_H
......@@ -136,7 +136,6 @@ int createSymlink(const char *targetPath, const char *linkName) {
}
// At this point we know that there is no file at linkName.
errno = 0;
symlink(targetPath, linkName);
return errno;
int err = symlink(targetPath, linkName);
return err != 0 ? errno : err;
}
......@@ -17,8 +17,10 @@ extern "C" {
#endif
int util_islink(char *path);
int util_create_tmpfile(char *filename, const int max_len);
long int util_filesize(char *filename);
int util_file_is_writable(char *filename);
int createSymlink(const char *targetPath, const char *linkName);
#ifdef __cplusplus
}
......
......@@ -133,8 +133,6 @@ void util_node_name(char *name, int *actual_len) {
/* Get the maximum resident set size used, in kilobytes. That is, the maximum
* number of kilobytes of physical memory that processes used
* simultaneously.
*
* 11/2011 : F. Prill, DWD
*/
void util_get_maxrss(int *maxrss) {
#if defined HAVE_GETRUSAGE
......
// ICON
//
// ---------------------------------------------------------------
// Copyright (C) 2004-2024, DWD, MPI-M, DKRZ, KIT, ETH, MeteoSwiss
// Contact information: icon-model.org
//
// See AUTHORS.TXT for a list of authors
// See LICENSES/ for license information
// SPDX-License-Identifier: BSD-3-Clause
// ---------------------------------------------------------------
#ifndef UTIL_SYSINFO_H
#define UTIL_SYSINFO_H
#ifdef __cplusplus
extern "C" {
#endif
void util_user_name(char *name, int *actual_len);
void util_os_system(char *name, int *actual_len);
void util_node_name(char *name, int *actual_len);
void util_get_maxrss(int *maxrss);
void util_compiler_release(char *release_str, int *rstr_len);
void util_c_getpid(long int *pid);
#ifdef __cplusplus
}
#endif
#endif // UTIL_SYSINFO_H
\ No newline at end of file
// ICON
//
// ---------------------------------------------------------------
// Copyright (C) 2004-2024, DWD, MPI-M, DKRZ, KIT, ETH, MeteoSwiss
// Contact information: icon-model.org
//
// See AUTHORS.TXT for a list of authors
// See LICENSES/ for license information
// SPDX-License-Identifier: BSD-3-Clause
// ---------------------------------------------------------------
#ifndef UTIL_TIMER_H
#define UTIL_TIMER_H
#ifdef __cplusplus
extern "C" {
#endif
int util_cputime(double *user_time, double *system_time);
double util_walltime();
double util_gettimeofday();
void util_init_real_time();
void util_get_real_time_size(int *rt_size);
void util_read_real_time(void *it);
void util_diff_real_time(void *it1, void *it2, double *t);
#ifdef __cplusplus
}
#endif
#endif // UTIL_TIMER_H
\ No newline at end of file
......@@ -44,11 +44,36 @@ if (BACKTRACE_TEST)
add_icon_c_test(UtilBacktraceTest ctest_util_backtrace.cpp)
endif()
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/test.namelist"
"&info_nml\n"
" file_name = 'test.namelist'\n"
" keywords = 'unit test','C language','nml_annotate'\n"
"/\n"
"&test_nml\n"
" numbers = 0,1,2,3\n"
" floating_points = -7.1,1.0,3.7,8.9\n"
" booleans = .TRUE., .FALSE., .true.\n"
" chars = 'unit', 'test'\n"
"/\n")
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/result.namelist"
"\n"
"NAMELIST info_nml\n"
" file_name 'test.namelist'\n"
" keywords 'unit test', 'C language', 'nml_annotate'\n"
"\n"
"NAMELIST test_nml\n"
" numbers 0, 1, 2, 3\n"
" floating_points -7.1, 1.0, 3.7, 8.9\n"
" booleans .TRUE., .FALSE., .true.\n"
" chars 'unit', 'test'\n")
add_icon_c_test(UtilNmlAnnotateTest ctest_nml_annotate.cpp)
add_icon_c_test(UtilArithmeticExprTest ctest_util_arithmetic_expr.cpp)
add_icon_c_test(UtilHashTest ctest_util_hash.cpp)
add_icon_c_test(UtilStrideTest ctest_util_stride.cpp)
add_icon_c_test(UtilStringParseTest ctest_util_string_parse.cpp)
add_icon_c_test(UtilSysinfoTest ctest_util_sysinfo.cpp)
add_icon_c_test(UtilSystemTest ctest_util_system.cpp)
add_icon_c_test(UtilTimerTest ctest_util_timer.cpp)
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/util_file_test.txt"
"This is a test file for unit tests for util_file.c\n")
......
// ICON
//
// ---------------------------------------------------------------
// Copyright (C) 2004-2024, DWD, MPI-M, DKRZ, KIT, ETH, MeteoSwiss
// Contact information: icon-model.org
//
// See AUTHORS.TXT for a list of authors
// See LICENSES/ for license information
// SPDX-License-Identifier: BSD-3-Clause
// ---------------------------------------------------------------
#include <gtest/gtest.h>
#include <fstream>
#include <filesystem>
#include <nml_annotate.h>
static std::string working_dir;
class NmlAnnotateTest : public ::testing::Test {
protected:
void EXPECT_FILE_EQ(const std::string &file1, const std::string &file2) {
std::fstream fs1, fs2;
fs1.open(file1);
fs2.open(file2);
std::string line_in_file1, line_in_file2;
bool error = false;
int line_num = 0;
while (fs1) {
std::getline(fs1, line_in_file1);
std::getline(fs2, line_in_file2);
EXPECT_EQ(line_in_file1, line_in_file2)
<< "line " << line_num << " is different";
line_num++;
}
fs1.close();
fs2.close();
}
};
TEST_F(NmlAnnotateTest, CanAnnotateNamelist) {
std::string namelist_file = working_dir + "/test.namelist";
std::string annotate_file = working_dir + "/annotated.namelist";
std::string result_file = working_dir + "/result.namelist";
char *namelist_file_cstr, *annotate_file_cstr;
namelist_file_cstr = &namelist_file[0];
annotate_file_cstr = &annotate_file[0];
EXPECT_NO_THROW(
{ util_annotate_nml(namelist_file_cstr, annotate_file_cstr); });
EXPECT_FILE_EQ(annotate_file, result_file);
}
int main(int argc, char **argv) {
::testing::InitGoogleTest(&argc, argv);
std::filesystem::path path = argv[0];
working_dir = path.parent_path();
std::cout << "Working directory: " << working_dir << std::endl;
return RUN_ALL_TESTS();
}
......@@ -13,12 +13,19 @@
#include <string>
#include <iostream>
#include <filesystem>
#include <util_file.h>
static std::string working_dir = ".";
static std::string working_dir;
class UtilFileTest : public ::testing::Test {};
class UtilFileTest : public ::testing::Test {
protected:
static bool ContainsSubstring(const std::string &str,
const std::string &substr) {
return str.find(substr) != std::string::npos;
}
};
TEST_F(UtilFileTest, FileIsLink) {
......@@ -35,6 +42,23 @@ TEST_F(UtilFileTest, FileIsLink) {
EXPECT_EQ(util_islink(file_cstr), -1);
}
TEST_F(UtilFileTest, CanCreateTmpFile) {
int filename_len;
char filename_cstr[30];
filename_len = util_create_tmpfile(filename_cstr, 30);
std::cout << "Temporary file " << filename_cstr << " created." << std::endl;
std::string filename(filename_cstr);
EXPECT_PRED2(ContainsSubstring, filename, "/tmp/icon");
EXPECT_EQ(filename_len, 24);
EXPECT_EQ(util_create_tmpfile(filename_cstr, 10), -1);
std::filesystem::remove(filename);
}
TEST_F(UtilFileTest, CanGetFileSize) {
std::string file = working_dir + "/util_file_test.txt";
......@@ -45,7 +69,6 @@ TEST_F(UtilFileTest, CanGetFileSize) {
EXPECT_EQ(util_filesize(file_cstr), 51);
}
TEST_F(UtilFileTest, CheckFileWritable) {
std::string file = working_dir + "/util_file_test.txt";
......@@ -55,12 +78,23 @@ TEST_F(UtilFileTest, CheckFileWritable) {
EXPECT_EQ(util_file_is_writable(file_cstr), 1);
}
TEST_F(UtilFileTest, CanCreateSymlink) {
std::string target_file = working_dir + "/util_file_test.txt";
std::string new_link = working_dir + "/util_file_new_link.txt";
EXPECT_EQ(createSymlink(target_file.c_str(), new_link.c_str()), 0);
char *new_link_cstr = &new_link[0];
EXPECT_EQ(util_islink(new_link_cstr), 1);
}
int main(int argc, char **argv) {
::testing::InitGoogleTest(&argc, argv);
if (argc > 1) {
working_dir = argv[1];
}
std::filesystem::path path = argv[0];
working_dir = path.parent_path();
std::cout << "Working directory: " << working_dir << std::endl;
......
......@@ -39,3 +39,115 @@ TEST_F(UtilHashCTest, HashwordIsCorrect2) {
EXPECT_EQ(hashword, 1976263765);
}
TEST_F(UtilHashCTest, HashwordIsCorrect_l0) {
std::string s = "";
uint32_t hashword = util_hashword(&s[0], s.length(), 0);
EXPECT_EQ(hashword, 3735928559);
}
TEST_F(UtilHashCTest, HashwordIsCorrect_l1) {
std::string s = "U";
uint32_t hashword = util_hashword(&s[0], s.length(), 0);
EXPECT_EQ(hashword, 2658498343);
}
TEST_F(UtilHashCTest, HashwordIsCorrect_l2) {
std::string s = "UT";
uint32_t hashword = util_hashword(&s[0], s.length(), 0);
EXPECT_EQ(hashword, 1367754127);
}
TEST_F(UtilHashCTest, HashwordIsCorrect_l3) {
std::string s = "UiT";
uint32_t hashword = util_hashword(&s[0], s.length(), 0);
EXPECT_EQ(hashword, 1170274080);
}
TEST_F(UtilHashCTest, HashwordIsCorrect_l4) {
std::string s = "UniT";
uint32_t hashword = util_hashword(&s[0], s.length(), 0);
EXPECT_EQ(hashword, 4137270609);
}
TEST_F(UtilHashCTest, HashwordIsCorrect_l5) {
std::string s = "UniTt";
uint32_t hashword = util_hashword(&s[0], s.length(), 0);
EXPECT_EQ(hashword, 2664783129);
}
TEST_F(UtilHashCTest, HashwordIsCorrect_l6) {
std::string s = "UniTet";
uint32_t hashword = util_hashword(&s[0], s.length(), 0);
EXPECT_EQ(hashword, 604414756);
}
TEST_F(UtilHashCTest, HashwordIsCorrect_l7) {
std::string s = "UniTest";
uint32_t hashword = util_hashword(&s[0], s.length(), 0);
EXPECT_EQ(hashword, 3603701657);
}
TEST_F(UtilHashCTest, HashwordIsCorrect_l8) {
std::string s = "UnitTest";
uint32_t hashword = util_hashword(&s[0], s.length(), 0);
EXPECT_EQ(hashword, 2518181024);
}
TEST_F(UtilHashCTest, HashwordIsCorrect_l9) {
std::string s = "UnitTests";
uint32_t hashword = util_hashword(&s[0], s.length(), 0);
EXPECT_EQ(hashword, 1752525959);
}
TEST_F(UtilHashCTest, HashwordIsCorrect_l10) {
std::string s = "CUnitTests";
uint32_t hashword = util_hashword(&s[0], s.length(), 0);
EXPECT_EQ(hashword, 693311643);
}
TEST_F(UtilHashCTest, HashwordIsCorrect_l11) {
std::string s = "UnitTestTMP";
uint32_t hashword = util_hashword(&s[0], s.length(), 0);
EXPECT_EQ(hashword, 1109590718);
}
TEST_F(UtilHashCTest, HashwordIsCorrect_l12) {
std::string s = "UnitTestForC";
uint32_t hashword = util_hashword(&s[0], s.length(), 0);
EXPECT_EQ(hashword, 3182545988);
}
TEST_F(UtilHashCTest, HashwordIsCorrect_l13) {
std::string s = "UnitTestFrCPP";
uint32_t hashword = util_hashword(&s[0], s.length(), 0);
EXPECT_EQ(hashword, 3082204807);
}
// ICON
//
// ---------------------------------------------------------------
// Copyright (C) 2004-2024, DWD, MPI-M, DKRZ, KIT, ETH, MeteoSwiss
// Contact information: icon-model.org
//
// See AUTHORS.TXT for a list of authors
// See LICENSES/ for license information
// SPDX-License-Identifier: BSD-3-Clause
// ---------------------------------------------------------------
#include <gtest/gtest.h>
#include <util_sysinfo.h>
class UtilSysinfoTest : public ::testing::Test {};
TEST_F(UtilSysinfoTest, CanGetUserName) {
char name[100];
int actual_len;
EXPECT_NO_THROW({ util_user_name(name, &actual_len); });
EXPECT_GT(actual_len, 0);
}
TEST_F(UtilSysinfoTest, CanGetOsSystem) {
char name[100];
int actual_len;
EXPECT_NO_THROW({ util_os_system(name, &actual_len); });
EXPECT_GT(actual_len, 0);
}
TEST_F(UtilSysinfoTest, CanGetNodeName) {
char name[100];
int actual_len;
EXPECT_NO_THROW({ util_node_name(name, &actual_len); });
EXPECT_GT(actual_len, 0);
}
TEST_F(UtilSysinfoTest, CanGetMaxResidentSetSize) {
int maxrss;
EXPECT_NO_THROW({ util_get_maxrss(&maxrss); });
}
TEST_F(UtilSysinfoTest, CanGetCompilerRelease) {
char release_str[100];
int rstr_len;
EXPECT_NO_THROW({ util_compiler_release(release_str, &rstr_len); });
EXPECT_GT(rstr_len, 0);
}
TEST_F(UtilSysinfoTest, CanGetProcessId) {
long int pid;
EXPECT_NO_THROW({ util_c_getpid(&pid); });
}
// ICON
//
// ---------------------------------------------------------------
// Copyright (C) 2004-2024, DWD, MPI-M, DKRZ, KIT, ETH, MeteoSwiss
// Contact information: icon-model.org
//
// See AUTHORS.TXT for a list of authors
// See LICENSES/ for license information
// SPDX-License-Identifier: BSD-3-Clause
// ---------------------------------------------------------------
#include <gtest/gtest.h>
#include <util_timer.h>
class UtilTimerTest : public ::testing::Test {};
TEST_F(UtilTimerTest, CanGetUserTime) {
double user_time, system_time;
EXPECT_NO_THROW({ util_cputime(&user_time, &system_time); });
}
TEST_F(UtilTimerTest, CanGetWallTime) {
EXPECT_NO_THROW({ double walltime = util_walltime(); });
}
TEST_F(UtilTimerTest, CanGetTimeOfDay) {
EXPECT_NO_THROW({ double walltime = util_gettimeofday(); });
}
TEST_F(UtilTimerTest, CanInitializeFineTimer) {
EXPECT_NO_THROW({ util_init_real_time(); });
}
TEST_F(UtilTimerTest, RealTimeSizeIsCorrect) {
int rt_size;
util_get_real_time_size(&rt_size);
EXPECT_EQ(rt_size, 8);
}
TEST_F(UtilTimerTest, CanReadRealTime) {
void *time_ptr = ::operator new(1);
EXPECT_NO_THROW({ util_read_real_time(time_ptr); });
}
TEST_F(UtilTimerTest, CanGetDiffRealTime) {
double t1 = 999, t2 = 1000, t_diff;
void *ptr1 = &t1, *ptr2 = &t2;
util_diff_real_time(ptr1, ptr2, &t_diff);
EXPECT_EQ(t_diff, 1);
}
......@@ -754,6 +754,106 @@ CONTAINS
CALL ASSERT_EQUAL(SIZE(ptr_out, 3), 10)
END SUBROUTINE
SUBROUTINE Test_insert_dimension_r_dp_3_2_test2
REAL(dp), POINTER :: ptr_out(:, :, :)
REAL(dp), TARGET :: ptr_in(1, 10)
CALL insert_dimension(ptr_out, ptr_in, 2)
CALL TAG_TEST("Test_insert_dimension_r_dp_3_2_test2_first_dim")
CALL ASSERT_EQUAL(SIZE(ptr_out, 1), 1)
CALL TAG_TEST("Test_insert_dimension_r_dp_3_2_test2_second_dim")
CALL ASSERT_EQUAL(SIZE(ptr_out, 2), 1)
CALL TAG_TEST("Test_insert_dimension_r_dp_3_2_test2_third_dim")
CALL ASSERT_EQUAL(SIZE(ptr_out, 3), 10)
CALL insert_dimension(ptr_out, ptr_in, 1)
CALL TAG_TEST("Test_insert_dimension_r_dp_3_2_test2_first_dim2")
CALL ASSERT_EQUAL(SIZE(ptr_out, 1), 1)
CALL TAG_TEST("Test_insert_dimension_r_dp_3_2_test2_second_dim2")
CALL ASSERT_EQUAL(SIZE(ptr_out, 2), 1)
CALL TAG_TEST("Test_insert_dimension_r_dp_3_2_test2_third_dim2")
CALL ASSERT_EQUAL(SIZE(ptr_out, 3), 10)
END SUBROUTINE
SUBROUTINE Test_insert_dimension_r_dp_3_2_test3
REAL(dp), POINTER :: ptr_out(:, :, :)
REAL(dp), TARGET :: ptr_in(5, 1)
CALL insert_dimension(ptr_out, ptr_in, 2)
CALL TAG_TEST("Test_insert_dimension_r_dp_3_2_test3_first_dim")
CALL ASSERT_EQUAL(SIZE(ptr_out, 1), 5)
CALL TAG_TEST("Test_insert_dimension_r_dp_3_2_test3_second_dim")
CALL ASSERT_EQUAL(SIZE(ptr_out, 2), 1)
CALL TAG_TEST("Test_insert_dimension_r_dp_3_2_test3_third_dim")
CALL ASSERT_EQUAL(SIZE(ptr_out, 3), 1)
CALL insert_dimension(ptr_out, ptr_in, 1)
CALL TAG_TEST("Test_insert_dimension_r_dp_3_2_test3_first_dim2")
CALL ASSERT_EQUAL(SIZE(ptr_out, 1), 1)
CALL TAG_TEST("Test_insert_dimension_r_dp_3_2_test3_second_dim2")
CALL ASSERT_EQUAL(SIZE(ptr_out, 2), 5)
CALL TAG_TEST("Test_insert_dimension_r_dp_3_2_test3_third_dim2")
CALL ASSERT_EQUAL(SIZE(ptr_out, 3), 1)
END SUBROUTINE
SUBROUTINE Test_insert_dimension_r_dp_3_2_test4
REAL(dp), POINTER :: ptr_out(:, :, :)
REAL(dp), TARGET :: ptr_in(1, 1)
CALL insert_dimension(ptr_out, ptr_in, 2)
CALL TAG_TEST("Test_insert_dimension_r_dp_3_2_test4_first_dim")
CALL ASSERT_EQUAL(SIZE(ptr_out, 1), 1)
CALL TAG_TEST("Test_insert_dimension_r_dp_3_2_test4_second_dim")
CALL ASSERT_EQUAL(SIZE(ptr_out, 2), 1)
CALL TAG_TEST("Test_insert_dimension_r_dp_3_2_test4_third_dim")
CALL ASSERT_EQUAL(SIZE(ptr_out, 3), 1)
CALL insert_dimension(ptr_out, ptr_in, 1)
CALL TAG_TEST("Test_insert_dimension_r_dp_3_2_test4_first_dim2")
CALL ASSERT_EQUAL(SIZE(ptr_out, 1), 1)
CALL TAG_TEST("Test_insert_dimension_r_dp_3_2_test4_second_dim2")
CALL ASSERT_EQUAL(SIZE(ptr_out, 2), 1)
CALL TAG_TEST("Test_insert_dimension_r_dp_3_2_test4_third_dim2")
CALL ASSERT_EQUAL(SIZE(ptr_out, 3), 1)
END SUBROUTINE
SUBROUTINE Test_insert_dimension_r_dp_3_2_test5
REAL(dp), POINTER :: ptr_out(:, :, :)
REAL(dp), TARGET :: ptr_in(0, 0)
CALL insert_dimension(ptr_out, ptr_in, 2)
CALL TAG_TEST("Test_insert_dimension_r_dp_3_2_test5_first_dim")
CALL ASSERT_EQUAL(SIZE(ptr_out, 1), 0)
CALL TAG_TEST("Test_insert_dimension_r_dp_3_2_test5_second_dim")
CALL ASSERT_EQUAL(SIZE(ptr_out, 2), 1)
CALL TAG_TEST("Test_insert_dimension_r_dp_3_2_test5_third_dim")
CALL ASSERT_EQUAL(SIZE(ptr_out, 3), 0)
CALL insert_dimension(ptr_out, ptr_in, 1)
CALL TAG_TEST("Test_insert_dimension_r_dp_3_2_test5_first_dim2")
CALL ASSERT_EQUAL(SIZE(ptr_out, 1), 1)
CALL TAG_TEST("Test_insert_dimension_r_dp_3_2_test5_second_dim2")
CALL ASSERT_EQUAL(SIZE(ptr_out, 2), 0)
CALL TAG_TEST("Test_insert_dimension_r_dp_3_2_test5_third_dim2")
CALL ASSERT_EQUAL(SIZE(ptr_out, 3), 0)
END SUBROUTINE
SUBROUTINE Test_insert_dimension_r_sp_3_2
REAL(sp), POINTER :: ptr_out(:, :, :)
REAL(sp), TARGET :: ptr_in(5, 10)
......@@ -780,6 +880,110 @@ CONTAINS
CALL ASSERT_EQUAL(SIZE(ptr_out, 3), 10)
END SUBROUTINE
SUBROUTINE Test_insert_dimension_r_sp_3_2_test2
REAL(sp), POINTER :: ptr_out(:, :, :)
REAL(sp), TARGET :: ptr_in(1, 10)
ptr_in = 1.0
CALL insert_dimension(ptr_out, ptr_in, 2)
CALL TAG_TEST("Test_insert_dimension_r_sp_3_2_test2_first_dim")
CALL ASSERT_EQUAL(SIZE(ptr_out, 1), 1)
CALL TAG_TEST("Test_insert_dimension_r_sp_3_2_test2_second_dim")
CALL ASSERT_EQUAL(SIZE(ptr_out, 2), 1)
CALL TAG_TEST("Test_insert_dimension_r_sp_3_2_test2_third_dim")
CALL ASSERT_EQUAL(SIZE(ptr_out, 3), 10)
CALL insert_dimension(ptr_out, ptr_in, 1)
CALL TAG_TEST("Test_insert_dimension_r_sp_3_2_test2_first_dim2")
CALL ASSERT_EQUAL(SIZE(ptr_out, 1), 1)
CALL TAG_TEST("Test_insert_dimension_r_sp_3_2_test2_second_dim2")
CALL ASSERT_EQUAL(SIZE(ptr_out, 2), 1)
CALL TAG_TEST("Test_insert_dimension_r_sp_3_2_test2_third_dim2")
CALL ASSERT_EQUAL(SIZE(ptr_out, 3), 10)
END SUBROUTINE
SUBROUTINE Test_insert_dimension_r_sp_3_2_test3
REAL(sp), POINTER :: ptr_out(:, :, :)
REAL(sp), TARGET :: ptr_in(5, 1)
ptr_in = 1.0
CALL insert_dimension(ptr_out, ptr_in, 2)
CALL TAG_TEST("Test_insert_dimension_r_sp_3_2_test3_first_dim")
CALL ASSERT_EQUAL(SIZE(ptr_out, 1), 5)
CALL TAG_TEST("Test_insert_dimension_r_sp_3_2_test3_second_dim")
CALL ASSERT_EQUAL(SIZE(ptr_out, 2), 1)
CALL TAG_TEST("Test_insert_dimension_r_sp_3_2_test3_third_dim")
CALL ASSERT_EQUAL(SIZE(ptr_out, 3), 1)
CALL insert_dimension(ptr_out, ptr_in, 1)
CALL TAG_TEST("Test_insert_dimension_r_sp_3_2_test3_first_dim2")
CALL ASSERT_EQUAL(SIZE(ptr_out, 1), 1)
CALL TAG_TEST("Test_insert_dimension_r_sp_3_2_test3_second_dim2")
CALL ASSERT_EQUAL(SIZE(ptr_out, 2), 5)
CALL TAG_TEST("Test_insert_dimension_r_sp_3_2_test3_third_dim2")
CALL ASSERT_EQUAL(SIZE(ptr_out, 3), 1)
END SUBROUTINE
SUBROUTINE Test_insert_dimension_r_sp_3_2_test4
REAL(sp), POINTER :: ptr_out(:, :, :)
REAL(sp), TARGET :: ptr_in(1, 1)
ptr_in = 1.0
CALL insert_dimension(ptr_out, ptr_in, 2)
CALL TAG_TEST("Test_insert_dimension_r_sp_3_2_test4_first_dim")
CALL ASSERT_EQUAL(SIZE(ptr_out, 1), 1)
CALL TAG_TEST("Test_insert_dimension_r_sp_3_2_test4_second_dim")
CALL ASSERT_EQUAL(SIZE(ptr_out, 2), 1)
CALL TAG_TEST("Test_insert_dimension_r_sp_3_2_test4_third_dim")
CALL ASSERT_EQUAL(SIZE(ptr_out, 3), 1)
CALL insert_dimension(ptr_out, ptr_in, 1)
CALL TAG_TEST("Test_insert_dimension_r_sp_3_2_test4_first_dim2")
CALL ASSERT_EQUAL(SIZE(ptr_out, 1), 1)
CALL TAG_TEST("Test_insert_dimension_r_sp_3_2_test4_second_dim2")
CALL ASSERT_EQUAL(SIZE(ptr_out, 2), 1)
CALL TAG_TEST("Test_insert_dimension_r_sp_3_2_test4_third_dim2")
CALL ASSERT_EQUAL(SIZE(ptr_out, 3), 1)
END SUBROUTINE
SUBROUTINE Test_insert_dimension_r_sp_3_2_test5
REAL(sp), POINTER :: ptr_out(:, :, :)
REAL(sp), TARGET :: ptr_in(0, 0)
ptr_in = 1.0
CALL insert_dimension(ptr_out, ptr_in, 2)
CALL TAG_TEST("Test_insert_dimension_r_sp_3_2_test5_first_dim")
CALL ASSERT_EQUAL(SIZE(ptr_out, 1), 0)
CALL TAG_TEST("Test_insert_dimension_r_sp_3_2_test5_second_dim")
CALL ASSERT_EQUAL(SIZE(ptr_out, 2), 1)
CALL TAG_TEST("Test_insert_dimension_r_sp_3_2_test5_third_dim")
CALL ASSERT_EQUAL(SIZE(ptr_out, 3), 0)
CALL insert_dimension(ptr_out, ptr_in, 1)
CALL TAG_TEST("Test_insert_dimension_r_sp_3_2_test5_first_dim2")
CALL ASSERT_EQUAL(SIZE(ptr_out, 1), 1)
CALL TAG_TEST("Test_insert_dimension_r_sp_3_2_test5_second_dim2")
CALL ASSERT_EQUAL(SIZE(ptr_out, 2), 0)
CALL TAG_TEST("Test_insert_dimension_r_sp_3_2_test5_third_dim2")
CALL ASSERT_EQUAL(SIZE(ptr_out, 3), 0)
END SUBROUTINE
SUBROUTINE Test_insert_dimension_i4_3_2
INTEGER(i4), POINTER :: ptr_out(:, :, :)
INTEGER(i4), TARGET :: ptr_in(5, 10)
......@@ -805,6 +1009,106 @@ CONTAINS
CALL ASSERT_EQUAL(SIZE(ptr_out, 3), 10)
END SUBROUTINE
SUBROUTINE Test_insert_dimension_i4_3_2_test2
INTEGER(i4), POINTER :: ptr_out(:, :, :)
INTEGER(i4), TARGET :: ptr_in(1, 10)
CALL insert_dimension(ptr_out, ptr_in, 2)
CALL TAG_TEST("Test_insert_dimension_i4_3_2_test2_first_dim")
CALL ASSERT_EQUAL(SIZE(ptr_out, 1), 1)
CALL TAG_TEST("Test_insert_dimension_i4_3_2_test2_second_dim")
CALL ASSERT_EQUAL(SIZE(ptr_out, 2), 1)
CALL TAG_TEST("Test_insert_dimension_i4_3_2_test2_third_dim")
CALL ASSERT_EQUAL(SIZE(ptr_out, 3), 10)
CALL insert_dimension(ptr_out, ptr_in, 1)
CALL TAG_TEST("Test_insert_dimension_i4_3_2_test2_first_dim2")
CALL ASSERT_EQUAL(SIZE(ptr_out, 1), 1)
CALL TAG_TEST("Test_insert_dimension_i4_3_2_test2_second_dim2")
CALL ASSERT_EQUAL(SIZE(ptr_out, 2), 1)
CALL TAG_TEST("Test_insert_dimension_i4_3_2_test2_third_dim2")
CALL ASSERT_EQUAL(SIZE(ptr_out, 3), 10)
END SUBROUTINE
SUBROUTINE Test_insert_dimension_i4_3_2_test3
INTEGER(i4), POINTER :: ptr_out(:, :, :)
INTEGER(i4), TARGET :: ptr_in(5, 1)
CALL insert_dimension(ptr_out, ptr_in, 2)
CALL TAG_TEST("Test_insert_dimension_i4_3_2_test3_first_dim")
CALL ASSERT_EQUAL(SIZE(ptr_out, 1), 5)
CALL TAG_TEST("Test_insert_dimension_i4_3_2_test3_second_dim")
CALL ASSERT_EQUAL(SIZE(ptr_out, 2), 1)
CALL TAG_TEST("Test_insert_dimension_i4_3_2_test3_third_dim")
CALL ASSERT_EQUAL(SIZE(ptr_out, 3), 1)
CALL insert_dimension(ptr_out, ptr_in, 1)
CALL TAG_TEST("Test_insert_dimension_i4_3_2_test3_first_dim2")
CALL ASSERT_EQUAL(SIZE(ptr_out, 1), 1)
CALL TAG_TEST("Test_insert_dimension_i4_3_2_test3_second_dim2")
CALL ASSERT_EQUAL(SIZE(ptr_out, 2), 5)
CALL TAG_TEST("Test_insert_dimension_i4_3_2_test3_third_dim2")
CALL ASSERT_EQUAL(SIZE(ptr_out, 3), 1)
END SUBROUTINE
SUBROUTINE Test_insert_dimension_i4_3_2_test4
INTEGER(i4), POINTER :: ptr_out(:, :, :)
INTEGER(i4), TARGET :: ptr_in(1, 1)
CALL insert_dimension(ptr_out, ptr_in, 2)
CALL TAG_TEST("Test_insert_dimension_i4_3_2_test4_first_dim")
CALL ASSERT_EQUAL(SIZE(ptr_out, 1), 1)
CALL TAG_TEST("Test_insert_dimension_i4_3_2_test4_second_dim")
CALL ASSERT_EQUAL(SIZE(ptr_out, 2), 1)
CALL TAG_TEST("Test_insert_dimension_i4_3_2_test4_third_dim")
CALL ASSERT_EQUAL(SIZE(ptr_out, 3), 1)
CALL insert_dimension(ptr_out, ptr_in, 1)
CALL TAG_TEST("Test_insert_dimension_i4_3_2_test4_first_dim2")
CALL ASSERT_EQUAL(SIZE(ptr_out, 1), 1)
CALL TAG_TEST("Test_insert_dimension_i4_3_2_test4_second_dim2")
CALL ASSERT_EQUAL(SIZE(ptr_out, 2), 1)
CALL TAG_TEST("Test_insert_dimension_i4_3_2_test4_third_dim2")
CALL ASSERT_EQUAL(SIZE(ptr_out, 3), 1)
END SUBROUTINE
SUBROUTINE Test_insert_dimension_i4_3_2_test5
INTEGER(i4), POINTER :: ptr_out(:, :, :)
INTEGER(i4), TARGET :: ptr_in(0, 0)
CALL insert_dimension(ptr_out, ptr_in, 2)
CALL TAG_TEST("Test_insert_dimension_i4_3_2_test5_first_dim")
CALL ASSERT_EQUAL(SIZE(ptr_out, 1), 0)
CALL TAG_TEST("Test_insert_dimension_i4_3_2_test5_second_dim")
CALL ASSERT_EQUAL(SIZE(ptr_out, 2), 1)
CALL TAG_TEST("Test_insert_dimension_i4_3_2_test5_third_dim")
CALL ASSERT_EQUAL(SIZE(ptr_out, 3), 0)
CALL insert_dimension(ptr_out, ptr_in, 1)
CALL TAG_TEST("Test_insert_dimension_i4_3_2_test5_first_dim2")
CALL ASSERT_EQUAL(SIZE(ptr_out, 1), 1)
CALL TAG_TEST("Test_insert_dimension_i4_3_2_test5_second_dim2")
CALL ASSERT_EQUAL(SIZE(ptr_out, 2), 0)
CALL TAG_TEST("Test_insert_dimension_i4_3_2_test5_third_dim2")
CALL ASSERT_EQUAL(SIZE(ptr_out, 3), 0)
END SUBROUTINE
SUBROUTINE Test_insert_dimension_l_3_2
LOGICAL, POINTER :: ptr_out(:, :, :)
LOGICAL, TARGET :: ptr_in(5, 10)
......@@ -830,6 +1134,106 @@ CONTAINS
CALL ASSERT_EQUAL(SIZE(ptr_out, 3), 10)
END SUBROUTINE
SUBROUTINE Test_insert_dimension_l_3_2_test2
LOGICAL, POINTER :: ptr_out(:, :, :)
LOGICAL, TARGET :: ptr_in(1, 10)
CALL insert_dimension(ptr_out, ptr_in, 2)
CALL TAG_TEST("Test_insert_dimension_l_3_2_test2_first_dim")
CALL ASSERT_EQUAL(SIZE(ptr_out, 1), 1)
CALL TAG_TEST("Test_insert_dimension_l_3_2_test2_second_dim")
CALL ASSERT_EQUAL(SIZE(ptr_out, 2), 1)
CALL TAG_TEST("Test_insert_dimension_l_3_2_test2_third_dim")
CALL ASSERT_EQUAL(SIZE(ptr_out, 3), 10)
CALL insert_dimension(ptr_out, ptr_in, 1)
CALL TAG_TEST("Test_insert_dimension_l_3_2_test2_first_dim2")
CALL ASSERT_EQUAL(SIZE(ptr_out, 1), 1)
CALL TAG_TEST("Test_insert_dimension_l_3_2_test2_second_dim2")
CALL ASSERT_EQUAL(SIZE(ptr_out, 2), 1)
CALL TAG_TEST("Test_insert_dimension_l_3_2_test2_third_dim2")
CALL ASSERT_EQUAL(SIZE(ptr_out, 3), 10)
END SUBROUTINE
SUBROUTINE Test_insert_dimension_l_3_2_test3
LOGICAL, POINTER :: ptr_out(:, :, :)
LOGICAL, TARGET :: ptr_in(5, 1)
CALL insert_dimension(ptr_out, ptr_in, 2)
CALL TAG_TEST("Test_insert_dimension_l_3_2_test3_first_dim")
CALL ASSERT_EQUAL(SIZE(ptr_out, 1), 5)
CALL TAG_TEST("Test_insert_dimension_l_3_2_test3_second_dim")
CALL ASSERT_EQUAL(SIZE(ptr_out, 2), 1)
CALL TAG_TEST("Test_insert_dimension_l_3_2_test3_third_dim")
CALL ASSERT_EQUAL(SIZE(ptr_out, 3), 1)
CALL insert_dimension(ptr_out, ptr_in, 1)
CALL TAG_TEST("Test_insert_dimension_l_3_2_test3_first_dim2")
CALL ASSERT_EQUAL(SIZE(ptr_out, 1), 1)
CALL TAG_TEST("Test_insert_dimension_l_3_2_test3_second_dim2")
CALL ASSERT_EQUAL(SIZE(ptr_out, 2), 5)
CALL TAG_TEST("Test_insert_dimension_l_3_2_test3_third_dim2")
CALL ASSERT_EQUAL(SIZE(ptr_out, 3), 1)
END SUBROUTINE
SUBROUTINE Test_insert_dimension_l_3_2_test4
LOGICAL, POINTER :: ptr_out(:, :, :)
LOGICAL, TARGET :: ptr_in(1, 1)
CALL insert_dimension(ptr_out, ptr_in, 2)
CALL TAG_TEST("Test_insert_dimension_l_3_2_test4_first_dim")
CALL ASSERT_EQUAL(SIZE(ptr_out, 1), 1)
CALL TAG_TEST("Test_insert_dimension_l_3_2_test4_second_dim")
CALL ASSERT_EQUAL(SIZE(ptr_out, 2), 1)
CALL TAG_TEST("Test_insert_dimension_l_3_2_test4_third_dim")
CALL ASSERT_EQUAL(SIZE(ptr_out, 3), 1)
CALL insert_dimension(ptr_out, ptr_in, 1)
CALL TAG_TEST("Test_insert_dimension_l_3_2_test4_first_dim2")
CALL ASSERT_EQUAL(SIZE(ptr_out, 1), 1)
CALL TAG_TEST("Test_insert_dimension_l_3_2_test4_second_dim2")
CALL ASSERT_EQUAL(SIZE(ptr_out, 2), 1)
CALL TAG_TEST("Test_insert_dimension_l_3_2_test4_third_dim2")
CALL ASSERT_EQUAL(SIZE(ptr_out, 3), 1)
END SUBROUTINE
SUBROUTINE Test_insert_dimension_l_3_2_test5
LOGICAL, POINTER :: ptr_out(:, :, :)
LOGICAL, TARGET :: ptr_in(0, 0)
CALL insert_dimension(ptr_out, ptr_in, 2)
CALL TAG_TEST("Test_insert_dimension_l_3_2_test5_first_dim")
CALL ASSERT_EQUAL(SIZE(ptr_out, 1), 0)
CALL TAG_TEST("Test_insert_dimension_l_3_2_test5_second_dim")
CALL ASSERT_EQUAL(SIZE(ptr_out, 2), 1)
CALL TAG_TEST("Test_insert_dimension_l_3_2_test5_third_dim")
CALL ASSERT_EQUAL(SIZE(ptr_out, 3), 0)
CALL insert_dimension(ptr_out, ptr_in, 1)
CALL TAG_TEST("Test_insert_dimension_l_3_2_test5_first_dim2")
CALL ASSERT_EQUAL(SIZE(ptr_out, 1), 1)
CALL TAG_TEST("Test_insert_dimension_l_3_2_test5_second_dim2")
CALL ASSERT_EQUAL(SIZE(ptr_out, 2), 0)
CALL TAG_TEST("Test_insert_dimension_l_3_2_test5_third_dim2")
CALL ASSERT_EQUAL(SIZE(ptr_out, 3), 0)
END SUBROUTINE
SUBROUTINE Test_insert_dimension_r_dp_6_5
REAL(dp), POINTER :: ptr_out(:, :, :, :, :, :)
REAL(dp), TARGET :: ptr_in(2, 3, 4, 5, 6)
......@@ -1072,6 +1476,43 @@ CONTAINS
CALL ASSERT_EQUAL(ASSOCIATED(ptr), .FALSE.)
END SUBROUTINE
SUBROUTINE Test_assert_acc_host_only
! OpenACC version is left TODO
CALL TAG_TEST("Test_assert_acc_host_only_true")
CALL assert_acc_host_only("Unit_test", .TRUE.)
CALL SUCCEED
CALL TAG_TEST("Test_assert_acc_host_only_false")
CALL assert_acc_host_only("Unit_test", .FALSE.)
CALL SUCCEED
END SUBROUTINE
SUBROUTINE Test_assert_acc_device_only
! OpenACC version is left TODO
CALL TAG_TEST("Test_assert_acc_device_only_true")
CALL assert_acc_device_only("Unit_test", .TRUE.)
CALL SUCCEED
CALL TAG_TEST("Test_assert_acc_device_only_false")
CALL assert_acc_device_only("Unit_test", .FALSE.)
CALL SUCCEED
END SUBROUTINE
SUBROUTINE Test_assert_lacc_equals_i_am_accel_node
! OpenACC version is left TODO
CALL TAG_TEST("Test_assert_lacc_equals_i_am_accel_node_match_true")
CALL assert_lacc_equals_i_am_accel_node("Unit_test", .TRUE., .TRUE.)
CALL SUCCEED
CALL TAG_TEST("Test_assert_lacc_equals_i_am_accel_node_match_false")
CALL assert_lacc_equals_i_am_accel_node("Unit_test", .FALSE., .FALSE.)
CALL SUCCEED
CALL TAG_TEST("Test_assert_lacc_equals_i_am_accel_node_false")
CALL assert_lacc_equals_i_am_accel_node("Unit_test", .FALSE., .TRUE.)
CALL SUCCEED
END SUBROUTINE
! Support functions for testing
LOGICAL FUNCTION assert_logical_array(array1, array2)
......