]> git.ipfire.org Git - thirdparty/snort3.git/commitdiff
added unit for CSVFormatter
authorCarter Waxman <cwaxman@cisco.com>
Wed, 6 Apr 2016 14:33:00 +0000 (10:33 -0400)
committerCarter Waxman <cwaxman@cisco.com>
Wed, 6 Apr 2016 14:35:28 +0000 (10:35 -0400)
src/network_inspectors/perf_monitor/csv_formatter.cc
src/network_inspectors/perf_monitor/csv_formatter.h
src/network_inspectors/perf_monitor/perf_formatter.h

index ff35c54588a5c78596277b4db63530852ec5422b..74cf94a93257f0b176a5848fa44c6f9cebf8c1ff 100644 (file)
 
 #include "csv_formatter.h"
 
+#ifdef UNIT_TEST
+#include "catch/catch.hpp"
+#endif
+
 using namespace std;
 
 SectionRef CSVFormatter::register_section(string name)
@@ -37,16 +41,6 @@ void CSVFormatter::init_output(FILE* fh)
 
 }
 
-void CSVFormatter::set_field(FieldRef ref, PegCount val)
-{
-    return PerfFormatter::set_field(ref, val);
-}
-
-void CSVFormatter::set_field(FieldRef ref, double val)
-{
-    return PerfFormatter::set_field(ref, val);
-}
-
 void CSVFormatter::write(FILE* fh, time_t timestamp)
 {
 
@@ -61,10 +55,10 @@ void CSVFormatter::clear()
 
 TEST_CASE("header output", "[perf csv_formatter]")
 {
-    const char* cooked =
+    char* fake_file, cooked =
         "#timestamp,name.one,name.two,other.three,other.four\n";
 
-    CSVFormatter f();
+    CSVFormatter f;
     FILE* fh = tmpfile();
 
     SectionRef s = f.register_section("name");
@@ -75,6 +69,10 @@ TEST_CASE("header output", "[perf csv_formatter]")
     f.register_field(s, "four");
     f.init_output(fh);
 
+    auto size = tell(fh);
+    rewind(fh);
+
+    fread(
     fclose(fh);
 }
 
index ad69d8fb13cf70745ed8ddef2f612ab52ed12da3..b624d0edbed702a5370356ce0c57464d6df9448e 100644 (file)
@@ -27,12 +27,14 @@ class CSVFormatter : public PerfFormatter
 {
 public:
     CSVFormatter() {};
-    virtual ~CSVFormatter() {};
     virtual SectionRef register_section(std::string) override;
     virtual FieldRef register_field(SectionRef, std::string) override;
     virtual void init_output(FILE*) override;
     virtual void write(FILE*, time_t) override;
     virtual void clear() override;
+
+private:
+    std::string header;
 };
 #endif
 
index 20a3e8347a5eaf21558ba6655e519bf07db738dd..c7bb7170d11765adc612cd6e2976af283c49d2ac 100644 (file)
@@ -57,7 +57,7 @@ public:
     virtual void set_field(FieldRef, PegCount);
     virtual void set_field(FieldRef, double);
     virtual void init_output(FILE*);
-    virtual void write(FILE*);
+    virtual void write(FILE*, time_t);
     virtual void clear();
 
 private: