aboutsummaryrefslogtreecommitdiffstats
path: root/tests/Test_Utils/Test_GraphIsCyclic.cs
blob: e7302408362f7568f9793d3f90720ffa2b312457 (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
33
34
35
36
37
/***************************************************************************************************
 Copyright (C) 2025 The Qt Company Ltd.
 SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
***************************************************************************************************/

using Qt.DotNet.Utils.Collections;

namespace Test_Utils
{
    [TestClass]
    public class Test_GraphIsCyclic
    {
        [TestMethod]
        public void CyclicGraph_ShouldReturnTrue()
        {
            Dictionary<string, List<string>> graph = new()
            {
                { "A", [ "B" ] },
                { "B", [ "C" ] },
                { "C", [ "A" ] }
            };
            Assert.IsTrue(graph.IsCyclic());
        }

        [TestMethod]
        public void AcyclicGraph_ShouldReturnFalse()
        {
            Dictionary<string, List<string>> graph = new()
            {
                { "A", [ "B", "C" ] },
                { "B", [ "C" ] },
                { "C", [ ] }
            };
            Assert.IsFalse(graph.IsCyclic());
        }
    }
}