Add test cases for chr().

master
Torsten Paul 2014-07-13 19:18:48 +02:00
parent 94fd976bad
commit 1269ef49c3
3 changed files with 32 additions and 0 deletions

24
testdata/scad/misc/chr-tests.scad vendored Normal file
View File

@ -0,0 +1,24 @@
function f(x) = x;
s = "string";
smiley = 9786;
// empty, inf, -inf, nan
echo(chr(), chr(1/0), chr(-1/0), chr(0/0));
// invalid values
echo(chr(0), chr(-0), chr(0.5), chr(-0.9), chr(-100), chr(2097152), chr(1e10), chr(-2e10));
// valid values
echo(chr(f(33)), chr(49), chr(65), chr(97), chr(smiley), chr(128512));
// multiple values
echo(chr(90, 89, 88), chr(65, "test", false, -5, 0, 66, [67:69], [70, 71, 72, 73], smiley));
// ranges
echo(chr([48:57]), chr([70 : 2 : 80]));
// vectors
echo(chr([65, 66, 67, 97, 98, 99]), chr([49, "test", true, -1, 50]));
// other (not supported) types
echo(chr(undef), chr(true), chr("test"), chr(s));

View File

@ -924,6 +924,7 @@ list(APPEND ECHO_FILES ${FUNCTION_FILES}
${CMAKE_SOURCE_DIR}/../testdata/scad/misc/string-test.scad
${CMAKE_SOURCE_DIR}/../testdata/scad/misc/string-indexing.scad
${CMAKE_SOURCE_DIR}/../testdata/scad/misc/string-unicode.scad
${CMAKE_SOURCE_DIR}/../testdata/scad/misc/chr-tests.scad
${CMAKE_SOURCE_DIR}/../testdata/scad/misc/vector-values.scad
${CMAKE_SOURCE_DIR}/../testdata/scad/misc/search-tests.scad
${CMAKE_SOURCE_DIR}/../testdata/scad/misc/search-tests-unicode.scad

View File

@ -0,0 +1,7 @@
ECHO: "", "", "", ""
ECHO: "", "", "", "", "", "", "", ""
ECHO: "!", "1", "A", "a", "☺", "😀"
ECHO: "ZYX", "ABCDEFGHI☺"
ECHO: "0123456789", "FHJLNP"
ECHO: "ABCabc", "12"
ECHO: "", "", "", ""