[ox/std] Fix writeItoa to work with negatives
All checks were successful
Build / build (push) Successful in 1m9s
All checks were successful
Build / build (push) Successful in 1m9s
This commit is contained in:
2
deps/ox/src/ox/std/strconv.hpp
vendored
2
deps/ox/src/ox/std/strconv.hpp
vendored
@@ -25,7 +25,7 @@ constexpr ox::Error writeItoa(Integer v, ox::Writer_c auto &writer) noexcept {
|
|||||||
auto it = 0;
|
auto it = 0;
|
||||||
if (val < 0) {
|
if (val < 0) {
|
||||||
OX_RETURN_ERROR(writer.put('-'));
|
OX_RETURN_ERROR(writer.put('-'));
|
||||||
++it;
|
val = ~val + 1;
|
||||||
}
|
}
|
||||||
while (mod) {
|
while (mod) {
|
||||||
auto digit = val / mod;
|
auto digit = val / mod;
|
||||||
|
|||||||
1
deps/ox/src/ox/std/test/CMakeLists.txt
vendored
1
deps/ox/src/ox/std/test/CMakeLists.txt
vendored
@@ -28,3 +28,4 @@ add_test("[ox/std] FromHex" ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/StdTest "FromHex")
|
|||||||
add_test("[ox/std] ToHex" ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/StdTest "ToHex")
|
add_test("[ox/std] ToHex" ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/StdTest "ToHex")
|
||||||
add_test("[ox/std] UUID" ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/StdTest "UUID")
|
add_test("[ox/std] UUID" ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/StdTest "UUID")
|
||||||
add_test("[ox/std] UUID::generate" ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/StdTest "UUID::generate")
|
add_test("[ox/std] UUID::generate" ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/StdTest "UUID::generate")
|
||||||
|
add_test("[ox/std] intToStr" ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/StdTest "intToStr")
|
||||||
|
|||||||
14
deps/ox/src/ox/std/test/tests.cpp
vendored
14
deps/ox/src/ox/std/test/tests.cpp
vendored
@@ -536,6 +536,20 @@ OX_CLANG_NOWARN_END
|
|||||||
return ox::Error(0);
|
return ox::Error(0);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"intToStr",
|
||||||
|
[] {
|
||||||
|
oxExpect(ox::intToStr(5), "5");
|
||||||
|
oxExpect(ox::intToStr(5000), "5000");
|
||||||
|
oxExpect(ox::intToStr(50000), "50000");
|
||||||
|
oxExpect(ox::intToStr(500000), "500000");
|
||||||
|
oxExpect(ox::intToStr(-5), "-5");
|
||||||
|
oxExpect(ox::intToStr(-5000), "-5000");
|
||||||
|
oxExpect(ox::intToStr(-50000), "-50000");
|
||||||
|
oxExpect(ox::intToStr(-500000), "-500000");
|
||||||
|
return ox::Error{};
|
||||||
|
}
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
int main(int argc, const char **argv) {
|
int main(int argc, const char **argv) {
|
||||||
|
|||||||
Reference in New Issue
Block a user