mirror of
https://github.com/octoleo/plantuml.git
synced 2024-12-22 10:59:01 +00:00
test: first commit for some unit tests of tim/stdlib
functions
- `AlwaysFalse` - `AlwaysTrue` - `Dec2hex` - `Feature` - `GetJsonKey` - `GetJsonType` - `Hex2dec` - `Lower` - `Size` - `Upper` - TBC...
This commit is contained in:
parent
957726fda0
commit
f91e0db9eb
@ -0,0 +1,50 @@
|
||||
package net.sourceforge.plantuml.tim.stdlib;
|
||||
|
||||
import static net.sourceforge.plantuml.tim.TimTestUtils.assertTimExpectedOutput;
|
||||
import static net.sourceforge.plantuml.tim.TimTestUtils.assertTimExpectedOutputFromInput;
|
||||
|
||||
import org.junit.jupiter.api.DisplayNameGenerator.ReplaceUnderscores;
|
||||
import org.junit.jupiter.api.IndicativeSentencesGeneration;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.params.converter.ConvertWith;
|
||||
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.TFunction;
|
||||
|
||||
/**
|
||||
* Tests the builtin function.
|
||||
*/
|
||||
@IndicativeSentencesGeneration(separator = ": ", generator = ReplaceUnderscores.class)
|
||||
|
||||
class AlwaysFalseTest {
|
||||
TFunction cut = new AlwaysFalse();
|
||||
final String cutName = "AlwaysFalse";
|
||||
|
||||
@Test
|
||||
void Test_without_Param() throws EaterException, EaterExceptionLocated {
|
||||
assertTimExpectedOutput(cut, "0");
|
||||
}
|
||||
|
||||
@ParameterizedTest(name = "[{index}] " + cutName + "(''{0}'') = {1}")
|
||||
@CsvSource(nullValues = "null", value = {
|
||||
" 0 , 0 ",
|
||||
" 1 , 0 ",
|
||||
" 'a' , 0 ",
|
||||
})
|
||||
void Test_with_String(String input, String expected) throws EaterException, EaterExceptionLocated {
|
||||
assertTimExpectedOutputFromInput(cut, input, expected);
|
||||
}
|
||||
|
||||
@ParameterizedTest(name = "[{index}] " + cutName + "({0}) = {1}")
|
||||
@CsvSource(nullValues = "null", value = {
|
||||
" 0 , 0 ",
|
||||
" 1 , 0 ",
|
||||
" 123 , 0 ",
|
||||
})
|
||||
void Test_with_Integer(Integer input, String expected) throws EaterException, EaterExceptionLocated {
|
||||
assertTimExpectedOutputFromInput(cut, input, expected);
|
||||
}
|
||||
}
|
50
test/net/sourceforge/plantuml/tim/stdlib/AlwaysTrueTest.java
Normal file
50
test/net/sourceforge/plantuml/tim/stdlib/AlwaysTrueTest.java
Normal file
@ -0,0 +1,50 @@
|
||||
package net.sourceforge.plantuml.tim.stdlib;
|
||||
|
||||
import static net.sourceforge.plantuml.tim.TimTestUtils.assertTimExpectedOutput;
|
||||
import static net.sourceforge.plantuml.tim.TimTestUtils.assertTimExpectedOutputFromInput;
|
||||
|
||||
import org.junit.jupiter.api.DisplayNameGenerator.ReplaceUnderscores;
|
||||
import org.junit.jupiter.api.IndicativeSentencesGeneration;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.params.converter.ConvertWith;
|
||||
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.TFunction;
|
||||
|
||||
/**
|
||||
* Tests the builtin function.
|
||||
*/
|
||||
@IndicativeSentencesGeneration(separator = ": ", generator = ReplaceUnderscores.class)
|
||||
|
||||
class AlwaysTrueTest {
|
||||
TFunction cut = new AlwaysTrue();
|
||||
final String cutName = "AlwaysTrue";
|
||||
|
||||
@Test
|
||||
void Test_without_Param() throws EaterException, EaterExceptionLocated {
|
||||
assertTimExpectedOutput(cut, "1");
|
||||
}
|
||||
|
||||
@ParameterizedTest(name = "[{index}] " + cutName + "(''{0}'') = {1}")
|
||||
@CsvSource(nullValues = "null", value = {
|
||||
" 0 , 1 ",
|
||||
" 1 , 1 ",
|
||||
" 'a' , 1 ",
|
||||
})
|
||||
void Test_with_String(String input, String expected) throws EaterException, EaterExceptionLocated {
|
||||
assertTimExpectedOutputFromInput(cut, input, expected);
|
||||
}
|
||||
|
||||
@ParameterizedTest(name = "[{index}] " + cutName + "({0}) = {1}")
|
||||
@CsvSource(nullValues = "null", value = {
|
||||
" 0 , 1 ",
|
||||
" 1 , 1 ",
|
||||
" 123 , 1 ",
|
||||
})
|
||||
void Test_with_Integer(Integer input, String expected) throws EaterException, EaterExceptionLocated {
|
||||
assertTimExpectedOutputFromInput(cut, input, expected);
|
||||
}
|
||||
}
|
58
test/net/sourceforge/plantuml/tim/stdlib/Dec2hexTest.java
Normal file
58
test/net/sourceforge/plantuml/tim/stdlib/Dec2hexTest.java
Normal file
@ -0,0 +1,58 @@
|
||||
package net.sourceforge.plantuml.tim.stdlib;
|
||||
|
||||
import static net.sourceforge.plantuml.tim.TimTestUtils.assertTimExpectedOutput;
|
||||
import static net.sourceforge.plantuml.tim.TimTestUtils.assertTimExpectedOutputFromInput;
|
||||
|
||||
import org.junit.jupiter.api.DisplayNameGenerator.ReplaceUnderscores;
|
||||
import org.junit.jupiter.api.IndicativeSentencesGeneration;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.params.converter.ConvertWith;
|
||||
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.TFunction;
|
||||
|
||||
/**
|
||||
* Tests the builtin function.
|
||||
*/
|
||||
@IndicativeSentencesGeneration(separator = ": ", generator = ReplaceUnderscores.class)
|
||||
|
||||
class Dec2hexTest {
|
||||
TFunction cut = new Dec2hex();
|
||||
final String cutName = "Dec2hex";
|
||||
|
||||
@Test
|
||||
void Test_without_Param() throws EaterException, EaterExceptionLocated {
|
||||
assertTimExpectedOutput(cut, "");
|
||||
}
|
||||
|
||||
@ParameterizedTest(name = "[{index}] " + cutName + "(''{0}'') = {1}")
|
||||
@CsvSource(nullValues = "null", value = {
|
||||
" 0 , 0 ",
|
||||
" 1 , 0 ",
|
||||
" 10 , 0 ",
|
||||
" 15 , 0 ",
|
||||
" 16 , 0 ",
|
||||
" 255 , 0 ",
|
||||
" 65535 , 0 ",
|
||||
})
|
||||
void Test_with_String(String input, String expected) throws EaterException, EaterExceptionLocated {
|
||||
assertTimExpectedOutputFromInput(cut, input, expected);
|
||||
}
|
||||
|
||||
@ParameterizedTest(name = "[{index}] " + cutName + "({0}) = {1}")
|
||||
@CsvSource(nullValues = "null", value = {
|
||||
" 0 , 0 ",
|
||||
" 1 , 1 ",
|
||||
" 10 , a ",
|
||||
" 15 , f ",
|
||||
" 16 , 10 ",
|
||||
" 255 , ff ",
|
||||
" 65535 , ffff ",
|
||||
})
|
||||
void Test_with_Integer(Integer input, String expected) throws EaterException, EaterExceptionLocated {
|
||||
assertTimExpectedOutputFromInput(cut, input, expected);
|
||||
}
|
||||
}
|
68
test/net/sourceforge/plantuml/tim/stdlib/FeatureTest.java
Normal file
68
test/net/sourceforge/plantuml/tim/stdlib/FeatureTest.java
Normal file
@ -0,0 +1,68 @@
|
||||
package net.sourceforge.plantuml.tim.stdlib;
|
||||
|
||||
import static net.sourceforge.plantuml.test.JunitUtils.StringJsonConverter;
|
||||
import static net.sourceforge.plantuml.tim.TimTestUtils.assertTimExpectedOutput;
|
||||
import static net.sourceforge.plantuml.tim.TimTestUtils.assertTimExpectedOutputFromInput;
|
||||
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.DisplayNameGenerator.ReplaceUnderscores;
|
||||
import org.junit.jupiter.api.IndicativeSentencesGeneration;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.params.converter.ConvertWith;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.CsvSource;
|
||||
|
||||
import net.sourceforge.plantuml.json.JsonValue;
|
||||
import net.sourceforge.plantuml.tim.EaterException;
|
||||
import net.sourceforge.plantuml.tim.EaterExceptionLocated;
|
||||
import net.sourceforge.plantuml.tim.TFunction;
|
||||
|
||||
/**
|
||||
* Tests the builtin function.
|
||||
*/
|
||||
@IndicativeSentencesGeneration(separator = ": ", generator = ReplaceUnderscores.class)
|
||||
|
||||
class FeatureTest {
|
||||
TFunction cut = new Feature();
|
||||
final String cutName = "Feature";
|
||||
|
||||
@Disabled
|
||||
@Test
|
||||
void Test_without_Param() throws EaterException, EaterExceptionLocated {
|
||||
assertTimExpectedOutput(cut, "0");
|
||||
}
|
||||
|
||||
@ParameterizedTest(name = "[{index}] " + cutName + "(''{0}'') = {1}")
|
||||
@CsvSource(nullValues = "null", value = {
|
||||
" style, 1",
|
||||
" theme, 1",
|
||||
" Style, 1",
|
||||
" Theme, 1",
|
||||
" 0 , 0",
|
||||
" 1 , 0",
|
||||
" abc , 0",
|
||||
|
||||
})
|
||||
void Test_with_String(String input, String expected) throws EaterException, EaterExceptionLocated {
|
||||
assertTimExpectedOutputFromInput(cut, input, expected);
|
||||
}
|
||||
|
||||
@ParameterizedTest(name = "[{index}] " + cutName + "({0}) = {1}")
|
||||
@CsvSource(nullValues = "null", value = {
|
||||
" 0, 0",
|
||||
" 10, 0",
|
||||
})
|
||||
void Test_with_Integer(Integer input, String expected) throws EaterException, EaterExceptionLocated {
|
||||
assertTimExpectedOutputFromInput(cut, input, expected);
|
||||
}
|
||||
|
||||
@ParameterizedTest(name = "[{index}] " + cutName + "({0}) = {1}")
|
||||
@CsvSource(value = {
|
||||
" \"style\", 1",
|
||||
" \"theme\", 1",
|
||||
" 0, 0",
|
||||
})
|
||||
void Test_with_Json(@ConvertWith(StringJsonConverter.class) JsonValue input, String expected) throws EaterException, EaterExceptionLocated {
|
||||
assertTimExpectedOutputFromInput(cut, input, expected);
|
||||
}
|
||||
}
|
73
test/net/sourceforge/plantuml/tim/stdlib/GetJsonKeyTest.java
Normal file
73
test/net/sourceforge/plantuml/tim/stdlib/GetJsonKeyTest.java
Normal file
@ -0,0 +1,73 @@
|
||||
package net.sourceforge.plantuml.tim.stdlib;
|
||||
|
||||
import static net.sourceforge.plantuml.test.JunitUtils.StringJsonConverter;
|
||||
import static net.sourceforge.plantuml.tim.TimTestUtils.assertTimExpectedOutput;
|
||||
import static net.sourceforge.plantuml.tim.TimTestUtils.assertTimExpectedOutputFromInput;
|
||||
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.DisplayNameGenerator.ReplaceUnderscores;
|
||||
import org.junit.jupiter.api.IndicativeSentencesGeneration;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.params.converter.ConvertWith;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.CsvSource;
|
||||
|
||||
import net.sourceforge.plantuml.json.JsonValue;
|
||||
import net.sourceforge.plantuml.tim.EaterException;
|
||||
import net.sourceforge.plantuml.tim.EaterExceptionLocated;
|
||||
import net.sourceforge.plantuml.tim.TFunction;
|
||||
|
||||
/**
|
||||
* Tests the builtin function.
|
||||
*/
|
||||
@IndicativeSentencesGeneration(separator = ": ", generator = ReplaceUnderscores.class)
|
||||
|
||||
class GetJsonKeyTest {
|
||||
TFunction cut = new GetJsonKey();
|
||||
final String cutName = "GetJsonKey";
|
||||
|
||||
@Disabled
|
||||
@Test
|
||||
void Test_without_Param() throws EaterException, EaterExceptionLocated {
|
||||
assertTimExpectedOutput(cut, "0");
|
||||
}
|
||||
|
||||
@Disabled // EaterException: Not JSON data
|
||||
@ParameterizedTest(name = "[{index}] " + cutName + "(''{0}'') = {1}")
|
||||
@CsvSource(nullValues = "null", value = {
|
||||
" 0, Not JSON data",
|
||||
" a, Not JSON data",
|
||||
" -1, Not JSON data",
|
||||
})
|
||||
void Test_with_String(String input, String expected) throws EaterException, EaterExceptionLocated {
|
||||
assertTimExpectedOutputFromInput(cut, input, expected);
|
||||
}
|
||||
|
||||
@Disabled // EaterException: Not JSON data
|
||||
@ParameterizedTest(name = "[{index}] " + cutName + "({0}) = {1}")
|
||||
@CsvSource(nullValues = "null", value = {
|
||||
" 0, Not JSON data",
|
||||
" -1, Not JSON data",
|
||||
})
|
||||
void Test_with_Integer(Integer input, String expected) throws EaterException, EaterExceptionLocated {
|
||||
assertTimExpectedOutputFromInput(cut, input, expected);
|
||||
}
|
||||
|
||||
@ParameterizedTest(name = "[{index}] " + cutName + "({0}) = {1}")
|
||||
@CsvSource(value = {
|
||||
" [] , []",
|
||||
" '{\"a\":[1, 2]}' , [\"a\"]",
|
||||
" '[{\"a\":[1, 2]}]' , [\"a\"]",
|
||||
" '{\"a\":\"abc\"}' , [\"a\"]",
|
||||
" '[{\"a\":[1, 2]}, {\"b\":[3, 4]}]' , '[\"a\",\"b\"]'",
|
||||
" '{\"a\":[1, 2], \"b\":\"abc\", \"b\":true}' , '[\"a\",\"b\",\"b\"]'",
|
||||
// TODO: Manage Array with different type inside
|
||||
// Ref.:
|
||||
// - https://datatracker.ietf.org/doc/html/rfc8259#section-5
|
||||
// - https://json-schema.org/understanding-json-schema/reference/array.html
|
||||
//" '[3, \"different\", { \"types\" : \"of values\" }]', [\"types\"]",
|
||||
})
|
||||
void Test_with_Json(@ConvertWith(StringJsonConverter.class) JsonValue input, String expected) throws EaterException, EaterExceptionLocated {
|
||||
assertTimExpectedOutputFromInput(cut, input, expected);
|
||||
}
|
||||
}
|
@ -0,0 +1,73 @@
|
||||
package net.sourceforge.plantuml.tim.stdlib;
|
||||
|
||||
import static net.sourceforge.plantuml.test.JunitUtils.StringJsonConverter;
|
||||
import static net.sourceforge.plantuml.tim.TimTestUtils.assertTimExpectedOutput;
|
||||
import static net.sourceforge.plantuml.tim.TimTestUtils.assertTimExpectedOutputFromInput;
|
||||
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.DisplayNameGenerator.ReplaceUnderscores;
|
||||
import org.junit.jupiter.api.IndicativeSentencesGeneration;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.params.converter.ConvertWith;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.CsvSource;
|
||||
|
||||
import net.sourceforge.plantuml.json.JsonValue;
|
||||
import net.sourceforge.plantuml.tim.EaterException;
|
||||
import net.sourceforge.plantuml.tim.EaterExceptionLocated;
|
||||
import net.sourceforge.plantuml.tim.TFunction;
|
||||
|
||||
/**
|
||||
* Tests the builtin function.
|
||||
*/
|
||||
@IndicativeSentencesGeneration(separator = ": ", generator = ReplaceUnderscores.class)
|
||||
|
||||
class GetJsonTypeTest {
|
||||
TFunction cut = new GetJsonType();
|
||||
final String cutName = "GetJsonType";
|
||||
|
||||
@Disabled
|
||||
@Test
|
||||
void Test_without_Param() throws EaterException, EaterExceptionLocated {
|
||||
assertTimExpectedOutput(cut, "0");
|
||||
}
|
||||
|
||||
@ParameterizedTest(name = "[{index}] " + cutName + "(''{0}'') = {1}")
|
||||
@CsvSource(nullValues = "null", value = {
|
||||
" 0, string",
|
||||
" a, string",
|
||||
" -1, string",
|
||||
})
|
||||
void Test_with_String(String input, String expected) throws EaterException, EaterExceptionLocated {
|
||||
assertTimExpectedOutputFromInput(cut, input, expected);
|
||||
}
|
||||
|
||||
@ParameterizedTest(name = "[{index}] " + cutName + "({0}) = {1}")
|
||||
@CsvSource(nullValues = "null", value = {
|
||||
" 0, number",
|
||||
" -1, number",
|
||||
})
|
||||
void Test_with_Integer(Integer input, String expected) throws EaterException, EaterExceptionLocated {
|
||||
assertTimExpectedOutputFromInput(cut, input, expected);
|
||||
}
|
||||
|
||||
@ParameterizedTest(name = "[{index}] " + cutName + "({0}) = {1}")
|
||||
@CsvSource(value = {
|
||||
" 0 , number",
|
||||
" 123 , number",
|
||||
" \"abc\" , string",
|
||||
" \"string\" , string",
|
||||
" '[1, 2]' , array",
|
||||
" '[\"a\", \"b\"]' , array",
|
||||
" '{\"a\":[1, 2]}' , object",
|
||||
" '{\"a\":\"abc\"}' , object",
|
||||
" true , boolean ",
|
||||
" false , boolean ",
|
||||
" 1 , number ",
|
||||
" null , json ",
|
||||
" '{\"a\":[1, 2], \"b\":\"abc\", \"b\":true}' , object",
|
||||
})
|
||||
void Test_with_Json(@ConvertWith(StringJsonConverter.class) JsonValue input, String expected) throws EaterException, EaterExceptionLocated {
|
||||
assertTimExpectedOutputFromInput(cut, input, expected);
|
||||
}
|
||||
}
|
61
test/net/sourceforge/plantuml/tim/stdlib/Hex2decTest.java
Normal file
61
test/net/sourceforge/plantuml/tim/stdlib/Hex2decTest.java
Normal file
@ -0,0 +1,61 @@
|
||||
package net.sourceforge.plantuml.tim.stdlib;
|
||||
|
||||
import static net.sourceforge.plantuml.tim.TimTestUtils.assertTimExpectedOutput;
|
||||
import static net.sourceforge.plantuml.tim.TimTestUtils.assertTimExpectedOutputFromInput;
|
||||
|
||||
import org.junit.jupiter.api.DisplayNameGenerator.ReplaceUnderscores;
|
||||
import org.junit.jupiter.api.IndicativeSentencesGeneration;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.params.converter.ConvertWith;
|
||||
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.TFunction;
|
||||
|
||||
/**
|
||||
* Tests the builtin function.
|
||||
*/
|
||||
@IndicativeSentencesGeneration(separator = ": ", generator = ReplaceUnderscores.class)
|
||||
|
||||
class Hex2decTest {
|
||||
TFunction cut = new Hex2dec();
|
||||
final String cutName = "Hex2dec";
|
||||
|
||||
@Test
|
||||
void Test_without_Param() throws EaterException, EaterExceptionLocated {
|
||||
assertTimExpectedOutput(cut, "0");
|
||||
}
|
||||
|
||||
@ParameterizedTest(name = "[{index}] " + cutName + "(''{0}'') = {1}")
|
||||
@CsvSource(nullValues = "null", value = {
|
||||
" 0 , 0 ",
|
||||
" 1 , 1 ",
|
||||
" a , 10 ",
|
||||
" f , 15 ",
|
||||
" 10 , 16 ",
|
||||
" ff , 255 ",
|
||||
" ffff , 65535 ",
|
||||
" ' ' , 0 ",
|
||||
" g , 0 ",
|
||||
" -g , 0 ",
|
||||
" à , 0 ",
|
||||
" -1 , -1 ",
|
||||
" -a , -10 ",
|
||||
})
|
||||
void Test_with_String(String input, String expected) throws EaterException, EaterExceptionLocated {
|
||||
assertTimExpectedOutputFromInput(cut, input, expected);
|
||||
}
|
||||
|
||||
@ParameterizedTest(name = "[{index}] " + cutName + "({0}) = {1}")
|
||||
@CsvSource(nullValues = "null", value = {
|
||||
" 0 , 0 ",
|
||||
" 1 , 1 ",
|
||||
" 10 , 16 ",
|
||||
" -1 , -1 ",
|
||||
})
|
||||
void Test_with_Integer(Integer input, String expected) throws EaterException, EaterExceptionLocated {
|
||||
assertTimExpectedOutputFromInput(cut, input, expected);
|
||||
}
|
||||
}
|
76
test/net/sourceforge/plantuml/tim/stdlib/LowerTest.java
Normal file
76
test/net/sourceforge/plantuml/tim/stdlib/LowerTest.java
Normal file
@ -0,0 +1,76 @@
|
||||
package net.sourceforge.plantuml.tim.stdlib;
|
||||
|
||||
import static net.sourceforge.plantuml.test.JunitUtils.StringJsonConverter;
|
||||
import static net.sourceforge.plantuml.tim.TimTestUtils.assertTimExpectedOutput;
|
||||
import static net.sourceforge.plantuml.tim.TimTestUtils.assertTimExpectedOutputFromInput;
|
||||
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.DisplayNameGenerator.ReplaceUnderscores;
|
||||
import org.junit.jupiter.api.IndicativeSentencesGeneration;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.params.converter.ConvertWith;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.CsvSource;
|
||||
|
||||
import net.sourceforge.plantuml.json.JsonValue;
|
||||
import net.sourceforge.plantuml.tim.EaterException;
|
||||
import net.sourceforge.plantuml.tim.EaterExceptionLocated;
|
||||
import net.sourceforge.plantuml.tim.TFunction;
|
||||
|
||||
/**
|
||||
* Tests the builtin function.
|
||||
*/
|
||||
@IndicativeSentencesGeneration(separator = ": ", generator = ReplaceUnderscores.class)
|
||||
|
||||
class LowerTest {
|
||||
TFunction cut = new Lower();
|
||||
final String cutName = "Lower";
|
||||
|
||||
// TODO: Manage Lower function without param. (today: we observe `Function not found %lower`)
|
||||
@Disabled
|
||||
@Test
|
||||
void Test_without_Param() throws EaterException, EaterExceptionLocated {
|
||||
assertTimExpectedOutput(cut, "");
|
||||
}
|
||||
|
||||
@ParameterizedTest(name = "[{index}] " + cutName + "(''{0}'') = {1}")
|
||||
@CsvSource(nullValues = "null", value = {
|
||||
" 0 , 0 ",
|
||||
" 1 , 1 ",
|
||||
" A , a ",
|
||||
" a , a ",
|
||||
" F , f ",
|
||||
" G , g ",
|
||||
" É , é ",
|
||||
" 😀 , 😀 ",
|
||||
})
|
||||
void Test_with_String(String input, String expected) throws EaterException, EaterExceptionLocated {
|
||||
assertTimExpectedOutputFromInput(cut, input, expected);
|
||||
}
|
||||
|
||||
@ParameterizedTest(name = "[{index}] " + cutName + "({0}) = {1}")
|
||||
@CsvSource(nullValues = "null", value = {
|
||||
" 0 , 0 ",
|
||||
" 1 , 1 ",
|
||||
" 10 , 10 ",
|
||||
" -1 , -1 ",
|
||||
})
|
||||
void Test_with_Integer(Integer input, String expected) throws EaterException, EaterExceptionLocated {
|
||||
assertTimExpectedOutputFromInput(cut, input, expected);
|
||||
}
|
||||
|
||||
@ParameterizedTest(name = "[{index}] " + cutName + "({0}) = {1}")
|
||||
@CsvSource(value = {
|
||||
" '{\"a\":[1, 2]}' , '{\"a\":[1,2]}'",
|
||||
" '{\"A\":[1, 2]}' , '{\"a\":[1,2]}'",
|
||||
" '[1, 2]' , '[1,2]'",
|
||||
" '{\"a\":[1, 2], \"b\":\"abc\", \"b\":true}' , '{\"a\":[1,2],\"b\":\"abc\",\"b\":true}'",
|
||||
" '{\"A\":[1, 2], \"B\":\"ABC\", \"B\":true}' , '{\"a\":[1,2],\"b\":\"abc\",\"b\":true}' ",
|
||||
" true, true"
|
||||
// TODO: See JSON management of TRUE/FALSE
|
||||
//" TRUE , true ",
|
||||
})
|
||||
void Test_with_Json(@ConvertWith(StringJsonConverter.class) JsonValue input, String expected) throws EaterException, EaterExceptionLocated {
|
||||
assertTimExpectedOutputFromInput(cut, input, expected);
|
||||
}
|
||||
}
|
81
test/net/sourceforge/plantuml/tim/stdlib/SizeTest.java
Normal file
81
test/net/sourceforge/plantuml/tim/stdlib/SizeTest.java
Normal file
@ -0,0 +1,81 @@
|
||||
package net.sourceforge.plantuml.tim.stdlib;
|
||||
|
||||
import static net.sourceforge.plantuml.test.JunitUtils.StringJsonConverter;
|
||||
import static net.sourceforge.plantuml.tim.TimTestUtils.assertTimExpectedOutput;
|
||||
import static net.sourceforge.plantuml.tim.TimTestUtils.assertTimExpectedOutputFromInput;
|
||||
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.DisplayNameGenerator.ReplaceUnderscores;
|
||||
import org.junit.jupiter.api.IndicativeSentencesGeneration;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.params.converter.ConvertWith;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.CsvSource;
|
||||
|
||||
import net.sourceforge.plantuml.json.JsonValue;
|
||||
import net.sourceforge.plantuml.tim.EaterException;
|
||||
import net.sourceforge.plantuml.tim.EaterExceptionLocated;
|
||||
import net.sourceforge.plantuml.tim.TFunction;
|
||||
|
||||
/**
|
||||
* Tests the builtin function.
|
||||
*/
|
||||
@IndicativeSentencesGeneration(separator = ": ", generator = ReplaceUnderscores.class)
|
||||
|
||||
class SizeTest {
|
||||
TFunction cut = new Size();
|
||||
final String cutName = "Size";
|
||||
|
||||
// TODO: Manage `Size` function without param. (today: we observe `Function not found`)
|
||||
@Disabled
|
||||
@Test
|
||||
void Test_without_Param() throws EaterException, EaterExceptionLocated {
|
||||
assertTimExpectedOutput(cut, "0");
|
||||
}
|
||||
|
||||
@ParameterizedTest(name = "[{index}] " + cutName + "(''{0}'') = {1}")
|
||||
@CsvSource(nullValues = "null", value = {
|
||||
" 0 , 1 ",
|
||||
" 1 , 1 ",
|
||||
" 10 , 2 ",
|
||||
" a , 1 ",
|
||||
" A , 1 ",
|
||||
" ABC , 3 ",
|
||||
" '[1, 2]' , 6 ",
|
||||
" '{[1, 2]}' , 8 ",
|
||||
" à , 1 ",
|
||||
// TODO: fix `Size` to allow Unicode chars, the corresponding tests are here:
|
||||
// " 😀 , 1 ",
|
||||
// " \uD83D\uDE00 , 1",
|
||||
})
|
||||
void Test_with_String(String input, String expected) throws EaterException, EaterExceptionLocated {
|
||||
assertTimExpectedOutputFromInput(cut, input, expected);
|
||||
}
|
||||
|
||||
@ParameterizedTest(name = "[{index}] " + cutName + "({0}) = {1}")
|
||||
@CsvSource(nullValues = "null", value = {
|
||||
" 0 , 0 ",
|
||||
" 1 , 0 ",
|
||||
" 10 , 0 ",
|
||||
})
|
||||
void Test_with_Integer(Integer input, String expected) throws EaterException, EaterExceptionLocated {
|
||||
assertTimExpectedOutputFromInput(cut, input, expected);
|
||||
}
|
||||
|
||||
@ParameterizedTest(name = "[{index}] " + cutName + "({0}) = {1}")
|
||||
@CsvSource(value = {
|
||||
" 0, 0",
|
||||
" \"abc\", 0",
|
||||
" '\"abc\"', 0",
|
||||
" '{\"a\":[1, 2]}' , 1",
|
||||
" '[1, 2]' , 2",
|
||||
" '[\"a\", \"b\"]' , 2",
|
||||
" '{\"a\":[1, 2], \"b\":\"abc\", \"b\":true}' , 3",
|
||||
" true, 0 ",
|
||||
" 1, 0 ",
|
||||
" null, 0 ",
|
||||
})
|
||||
void Test_with_Json(@ConvertWith(StringJsonConverter.class) JsonValue input, String expected) throws EaterException, EaterExceptionLocated {
|
||||
assertTimExpectedOutputFromInput(cut, input, expected);
|
||||
}
|
||||
}
|
72
test/net/sourceforge/plantuml/tim/stdlib/UpperTest.java
Normal file
72
test/net/sourceforge/plantuml/tim/stdlib/UpperTest.java
Normal file
@ -0,0 +1,72 @@
|
||||
package net.sourceforge.plantuml.tim.stdlib;
|
||||
|
||||
import static net.sourceforge.plantuml.test.JunitUtils.StringJsonConverter;
|
||||
import static net.sourceforge.plantuml.tim.TimTestUtils.assertTimExpectedOutput;
|
||||
import static net.sourceforge.plantuml.tim.TimTestUtils.assertTimExpectedOutputFromInput;
|
||||
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.DisplayNameGenerator.ReplaceUnderscores;
|
||||
import org.junit.jupiter.api.IndicativeSentencesGeneration;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.params.converter.ConvertWith;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.CsvSource;
|
||||
|
||||
import net.sourceforge.plantuml.json.JsonValue;
|
||||
import net.sourceforge.plantuml.tim.EaterException;
|
||||
import net.sourceforge.plantuml.tim.EaterExceptionLocated;
|
||||
import net.sourceforge.plantuml.tim.TFunction;
|
||||
|
||||
/**
|
||||
* Tests the builtin function.
|
||||
*/
|
||||
@IndicativeSentencesGeneration(separator = ": ", generator = ReplaceUnderscores.class)
|
||||
|
||||
class UpperTest {
|
||||
TFunction cut = new Upper();
|
||||
final String cutName = "Upper";
|
||||
|
||||
// TODO: Manage Upper function without param. (today: we observe `Function not found %upper`)
|
||||
@Disabled
|
||||
@Test
|
||||
void Test_without_Param() throws EaterException, EaterExceptionLocated {
|
||||
assertTimExpectedOutput(cut, "");
|
||||
}
|
||||
|
||||
@ParameterizedTest(name = "[{index}] " + cutName + "(''{0}'') = {1}")
|
||||
@CsvSource(nullValues = "null", value = {
|
||||
" 0 , 0 ",
|
||||
" 1 , 1 ",
|
||||
" a , A ",
|
||||
" A , A ",
|
||||
" f , F ",
|
||||
" g , G ",
|
||||
" é , É ",
|
||||
" 😀 , 😀 ",
|
||||
})
|
||||
void Test_with_String(String input, String expected) throws EaterException, EaterExceptionLocated {
|
||||
assertTimExpectedOutputFromInput(cut, input, expected);
|
||||
}
|
||||
|
||||
@ParameterizedTest(name = "[{index}] " + cutName + "({0}) = {1}")
|
||||
@CsvSource(nullValues = "null", value = {
|
||||
" 0 , 0 ",
|
||||
" 1 , 1 ",
|
||||
" 10 , 10 ",
|
||||
" -1 , -1 ",
|
||||
})
|
||||
void Test_with_Integer(Integer input, String expected) throws EaterException, EaterExceptionLocated {
|
||||
assertTimExpectedOutputFromInput(cut, input, expected);
|
||||
}
|
||||
|
||||
@ParameterizedTest(name = "[{index}] " + cutName + "({0}) = {1}")
|
||||
@CsvSource(value = {
|
||||
" '{\"a\":[1, 2]}' , '{\"A\":[1,2]}'",
|
||||
" '[1, 2]' , '[1,2]'",
|
||||
" '{\"a\":[1, 2], \"b\":\"abc\", \"b\":true}' , '{\"A\":[1,2],\"B\":\"ABC\",\"B\":TRUE}'",
|
||||
" true , TRUE ",
|
||||
})
|
||||
void Test_with_Json(@ConvertWith(StringJsonConverter.class) JsonValue input, String expected) throws EaterException, EaterExceptionLocated {
|
||||
assertTimExpectedOutputFromInput(cut, input, expected);
|
||||
}
|
||||
}
|
@ -30,7 +30,7 @@ class XXXTest {
|
||||
|
||||
@Test
|
||||
void Test_without_Param() throws EaterException, EaterExceptionLocated {
|
||||
assertTimExpectedOutput(cut, "0"); // Change expetected value here
|
||||
assertTimExpectedOutput(cut, "0"); // Change expected value here
|
||||
}
|
||||
|
||||
@ParameterizedTest(name = "[{index}] " + cutName + "(''{0}'') = {1}")
|
||||
|
Loading…
Reference in New Issue
Block a user