From 63da3270a60b69a88ed363ac14fe001c07844c7b Mon Sep 17 00:00:00 2001 From: The-Lum <86879521+The-Lum@users.noreply.github.com> Date: Thu, 27 Jul 2023 15:41:03 +0000 Subject: [PATCH] test: add tests for the builtin function `%chr` _[TODO: fix `%chr` to allow Unicode chars, the corresponding tests are here.]_ --- .../plantuml/tim/stdlib/ChrTest.java | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 test/net/sourceforge/plantuml/tim/stdlib/ChrTest.java diff --git a/test/net/sourceforge/plantuml/tim/stdlib/ChrTest.java b/test/net/sourceforge/plantuml/tim/stdlib/ChrTest.java new file mode 100644 index 000000000..cf3886aaa --- /dev/null +++ b/test/net/sourceforge/plantuml/tim/stdlib/ChrTest.java @@ -0,0 +1,46 @@ +package net.sourceforge.plantuml.tim.stdlib; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import java.util.Collections; +import java.util.List; + +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.CsvSource; + +import net.sourceforge.plantuml.tim.EaterException; +import net.sourceforge.plantuml.tim.EaterExceptionLocated; +import net.sourceforge.plantuml.tim.expression.TValue; + +/** + * Tests the builtin function %chr. + */ +class ChrTest { + + /** + * Tests chr according to a list of input / expected output + * + * @throws EaterException should not + * @throws EaterExceptionLocated should not + */ + @ParameterizedTest + @CsvSource(nullValues = "null", value = { + " 65 , A ", + " 9 , '\t' ", + " 32 , ' ' ", + " 33 , '!' ", + " 34 , '\"' ", + " 224 , à ", + " 233 , é ", +// TODO: fix `%chr` to allow Unicode chars, the corresponding tests are here: +// " 128512 , 😀 ", +// " 128512 , \uD83D\uDE00 ", + }) + void executeReturnFunctionChrTest(Integer input, String expected) throws EaterException, EaterExceptionLocated { + Chr cut = new Chr(); + + List values = Collections.singletonList(TValue.fromInt(input)); + TValue tValue = cut.executeReturnFunction(null, null, null, values, null); + assertEquals(expected, tValue.toString()); + } +} \ No newline at end of file