File: test_string.py

package info (click to toggle)
dart 6.13.2%2Bds-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 56,948 kB
  • sloc: cpp: 274,310; python: 3,973; xml: 1,272; sh: 404; makefile: 31
file content (42 lines) | stat: -rw-r--r-- 1,522 bytes parent folder | download
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
34
35
36
37
38
39
40
41
42
# Copyright (c) 2011-2022, The DART development contributors
# All rights reserved.
#
# The list of contributors can be found at:
#   https://github.com/dartsim/dart/blob/master/LICENSE
#
# This file is provided under the "BSD-style" License

import pytest
import dartpy as dart


def test_case_conversions():
    assert dart.common.toUpper("to UppEr") == "TO UPPER"
    assert dart.common.toLower("to LowEr") == "to lower"


def test_trim():
    assert dart.common.trimLeft(" trim ThIs ") == "trim ThIs "
    assert dart.common.trimRight(" trim ThIs ") == " trim ThIs"
    assert dart.common.trim(" trim ThIs ") == "trim ThIs"

    assert dart.common.trimLeft("\n trim ThIs ", " ") == "\n trim ThIs "
    assert dart.common.trimLeft("\n trim ThIs ", "\n") == " trim ThIs "
    assert dart.common.trimRight(" trim ThIs \n", " ") == " trim ThIs \n"
    assert dart.common.trimRight(" trim ThIs \n", "\n") == " trim ThIs "
    assert dart.common.trim("\n trim ThIs \n", " ") == "\n trim ThIs \n"
    assert dart.common.trim("\n trim ThIs \n", "\n") == " trim ThIs "

    assert dart.common.trimLeft("\n trim ThIs \n", " \n") == "trim ThIs \n"
    assert dart.common.trimRight("\n trim ThIs \n", " \n") == "\n trim ThIs"
    assert dart.common.trim("\n trim ThIs \n", " \n") == "trim ThIs"


def test_split():
    assert len(dart.common.split(" trim ThIs ")) == 2
    assert dart.common.split(" trim ThIs ")[0] == "trim"
    assert dart.common.split(" trim ThIs ")[1] == "ThIs"


if __name__ == "__main__":
    pytest.main()