aboutsummaryrefslogtreecommitdiff
path: root/src/test/scala/xyz/driver/restquery/utils/StringOpsSuite.scala
blob: bd0bd2b0b05c7b5c11408751f4a52dda9ff9655d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package xyz.driver.pdsuicommon.utils

import xyz.driver.pdsuicommon.utils.Implicits.toStringOps
import org.scalatest.FreeSpecLike

class StringOpsSuite extends FreeSpecLike {

  "safeTrim" - {
    "empty string" in {
      assert("".safeTrim == "")
    }

    "string with whitespace symbols" in {
      assert("\u2002\u3000\r\u0085\u200A\u2005\u2000\u3000".safeTrim == "")
    }

    "string with control symbols" in {
      assert("\u001f\u007f\t\n".safeTrim == "")
    }

    "whitespaces and control symbols from the left side" in {
      assert("\u001f\u2002\u007f\nfoo".safeTrim == "foo")
    }

    "whitespaces and control symbols from the right side" in {
      assert("foo\u001f\u2002\u007f\n".safeTrim == "foo")
    }

    "already trimmed string" in {
      assert("foo".safeTrim == "foo")
    }
  }
}