/test/types/policykey.cpp

https://gitlab.com/admin-github-cloud/cynara · C++ · 51 lines · 20 code · 10 blank · 21 comment · 0 complexity · 9ae0b5ba3105ed839a048a87d827246a MD5 · raw file

  1. /*
  2. * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. /**
  17. * @file test/types/policykey.cpp
  18. * @author Aleksander Zdyb <a.zdyb@samsung.com>
  19. * @version 1.0
  20. * @brief Tests for Cynara::PolicyKey
  21. */
  22. #include <gtest/gtest.h>
  23. #include <gmock/gmock.h>
  24. #include "../helpers.h"
  25. #include <types/PolicyKey.h>
  26. #include <cynara-admin-types.h>
  27. using namespace Cynara;
  28. TEST(PolicyKey, to_string) {
  29. typedef Cynara::PolicyKeyFeature PKF;
  30. PolicyKey pk1 = Helpers::generatePolicyKey();
  31. ASSERT_EQ("c\tu\tp", pk1.toString());
  32. PolicyKey pk2(PKF::createWildcard(), PKF::createWildcard(), PKF::createWildcard());
  33. ASSERT_EQ(CYNARA_ADMIN_WILDCARD "\t" CYNARA_ADMIN_WILDCARD "\t" CYNARA_ADMIN_WILDCARD,
  34. pk2.toString());
  35. PolicyKey pk3(PKF::createWildcard(), PKF::create("u"), PKF::createWildcard());
  36. ASSERT_EQ(CYNARA_ADMIN_WILDCARD "\tu\t" CYNARA_ADMIN_WILDCARD, pk3.toString());
  37. PolicyKey pk4(PKF::createAny(), PKF::createAny(), PKF::createAny());
  38. ASSERT_EQ(CYNARA_ADMIN_ANY "\t" CYNARA_ADMIN_ANY "\t" CYNARA_ADMIN_ANY, pk4.toString());
  39. PolicyKey pk5(PKF::createWildcard(), PKF::create("u"), PKF::createAny());
  40. ASSERT_EQ(CYNARA_ADMIN_WILDCARD "\tu\t" CYNARA_ADMIN_ANY, pk5.toString());
  41. }