/test/helpers.cpp

https://gitlab.com/github-cloud-corporation/cynara · C++ · 55 lines · 24 code · 10 blank · 21 comment · 8 complexity · 7b86020929a117d010b05924206353fc 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/helpers.cpp
  18. * @author Aleksander Zdyb <a.zdyb@samsung.com>
  19. * @version 1.0
  20. * @brief Helper functions for tests
  21. */
  22. #include "helpers.h"
  23. #include "types/MonitorEntry.h"
  24. #include "types/PolicyKey.h"
  25. namespace Cynara {
  26. namespace Helpers {
  27. PolicyKey generatePolicyKey(const PolicyKeyFeature::ValueType &sufix) {
  28. auto createPKF = [&sufix](const PolicyKeyFeature::ValueType &value) -> PolicyKeyFeature {
  29. return PolicyKeyFeature::create(value + sufix);
  30. };
  31. return PolicyKey(createPKF("c"), createPKF("u"), createPKF("p"));
  32. }
  33. PolicyBucketId generateBucketId(const PolicyBucketId &sufix) {
  34. return "bucket" + sufix;
  35. }
  36. } // namespace Helpers
  37. bool operator ==(const MonitorEntry &me1, const MonitorEntry &me2) {
  38. return me1.key() == me2.key()
  39. && me1.result() == me2.result()
  40. && me1.timestamp() == me2.timestamp();
  41. }
  42. } // namespace Cynara
  43. bool operator ==(const timespec &t1, const timespec &t2) {
  44. return t1.tv_sec == t2.tv_sec && t1.tv_nsec == t2.tv_nsec;
  45. }