Home / Function/ test_csharp_code_splitter() — langchain Function Reference

test_csharp_code_splitter() — langchain Function Reference

Architecture documentation for the test_csharp_code_splitter() function in test_text_splitters.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  ff5afdf8_7588_7115_91e6_48b361f4c3bb["test_csharp_code_splitter()"]
  6d6b8ad4_1cfe_fbb0_e58e_76a50487c135["test_text_splitters.py"]
  ff5afdf8_7588_7115_91e6_48b361f4c3bb -->|defined in| 6d6b8ad4_1cfe_fbb0_e58e_76a50487c135
  style ff5afdf8_7588_7115_91e6_48b361f4c3bb fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/text-splitters/tests/unit_tests/test_text_splitters.py lines 918–982

def test_csharp_code_splitter() -> None:
    splitter = RecursiveCharacterTextSplitter.from_language(
        Language.CSHARP, chunk_size=CHUNK_SIZE, chunk_overlap=0
    )
    code = """
using System;
class Program
{
    static void Main()
    {
        int age = 30; // Change the age value as needed

        // Categorize the age without any console output
        if (age < 18)
        {
            // Age is under 18
        }
        else if (age >= 18 && age < 65)
        {
            // Age is an adult
        }
        else
        {
            // Age is a senior citizen
        }
    }
}
    """

    chunks = splitter.split_text(code)
    assert chunks == [
        "using System;",
        "class Program\n{",
        "static void",
        "Main()",
        "{",
        "int age",
        "= 30; // Change",
        "the age value",
        "as needed",
        "//",
        "Categorize the",
        "age without any",
        "console output",
        "if (age",
        "< 18)",
        "{",
        "//",
        "Age is under 18",
        "}",
        "else if",
        "(age >= 18 &&",
        "age < 65)",
        "{",
        "//",
        "Age is an adult",
        "}",
        "else",
        "{",
        "//",
        "Age is a senior",
        "citizen",
        "}\n    }",
        "}",
    ]

Domain

Subdomains

Frequently Asked Questions

What does test_csharp_code_splitter() do?
test_csharp_code_splitter() is a function in the langchain codebase, defined in libs/text-splitters/tests/unit_tests/test_text_splitters.py.
Where is test_csharp_code_splitter() defined?
test_csharp_code_splitter() is defined in libs/text-splitters/tests/unit_tests/test_text_splitters.py at line 918.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free