Skip to content

Commit 54c94bb

Browse files
committed
EAMxx: add testing for field operations that involves fill values
1 parent 7e6187f commit 54c94bb

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

components/eamxx/src/share/tests/field_tests.cpp

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -887,6 +887,13 @@ TEST_CASE ("update") {
887887
Field f4 = two.clone();
888888
f4.min(f3);
889889
REQUIRE (views_are_equal(f3, f4));
890+
891+
// Check that updating with rhs==fill_value ignores the rhs
892+
f3.deep_copy(constants::fill_value<Real>);
893+
f3.get_header().set_extra_data("mask_value",constants::fill_value<Real>);
894+
f2.deep_copy(1.0);
895+
f2.max(f3);
896+
REQUIRE (views_are_equal(f2,one));
890897
}
891898

892899
SECTION ("int") {
@@ -904,6 +911,13 @@ TEST_CASE ("update") {
904911
Field f4 = two.clone();
905912
f4.min(f3);
906913
REQUIRE (views_are_equal(f3, f4));
914+
915+
// Check that updating with rhs==fill_value ignores the rhs
916+
f3.deep_copy(constants::fill_value<int>);
917+
f3.get_header().set_extra_data("mask_value",constants::fill_value<int>);
918+
f2.deep_copy(1);
919+
f2.max(f3);
920+
REQUIRE (views_are_equal(f2,one));
907921
}
908922
}
909923

@@ -949,6 +963,19 @@ TEST_CASE ("update") {
949963
// Same, but we discard current content of f3
950964
f3.update(f_real,2,0);
951965
REQUIRE (views_are_equal(f3,f2));
966+
967+
// Check that updating with rhs==fill_value ignores the rhs
968+
Field one = f_real.clone();
969+
one.deep_copy(1.0);
970+
971+
f3.deep_copy(constants::fill_value<Real>);
972+
f3.get_header().set_extra_data("mask_value",constants::fill_value<Real>);
973+
f2.deep_copy(1.0);
974+
f2.update(f3,1,1);
975+
if (not views_are_equal(f2,one)) {
976+
print_field_hyperslab(f2);
977+
}
978+
REQUIRE (views_are_equal(f2,one));
952979
}
953980

954981
SECTION ("int") {
@@ -969,6 +996,15 @@ TEST_CASE ("update") {
969996
f3.update(f_int,2,0);
970997
REQUIRE (views_are_equal(f3,f2));
971998

999+
// Check that updating with rhs==fill_value ignores the rhs
1000+
Field one = f_int.clone();
1001+
one.deep_copy(1);
1002+
1003+
f3.deep_copy(constants::fill_value<int>);
1004+
f3.get_header().set_extra_data("mask_value",constants::fill_value<int>);
1005+
f2.deep_copy(1);
1006+
f2.update(f3,1,1);
1007+
REQUIRE (views_are_equal(f2,one));
9721008
}
9731009
}
9741010
}

0 commit comments

Comments
 (0)