From 9a2b0e3f72064569e90c7abe0c7fe6372da4137c Mon Sep 17 00:00:00 2001 From: Frank Elsinga Date: Sun, 10 Sep 2023 22:40:06 +0200 Subject: [PATCH] fixed the flaky slugification testcase --- .../src/search/search_executor/lexer.rs | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/server/main-api/src/search/search_executor/lexer.rs b/server/main-api/src/search/search_executor/lexer.rs index dbe2ded31..25cb0014f 100644 --- a/server/main-api/src/search/search_executor/lexer.rs +++ b/server/main-api/src/search/search_executor/lexer.rs @@ -78,15 +78,24 @@ mod tokenizer_tests { } #[test] - fn test_slugify() { + fn test_slugify_identical() { + // identical assert_eq!(&slugify(""), ""); assert_eq!(&slugify("a"), "a"); + assert_eq!(&slugify("1234567890"), "1234567890"); + assert_eq!(&slugify("äöüßa."), "äöüßa."); + } + + #[test] + fn test_slugify() { + // to-lower assert_eq!(&slugify("B"), "b"); - assert_eq!(&slugify("-B"), "b"); - assert_eq!(&slugify("-B"), "b"); - assert_eq!(&slugify("+#.a.-21"), "a-21"); - assert_eq!(&slugify("a--21"), "a-21"); assert_eq!(&slugify("aA"), "aa"); + // leading/tailing "-" get stripped + assert_eq!(&slugify("-B-"), "b"); + // no double dashes + assert_eq!(&slugify("a--21"), "a-21"); + assert_eq!(&slugify("a**21"), "a-21"); } #[test]