Skip to content

Commit

Permalink
[C++] 0.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
uselessgoddess committed Sep 4, 2021
1 parent f61ec95 commit 7f45e59
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 12 deletions.
2 changes: 1 addition & 1 deletion cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ add_library(${PROJECT_NAME}.Library INTERFACE)
target_include_directories(${PROJECT_NAME}.Library INTERFACE ${PROJECT_NAME})
target_link_libraries(${PROJECT_NAME}.Library INTERFACE CONAN_PKG::platform.ranges)

if((DEFINED LINKS_PLATFORM_TESTS) AND (${LINKS_PLATFORM_TESTS}))
if(${LINKS_PLATFORM_TESTS})
add_executable(${PROJECT_NAME}.Tests ${PROJECT_NAME}.Tests/AllTests.cpp)
target_link_libraries(${PROJECT_NAME}.Tests PRIVATE ${PROJECT_NAME}.Library)
target_link_libraries(${PROJECT_NAME}.Tests PRIVATE CONAN_PKG::gtest)
Expand Down
4 changes: 2 additions & 2 deletions cpp/Platform.Random.Tests/RandomExtensionsTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
}

std::uint64_t temp = NextUInt64(RandomHelpers::Default, {0UL, 5UL});
ASSERT_LT(temp, 5UL);
ASSERT_GT(temp, 0UL);
ASSERT_LE(temp, 5UL);
ASSERT_GE(temp, 0UL);
}
ASSERT_LT(theSameCount, 8);
}
Expand Down
14 changes: 9 additions & 5 deletions cpp/Platform.Random/Platform.Random.TemplateLibrary.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,15 @@
<title>LinksPlatform's Platform.Random Template Library</title>
<summary>LinksPlatform's Platform.Random is a Template Library that contains helper functions and constants to work with random numbers.</summary>
<description>LinksPlatform's Platform.Random is a Template Library that contains helper functions and constants to work with random numbers. Use Platform.Random.h file to include the library.</description>
<releaseNotes>Initial release.</releaseNotes>
<version>0.0.1</version>
<authors>konard, norwend</authors>
<owners>konard, norwend</owners>
<copyright>konard, norwend</copyright>
<releaseNotes>Huge bug fix:
- compile error
- stupid functions ordering
- todo static throw
- test assertions</releaseNotes>
<version>0.1.0</version>
<authors>konard, norwend, uselessgoddess</authors>
<owners>konard, norwend, uselessgoddess</owners>
<copyright>konard, norwend, uselessgoddess</copyright>
<projectUrl>https://linksplatform.github.io/Random</projectUrl>
<repository type="git" url="https://github.com/linksplatform/Random" />
<icon>images/icon.png</icon>
Expand Down
8 changes: 4 additions & 4 deletions cpp/Platform.Random/RandomExtensions.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
namespace Platform::Random
{
static std::uint64_t NextUInt64(std::mt19937_64& random) { return NextUInt64(random, Ranges::UInt64); }
std::uint64_t NextUInt64(std::mt19937_64& random, const Ranges::Range<std::uint64_t>& range) { return std::uniform_int_distribution<std::uint64_t>{range.Minimum, range.Maximum}(random); }

static std::uint64_t NextUInt64(std::mt19937_64& random, const Range<std::uint64_t>& range) { return std::uniform_int_distribution<std::uint64_t>{range.Minimum, range.Maximum}(random); }
std::uint64_t NextUInt64(std::mt19937_64& random) { return NextUInt64(random, Ranges::UInt64); }

static bool NextBoolean(std::mt19937_64& random) { return std::uniform_int_distribution<int>{0, 1}(random); }
} // namespace Platform::Random
bool NextBoolean(std::mt19937_64& random) { return std::uniform_int_distribution<int>{}(random) % 2 == 0; }
}
1 change: 1 addition & 0 deletions cpp/Platform.Random/RandomHelpers.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
namespace Platform::Random::RandomHelpers
{
// FIXME: cert-err58-cpp
std::mt19937_64 Default { std::random_device{}() };
}

0 comments on commit 7f45e59

Please sign in to comment.