summaryrefslogtreecommitdiffstats
path: root/util/cmake/tests/test_operations.py
blob: 95f894dae4b6e316b9913f8c1789d55915dd58b2 (plain)
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
#!/usr/bin/env python3
# Copyright (C) 2018 The Qt Company Ltd.
# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0

from pro2cmake import AddOperation, SetOperation, UniqueAddOperation, RemoveOperation

def test_add_operation():
    op = AddOperation(['bar', 'buz'])

    result = op.process(['foo', 'bar'], ['foo', 'bar'], lambda x: x)
    assert ['foo', 'bar', 'bar', 'buz'] == result


def test_uniqueadd_operation():
    op = UniqueAddOperation(['bar', 'buz'])

    result = op.process(['foo', 'bar'], ['foo', 'bar'], lambda x: x)
    assert ['foo', 'bar', 'buz'] == result


def test_set_operation():
    op = SetOperation(['bar', 'buz'])

    result = op.process(['foo', 'bar'], ['foo', 'bar'], lambda x: x)
    assert ['bar', 'buz'] == result


def test_remove_operation():
    op = RemoveOperation(['bar', 'buz'])

    result = op.process(['foo', 'bar'], ['foo', 'bar'], lambda x: x)
    assert ['foo', '-buz'] == result