// // PromptCacheTest.cpp // MNN // // Tests for prompt cache utilities (stripThinkBlocks). // #include #include "MNNTestSuite.h" #include "prompt_cache_utils.hpp" using MNN::Transformer::stripThinkBlocks; class PromptCacheStripThinkTest : public MNNTestCase { public: virtual ~PromptCacheStripThinkTest() = default; virtual bool run(int precision) { // Test 1: basic strip { std::string text = "Hello reasoning here world"; stripThinkBlocks(text); MNNTEST_ASSERT(text == "Hello world"); } // Test 2: multiple blocks { std::string text = "amidbend"; stripThinkBlocks(text); MNNTEST_ASSERT(text == "midend"); } // Test 3: no tags { std::string text = "no tags here"; stripThinkBlocks(text); MNNTEST_ASSERT(text == "no tags here"); } // Test 4: trailing newlines after { std::string text = "beforex\n\nafter"; stripThinkBlocks(text); MNNTEST_ASSERT(text == "beforeafter"); } // Test 5: unclosed (no ) { std::string text = "beforeunclosed"; stripThinkBlocks(text); MNNTEST_ASSERT(text == "beforeunclosed"); } // Test 6: empty string { std::string text = ""; stripThinkBlocks(text); MNNTEST_ASSERT(text == ""); } // Test 7: trailing \r\n mix { std::string text = "ab\r\nc"; stripThinkBlocks(text); MNNTEST_ASSERT(text == "ac"); } return true; } }; MNNTestSuiteRegister(PromptCacheStripThinkTest, "op/prompt_cache");