Add a random numbers test with a fixed seed.
This commit is contained in:
parent
14954a3816
commit
5953ea7cb5
2 changed files with 24 additions and 0 deletions
|
@ -21,6 +21,8 @@
|
|||
#include "sprout/cstring/strlen.hpp"
|
||||
#include "sprout/preprocessor/comma.hpp"
|
||||
#include <cstdint>
|
||||
#include <random>
|
||||
#include <string>
|
||||
|
||||
template <typename T> using int_info_10 = dhandy::implem::int_info<T, 10>;
|
||||
template <typename T> using int_info_16 = dhandy::implem::int_info<T, 16>;
|
||||
|
@ -109,6 +111,22 @@ TEST_CASE ("Check int to char array conversions", "[s2i][int_conv]") {
|
|||
num = 0xFFFFFFFFFFFFFFFF;
|
||||
CHECK(int_to_ary<__int128_t SPROUT_PP_COMMA() 16>(num * 0x10000 + 0xffff) == "ffffffffffffffffffff");
|
||||
#endif
|
||||
|
||||
{
|
||||
//Try a random test, which should not compile as constexpr
|
||||
std::mt19937 gen;
|
||||
gen.seed(1234);
|
||||
for (int z = 0; z < 10; ++z) {
|
||||
const int num = gen();
|
||||
CHECK(int_to_ary(num) == std::to_string(num));
|
||||
}
|
||||
|
||||
const int num = gen();
|
||||
std::string hello = "hello world";
|
||||
std::string hello1 = hello + " " + int_to_ary(num);
|
||||
std::string hello2 = hello + " " + std::to_string(num);
|
||||
CHECK(hello1 == hello2);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE ("Check char array to int conversions", "[i2s][int_conv]") {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue