1import os
2from cffi.ffiplatform import maybe_relative_path, flatten
3
4
5def test_not_absolute():
6    assert maybe_relative_path('foo/bar') == 'foo/bar'
7    assert maybe_relative_path('test_platform.py') == 'test_platform.py'
8
9def test_different_absolute():
10    p = os.path.join('..', 'baz.py')
11    assert maybe_relative_path(p) == p
12
13def test_absolute_mapping():
14    p = os.path.abspath('baz.py')
15    assert maybe_relative_path(p) == 'baz.py'
16    foobaz = os.path.join('foo', 'baz.py')
17    assert maybe_relative_path(os.path.abspath(foobaz)) == foobaz
18
19def test_flatten():
20    assert flatten("foo") == "3sfoo"
21    assert flatten(-10000000000000000000000000000) == \
22           "-10000000000000000000000000000i"
23    assert flatten([4, 5]) == "2l4i5i"
24    assert flatten({4: 5}) == "1d4i5i"
25    assert flatten({"foo": ("bar", "baaz")}) == "1d3sfoo2l3sbar4sbaaz"
26