Skip to content

Commit aaba886

Browse files
committed
test(server): update ParamsFromJsonCmpl expectations to b9739 schema behavior
b9739's server-schema validation changed two behaviors that the existing tests encoded from an earlier llama.cpp: - negative n_discard is now range-checked (0 <= value <= INT32_MAX) and throws, instead of being silently clamped to 0; and - every field-validation failure is wrapped in std::invalid_argument ("Field '<name>': ...", server-schema.cpp) rather than surfacing the inner std::runtime_error. Update the four affected assertions (NDiscard negative now expects a throw; dry_sequence_breakers / lora / repeat_last_n expect std::invalid_argument) and the descriptive comment block. With the prior server-schema.cpp test-link fix, the full C++ suite passes locally (446/446). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SfvSZ76NW4e1qX1PjL4RKq
1 parent 38be6db commit aaba886

1 file changed

Lines changed: 12 additions & 10 deletions

File tree

src/test/cpp/test_server.cpp

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1710,10 +1710,10 @@ TEST(CmplFinalChatStream, IncludeUsageTrue_TrailingChunkHasEmptyChoicesAndUsage)
17101710
// - repeat_last_n=-1 is expanded to n_ctx_slot
17111711
// - dry_penalty_last_n=-1 is expanded to n_ctx_slot
17121712
// - dry_base < 1.0 is reset to default
1713-
// - n_discard negative is clamped to 0
1714-
// - empty dry_sequence_breakers throws std::runtime_error
1715-
// - lora field not an array throws std::runtime_error
1716-
// - repeat_last_n < -1 throws std::runtime_error
1713+
// - n_discard negative throws std::invalid_argument (b9739: range-checked, no longer clamped)
1714+
// - empty dry_sequence_breakers throws std::invalid_argument
1715+
// - lora field not an array throws std::invalid_argument
1716+
// - repeat_last_n < -1 throws std::invalid_argument
17171717
// ============================================================
17181718

17191719
namespace {
@@ -1749,21 +1749,23 @@ TEST(ParamsFromJsonCmpl, DryBase_BelowOne_ResetToDefault) {
17491749
EXPECT_FLOAT_EQ(p.sampling.dry_base, defaults.sampling.dry_base);
17501750
}
17511751

1752-
TEST(ParamsFromJsonCmpl, NDiscard_Negative_ClampedToZero) {
1753-
const auto p = parse_params({{"n_discard", -5}});
1754-
EXPECT_EQ(p.n_discard, 0);
1752+
// b9739: negative n_discard is range-checked (0 <= value <= INT32_MAX) and now throws
1753+
// instead of being silently clamped to 0. The schema wraps every field-validation failure
1754+
// in std::invalid_argument ("Field '<name>': ...", server-schema.cpp).
1755+
TEST(ParamsFromJsonCmpl, NDiscard_Negative_Throws) {
1756+
EXPECT_THROW(parse_params({{"n_discard", -5}}), std::invalid_argument);
17551757
}
17561758

17571759
TEST(ParamsFromJsonCmpl, EmptyDrySequenceBreakers_Throws) {
1758-
EXPECT_THROW(parse_params({{"dry_sequence_breakers", json::array()}}), std::runtime_error);
1760+
EXPECT_THROW(parse_params({{"dry_sequence_breakers", json::array()}}), std::invalid_argument);
17591761
}
17601762

17611763
TEST(ParamsFromJsonCmpl, LoraNotArray_Throws) {
1762-
EXPECT_THROW(parse_params({{"lora", "not-an-array"}}), std::runtime_error);
1764+
EXPECT_THROW(parse_params({{"lora", "not-an-array"}}), std::invalid_argument);
17631765
}
17641766

17651767
TEST(ParamsFromJsonCmpl, RepeatLastN_BelowMinusOne_Throws) {
1766-
EXPECT_THROW(parse_params({{"repeat_last_n", -2}}), std::runtime_error);
1768+
EXPECT_THROW(parse_params({{"repeat_last_n", -2}}), std::invalid_argument);
17671769
}
17681770

17691771
TEST(ParamsFromJsonCmpl, StreamOptions_IncludeUsage_Parsed) {

0 commit comments

Comments
 (0)