|
14 | 14 | #include "log.h" |
15 | 15 | #include "regex-partial.h" |
16 | 16 |
|
| 17 | +template<class T> |
| 18 | +static void assert_equals(const char* label, const T& expected, const T& actual) { |
| 19 | + if (expected != actual){ |
| 20 | + std::ostringstream oss; |
| 21 | + if (label && *label) oss << label << '\n'; |
| 22 | + oss << "Expected: " << expected << "\nActual: " << actual; |
| 23 | + throw std::runtime_error(oss.str()); |
| 24 | + } |
| 25 | +} |
| 26 | + |
17 | 27 | template <class T> |
18 | 28 | static void assert_equals(const T & expected, const T & actual) { |
19 | | - if (expected != actual) { |
20 | | - std::cerr << "Expected: " << expected << std::endl; |
21 | | - std::cerr << "Actual: " << actual << std::endl; |
22 | | - std::cerr << std::flush; |
23 | | - throw std::runtime_error("Test failed"); |
24 | | - } |
| 29 | + assert_equals("", expected, actual); |
25 | 30 | } |
26 | 31 | static void assert_equals(const char * expected, const std::string & actual) { |
27 | 32 | return assert_equals<std::string>(expected, actual); |
@@ -201,14 +206,6 @@ static void test(const std::string & input, bool is_partial, const std::vector<s |
201 | 206 | assert_equals(expected, args_paths.size() == 1 && args_paths[0].empty() ? js->value.get<std::string>() : js->value.dump()); |
202 | 207 | } |
203 | 208 |
|
204 | | -template<typename T> |
205 | | -static void assert_equals(const char* label, const T& expected, const T& actual) { |
206 | | - if (!(expected == actual)) { |
207 | | - std::ostringstream oss; oss << label << "\nExpected: " << expected << "\nActual: " << actual; |
208 | | - throw std::runtime_error(oss.str()); |
209 | | - } |
210 | | -} |
211 | | - |
212 | 209 | static void test_deepseek_v3_1_tool_calls() { |
213 | 210 | //common_log_set_verbosity_thold(LOG_DEFAULT_DEBUG); |
214 | 211 | // variant: happy path for when it works as the model card says it should |
|
0 commit comments