Skip to content

Commit

Permalink
feat: [basic_model_speedup] cmake option to compile vector/unordered_…
Browse files Browse the repository at this point in the history
…set policy storage
  • Loading branch information
AlexeyChashchegorov committed Mar 5, 2024
1 parent 59828e4 commit c12899d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ if(APPLE AND NOT DEFINED CMAKE_OSX_DEPLOYMENT_TARGET)
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.13" CACHE STRING "Minimum OS X deployment version")
endif()

option(BUILD_HASHED "Build policy stored in hases" ON)

if(BUILD_HASHED)
add_compile_options("-DHASHED_POLICIES_VALUES")
endif()

if(WIN32)
add_compile_options("/bigobj")
Expand Down
11 changes: 6 additions & 5 deletions tests/management_api_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,21 +49,22 @@ void TestGetPolicy(casbin::Enforcer& e, const PoliciesValues& res) {

void TestGetFilteredPolicy(casbin::Enforcer& e, int field_index, const PoliciesValues& res, const std::vector<std::string>& field_values) {
auto my_res = e.GetFilteredPolicy(field_index, field_values);
for(auto m_it = my_res.begin(), r_it = res.begin(); m_it != my_res.end(); m_it++, r_it++)
auto r_it = res.begin();
for(auto m_it = my_res.begin(); m_it != my_res.end(); m_it++, r_it++)
ASSERT_TRUE(casbin::ArrayEquals(*m_it, *r_it));
}

void TestGetGroupingPolicy(casbin::Enforcer& e, const PoliciesValues& res) {
auto my_res = e.GetGroupingPolicy();

for(auto m_it = my_res.begin(), r_it = res.begin(); m_it != my_res.end(); m_it++, r_it++)
auto r_it = res.begin();
for(auto m_it = my_res.begin(); m_it != my_res.end(); m_it++, r_it++)
ASSERT_TRUE(casbin::ArrayEquals(*m_it, *r_it));
}

void TestGetFilteredGroupingPolicy(casbin::Enforcer& e, int field_index, const PoliciesValues& res, const std::vector<std::string>& field_values) {
auto my_res = e.GetFilteredGroupingPolicy(field_index, field_values);

for(auto m_it = my_res.begin(), r_it = res.begin(); m_it != my_res.end(); m_it++, r_it++)
auto r_it = res.begin();
for(auto m_it = my_res.begin(); m_it != my_res.end(); m_it++, r_it++)
ASSERT_TRUE(casbin::ArrayEquals(*m_it, *r_it));
}

Expand Down

0 comments on commit c12899d

Please sign in to comment.