[ConstraintElim] Add support for decomposing gep nuw (#118639)
[llvm-project.git] / clang / tools / scan-build-py / tests / unit / test_shell.py
blobdd27d2caa714bf5c514c5997b5d3cb21a5116774
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
7 import unittest
10 class ShellTest(unittest.TestCase):
11 def test_encode_decode_are_same(self):
12 def test(value):
13 self.assertEqual(sut.encode(sut.decode(value)), value)
15 test("")
16 test("clang")
17 test("clang this and that")
19 def test_decode_encode_are_same(self):
20 def test(value):
21 self.assertEqual(sut.decode(sut.encode(value)), value)
23 test([])
24 test(["clang"])
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):
31 self.assertEqual(
32 sut.encode(["clang", "it's me", "again"]), 'clang "it\'s me" again'
34 self.assertEqual(
35 sut.encode(["clang", "it(s me", "again)"]), 'clang "it(s me" "again)"'
37 self.assertEqual(
38 sut.encode(["clang", "redirect > it"]), 'clang "redirect > it"'
40 self.assertEqual(
41 sut.encode(["clang", '-DKEY="VALUE"']), 'clang -DKEY=\\"VALUE\\"'
43 self.assertEqual(
44 sut.encode(["clang", '-DKEY="value with spaces"']),
45 'clang -DKEY=\\"value with spaces\\"',