martinzink commented on a change in pull request #1066:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1066#discussion_r631751390



##########
File path: extensions/pdh/tests/PerformanceDataCounterTests.cpp
##########
@@ -0,0 +1,187 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "TestBase.h"
+#include "PDHCounters.h"
+#include "MemoryConsumptionCounter.h"
+#include "gsl/gsl-lite.hpp"
+
+using org::apache::nifi::minifi::processors::SinglePDHCounter;
+using org::apache::nifi::minifi::processors::PDHCounterArray;
+using org::apache::nifi::minifi::processors::PDHCounter;
+using org::apache::nifi::minifi::processors::MemoryConsumptionCounter;
+
+
+TEST_CASE("PDHCounterNameTests", "[pdhcounternametests]") {
+  std::unique_ptr<PDHCounter> test_counter = 
PDHCounter::createPDHCounter("\\System\\Threads");
+  REQUIRE(nullptr != dynamic_cast<SinglePDHCounter*> (test_counter.get()));
+  REQUIRE("\\System\\Threads" == test_counter->getName());
+  REQUIRE("System" == test_counter->getObjectName());
+  REQUIRE("Threads" == test_counter->getCounterName());
+}
+
+TEST_CASE("PDHCounterArrayNameTests", "[pdhcounterarraytests]") {
+  std::unique_ptr<PDHCounter> test_counter_array = 
PDHCounter::createPDHCounter("\\LogicalDisk(*)\\% Free Space");
+  REQUIRE(nullptr != dynamic_cast<PDHCounterArray*> 
(test_counter_array.get()));
+  REQUIRE("\\LogicalDisk(*)\\% Free Space" == test_counter_array->getName());
+  REQUIRE("LogicalDisk" == test_counter_array->getObjectName());
+  REQUIRE("% Free Space" == test_counter_array->getCounterName());
+}
+
+TEST_CASE("PDHCountersInvalidNameTests", "[pdhcountersinvalidnametests]") {
+  REQUIRE(nullptr == PDHCounter::createPDHCounter("Invalid Name"));
+  REQUIRE(nullptr == PDHCounter::createPDHCounter(""));
+  REQUIRE(nullptr == PDHCounter::createPDHCounter("Something\\Counter"));
+  REQUIRE(nullptr == PDHCounter::createPDHCounter("\\Too\\Many\\Separators"));
+  REQUIRE(nullptr == PDHCounter::createPDHCounter("Too\\Many\\Separators"));
+  REQUIRE(nullptr != PDHCounter::createPDHCounter("\\Valid\\Counter"));
+}
+
+class TestablePDHCounter : public SinglePDHCounter {
+ public:
+  explicit TestablePDHCounter(const std::string& query_name, bool is_double = 
true) : SinglePDHCounter(query_name, is_double) {
+  }
+};
+
+class TestablePDHCounterArray : public PDHCounterArray {
+ public:
+  explicit TestablePDHCounterArray(const std::string& query_name, bool 
is_double = true) : PDHCounterArray(query_name, is_double) {
+  }
+};
+
+TEST_CASE("PDHCountersAddingToQueryTests", "[pdhcountersaddingtoquerytests]") {
+  PDH_HQUERY pdh_query;
+  PdhOpenQueryA(nullptr, 0, &pdh_query);
+  gsl::finally([&pdh_query] { PdhCloseQuery(&pdh_query); });

Review comment:
       yeah, you were right (it complies because pdh_query is ptr but its 
location is also a ptr) fixed it in 
[d536ded](https://github.com/apache/nifi-minifi-cpp/pull/1066/commits/d536deda68b57c0c18ee34ff32b6a843d819b8ef)




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to