def test_cpp_code_splitter() -> None:
    """Test case for code splitting using C++."""
    if "CI" in os.environ:
        return

    # Removing chunk_lines, chunk_lines_overlap, and max_chars to focus on scopes
    code_splitter = CodeHierarchyNodeParser(
        language="cpp",
        skeleton=False,
        chunk_min_characters=0,
    )

    text = """\
#include <iostream>

class MyClass {       // The class
  public:             // Access specifier
    int myNum;        // Attribute (int variable)
    string myString;  // Attribute (string variable)
    void myMethod() { // Method/function defined inside the class
        cout << "Hello World!";
    }
};

int main() {
    std::cout << "Hello, World!" << std::endl;
    return 0;
}"""

    text_node = TextNode(
        text=text,
    )
    chunks = code_splitter.get_nodes_from_documents([text_node])

    # Test the first chunk (#include statement)
    assert chunks[0].text == text
    assert chunks[0].metadata["inclusive_scopes"] == []

    # Test the second chunk (class MyClass)
    assert (
        chunks[1].text
        == """\
class MyClass {       // The class
  public:             // Access specifier
    int myNum;        // Attribute (int variable)
    string myString;  // Attribute (string variable)
    void myMethod() { // Method/function defined inside the class
        cout << "Hello World!";
    }
}"""
    )
    assert chunks[1].metadata["inclusive_scopes"] == [
        {"name": "MyClass", "type": "class_specifier", "signature": "class MyClass"}
    ]
    assert (
        cast(RelatedNodeInfo, chunks[1].relationships[NodeRelationship.PARENT]).node_id
        == chunks[0].id_
    )
    assert [c.node_id for c in chunks[1].relationships[NodeRelationship.CHILD]] == [
        chunks[2].id_
    ]

    # Test the third chunk (myMethod in class MyClass)
    assert (
        chunks[2].text
        == """\
    void myMethod() { // Method/function defined inside the class
        cout << "Hello World!";
    }"""
    )
    assert chunks[2].metadata["inclusive_scopes"] == [
        {"name": "MyClass", "type": "class_specifier", "signature": "class MyClass"},
        {
            "name": "myMethod()",
            "type": "function_definition",
            "signature": "void myMethod()",
        },
    ]
    assert (
        cast(RelatedNodeInfo, chunks[2].relationships[NodeRelationship.PARENT]).node_id
        == chunks[1].id_
    )
    assert chunks[2].relationships[NodeRelationship.CHILD] == []

    # Test the fourth chunk (main function)
    assert (
        chunks[3].text
        == """\
int main() {
    std::cout << "Hello, World!" << std::endl;
    return 0;
}"""
    )
    assert chunks[3].metadata["inclusive_scopes"] == [
        {"name": "main()", "type": "function_definition", "signature": "int main()"}
    ]
    assert (
        cast(RelatedNodeInfo, chunks[3].relationships[NodeRelationship.PARENT]).node_id
        == chunks[0].id_
    )
    assert chunks[3].relationships[NodeRelationship.CHILD] == []
Test case for code splitting using C++.
llama-index-packs/llama-index-packs-code-hierarchy/tests/test_code_hierarchy_no_skeleton.py