test: fix GetRangeWithMaxLongLength on 32 bit machines (#1867)

The test used the hardcoded long value for 64 bit machines even on 32
bit ones, leading to test failures. With this patch the max long length
is obtained using std::numeric_limits<long>::max(). Thanks to q2a3z for
the hint!

Fixes: https://github.com/yhirose/cpp-httplib/issues/1795
This commit is contained in:
Andrea Pappacoda authored and GitHub committed 2024-06-23 17:49:00 -04:00
1 parent 9e4f93d87e
commit bdefdce1ae
1 file changed
+2 -1
+2 -1
View File
@@ -6,6 +6,7 @@
#include <atomic> #include <atomic>
#include <chrono> #include <chrono>
#include <future> #include <future>
#include <limits>
#include <memory> #include <memory>
#include <sstream> #include <sstream>
#include <stdexcept> #include <stdexcept>
@@ -3474,7 +3475,7 @@ TEST_F(ServerTest, GetStreamedWithRangeError) {
TEST_F(ServerTest, GetRangeWithMaxLongLength) { TEST_F(ServerTest, GetRangeWithMaxLongLength) {
auto res = auto res =
cli_.Get("/with-range", {{"Range", "bytes=0-9223372036854775807"}}); cli_.Get("/with-range", {{"Range", "bytes=0-" + std::to_string(std::numeric_limits<long>::max())}});
EXPECT_EQ(StatusCode::RangeNotSatisfiable_416, res->status); EXPECT_EQ(StatusCode::RangeNotSatisfiable_416, res->status);
EXPECT_EQ("0", res->get_header_value("Content-Length")); EXPECT_EQ("0", res->get_header_value("Content-Length"));
EXPECT_EQ(false, res->has_header("Content-Range")); EXPECT_EQ(false, res->has_header("Content-Range"));