summaryrefslogtreecommitdiff
path: root/tests/typ/utility/string.typ
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2022-03-18 23:36:18 +0100
committerLaurenz <laurmaedje@gmail.com>2022-03-18 23:43:58 +0100
commitbeca01c826ee51c9ee6d5eadd7e5ef10f7fb9f58 (patch)
treee0ebb40b8775bba3b4be7bc47dceda3d349e2ac0 /tests/typ/utility/string.typ
parent77d153d315a2a5909840ebcd47491e4cef14428b (diff)
Methods
Diffstat (limited to 'tests/typ/utility/string.typ')
-rw-r--r--tests/typ/utility/string.typ52
1 files changed, 52 insertions, 0 deletions
diff --git a/tests/typ/utility/string.typ b/tests/typ/utility/string.typ
new file mode 100644
index 00000000..9b57e833
--- /dev/null
+++ b/tests/typ/utility/string.typ
@@ -0,0 +1,52 @@
+// Test string related methods.
+// Ref: false
+
+---
+// Test conversion to string.
+#test(str(123), "123")
+#test(str(50.14), "50.14")
+#test(str(10 / 3).len() > 10, true)
+#test(repr(ltr), "ltr")
+#test(repr((1, 2, false, )), "(1, 2, false)")
+
+---
+// Error: 6-8 cannot convert content to string
+#str([])
+
+---
+// Test the `split` and `trim` methods.
+#test(
+ "Typst, LaTeX, Word, InDesign".split(",").map(s => s.trim()),
+ ("Typst", "LaTeX", "Word", "InDesign"),
+)
+
+---
+// Test the `upper` and `lower` functions.
+#let memes = "ArE mEmEs gReAt?";
+#test(lower(memes), "are memes great?")
+#test(upper(memes), "ARE MEMES GREAT?")
+#test(upper("Ελλάδα"), "ΕΛΛΆΔΑ")
+
+---
+// Error: 8-9 expected string or content, found integer
+#upper(1)
+
+---
+// Error: 9-11 must be at least zero
+#symbol(-1)
+
+---
+// Test integrated lower, upper and symbols.
+// Ref: true
+#upper("Abc 8")
+#upper[def]
+
+#lower("SCREAMING MUST BE SILENCED in " + roman(1672) + " years")
+
+#for i in range(9) {
+ symbol(i)
+ [ and ]
+ roman(i)
+ [ for #i]
+ parbreak()
+}