1 # -*- coding: utf-8 -*-
2 # Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
3 # See https://llvm.org/LICENSE.txt for license information.
4 # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 import libscanbuild
.shell
as sut
10 class ShellTest(unittest
.TestCase
):
11 def test_encode_decode_are_same(self
):
13 self
.assertEqual(sut
.encode(sut
.decode(value
)), value
)
17 test("clang this and that")
19 def test_decode_encode_are_same(self
):
21 self
.assertEqual(sut
.decode(sut
.encode(value
)), value
)
25 test(["clang", "this", "and", "that"])
26 test(["clang", "this and", "that"])
27 test(["clang", "it's me", "again"])
28 test(["clang", 'some "words" are', "quoted"])
30 def test_encode(self
):
32 sut
.encode(["clang", "it's me", "again"]), 'clang "it\'s me" again'
35 sut
.encode(["clang", "it(s me", "again)"]), 'clang "it(s me" "again)"'
38 sut
.encode(["clang", "redirect > it"]), 'clang "redirect > it"'
41 sut
.encode(["clang", '-DKEY="VALUE"']), 'clang -DKEY=\\"VALUE\\"'
44 sut
.encode(["clang", '-DKEY="value with spaces"']),
45 'clang -DKEY=\\"value with spaces\\"',