MCPcopy Create free account
hub / github.com/ProjectUnifree/unifree / TestCodeExtractors

Class TestCodeExtractors

tests/test_code_extrators.py:10–106  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8
9
10class TestCodeExtractors(unittest.TestCase):
11
12 def test_extract_first_source_code(self):
13 target_code = "some code here!"
14 responses = [
15 f"""
16```
17{target_code}
18```
19""",
20 f"""
21```
22{target_code}
23```
24Some ending comment
25""",
26 f"""
27Some beginning comment
28```
29{target_code}
30```
31Some ending comment
32""",
33 f"""
34Some beginning comment
35```cpp
36{target_code}
37```
38Some ending comment
39""",
40 f"""
41 Some beginning comment
42 ```h
43 {target_code}
44 ```
45 ```cpp
46 code we don't care about
47 ```
48 """,
49 f"""
50{target_code}
51""",
52 ]
53
54 for response in responses:
55 extracted_code = extract_first_source_code(response)
56 self.assertEqual(target_code, extracted_code)
57
58 def test_extract_header_implementation(self):
59 target_header = "header here!"
60 target_implementation = "implementation here!"
61 responses = [
62 f"""
63 ```cpp
64 {target_header}
65 ```
66 ```cpp
67 {target_implementation}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected