@@ -2237,6 +2237,40 @@ void test_xml_tool_call_parsing() {
2237
2237
std::cout << " ✅ XML tool call parsing works correctly!" << std::endl;
2238
2238
}
2239
2239
2240
+ // Test whitespace preservation in qwen3 content extraction
2241
+ void test_qwen3_whitespace_preservation () {
2242
+ std::cout << " \n 🧹 Testing Qwen3 Whitespace Preservation Fix:" << std::endl;
2243
+
2244
+ // Test case with PEP 8 style: 2 empty lines between functions
2245
+ const std::string pep8_content = R"( def celsius_to_fahrenheit(celsius):
2246
+ return celsius * 9/5 + 32
2247
+
2248
+
2249
+ def fahrenheit_to_celsius(fahrenheit):
2250
+ return (fahrenheit - 32) * 5/9)" ;
2251
+
2252
+ std::cout << " 🎯 Testing PEP 8 compliance (2 empty lines between functions)..." << std::endl;
2253
+ std::cout << " Original content has: 2 empty lines between functions" << std::endl;
2254
+
2255
+ // Test the qwen3 content extraction directly
2256
+ std::string result = qwen3::extract_content_during_parsing (pep8_content, false );
2257
+
2258
+ // Check if the double newlines are preserved (should have \n\n\n for 2 empty lines)
2259
+ bool has_double_empty_lines = result.find (" \n\n\n " ) != std::string::npos;
2260
+
2261
+ std::cout << " Result content: '" << result << " '" << std::endl;
2262
+ std::cout << " Has 2 empty lines preserved: " << (has_double_empty_lines ? " YES" : " NO" ) << std::endl;
2263
+
2264
+ test_assert (has_double_empty_lines, " Qwen3: PEP 8 double empty lines preserved" );
2265
+
2266
+ // Additional test: ensure no excessive trimming
2267
+ test_assert (!result.empty (), " Qwen3: Content not empty after processing" );
2268
+ test_assert (result.find (" celsius_to_fahrenheit" ) != std::string::npos, " Qwen3: Function content preserved" );
2269
+ test_assert (result.find (" fahrenheit_to_celsius" ) != std::string::npos, " Qwen3: Second function preserved" );
2270
+
2271
+ std::cout << " ✅ Qwen3 whitespace preservation working correctly!" << std::endl;
2272
+ }
2273
+
2240
2274
// Test the streaming tool calls fix implementation
2241
2275
void test_streaming_tool_calls_fix () {
2242
2276
std::cout << " \n === Streaming Tool Calls Fix Validation ===" << std::endl;
@@ -2797,6 +2831,7 @@ int main() {
2797
2831
test_content_cleaning ();
2798
2832
test_contamination_reproduction (); // Added this test
2799
2833
test_mixed_formats ();
2834
+ test_qwen3_whitespace_preservation (); // Test whitespace fix
2800
2835
2801
2836
std::cout << " \n 🌍 Unicode & International Tests:" << std::endl;
2802
2837
test_unicode_support ();
0 commit comments