Commit 720a9cd1 authored by Oriol Tintó-Prims's avatar Oriol Tintó-Prims
Browse files

New tests for replace_variable_exact_match.

parent 319b690f
......@@ -62,7 +62,7 @@ class TestFunctionMethods(unittest.TestCase):
def test_dimension_of_contents_1(self):
from AutoRPE.UtilsRPE.Functions import dimension_of_contents
self.assertEqual(dimension_of_contents("1.0"),0)
self.assertEqual(dimension_of_contents("1.0"), 0)
def test_dimension_of_contents_2(self):
from AutoRPE.UtilsRPE.Functions import dimension_of_contents
......@@ -109,6 +109,32 @@ class TestFunctionMethods(unittest.TestCase):
for case, answer in cases:
self.assertEqual(dimension_of_contents(case), answer)
def test_replace_variable_exact_match(self):
from AutoRPE.UtilsRPE.Functions import replace_variable_exact_match
# This is the line of code from NEMO
fun_in = "znam = 'sye'//'_l'//zchar1 ; z3d(:,:,:) = sye (:,:,jk,:) ; CALL iom_rstput( iter, nitrst, numriw, znam , z3d )"
# This is the argument that we want to replace and its replacement
piece_to_replace = "z3d"
replacement = "REAL(z3d, dp)"
# This is what the function actually gives
fun_out = replace_variable_exact_match(piece_to_replace, replacement, fun_in)
# This is what it should give
solution = "znam = 'sye'//'_l'//zchar1 ; z3d(:,:,:) = sye (:,:,jk,:) ; CALL iom_rstput( iter, nitrst, numriw, znam , REAL(z3d, dp) )"
self.assertEqual(fun_out, solution)
def test_replace_variable_exact_match_2(self):
from AutoRPE.UtilsRPE.Functions import replace_variable_exact_match
# This is the line of code from NEMO
fun_in = "CALL iom_rstput( iter, nitrst, numriw, 'sxice' , sxice )"
# This is the argument that we want to replace and its replacement
piece_to_replace = "sxice"
replacement = "REAL(sxice, dp)"
# This is what the function actually gives
fun_out = replace_variable_exact_match(piece_to_replace, replacement, fun_in)
# This is what it should give
solution = "CALL iom_rstput( iter, nitrst, numriw, 'sxice' , REAL(sxice, dp) )"
self.assertEqual(fun_out, solution)
if __name__ == '__main__':
unittest.main()
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment