<commit_before>#include "DataLogger_HDF5.h"

#include <string>
  using std::string;

#include <gmock/gmock.h>
  using ::testing::Eq;
#include <gtest/gtest.h>
  using ::testing::Test;

#include "MockInputDataInterface.h"
#include "CEMdefs.h"


namespace CEM
{
namespace DataLogger_Test
{
namespace testing
{
    class DataLogger_Test : public Test
    {
    protected:
       DataLogger_Test(){}
       ~DataLogger_Test(){}

      virtual void SetUp()
      {
       
	input = new MockInputData;
        EXPECT_CALL(*input, getVectorLength()).WillRepeatedly(::testing::Return(15));
	EXPECT_CALL(*input, getOutputFileName()).WillRepeatedly(::testing::Return("CEMTest.h5"));
	
	dl = new DataLoggerHDF5(input);

      }
      virtual void TearDown(){ delete dl; delete input;}

        DataLoggerHDF5* dl;
        MockInputData* input;
        std::string outputFileName;

    };


    TEST_F(DataLogger_Test, write_read_vector)
    {
      std::vector<double> in = {1,5.87,7.993,8,10.2,2.0190,30,50,100,150,-100,-20,-30.5, 3.4, 5.776};
      dl->WriteDataArray(in);
      std::vector<double> out = dl->ReadDataArray(input->getOutputFileName(),"/Ex", 0);

      EXPECT_THAT(in.size(),Eq(out.size()));
      
      for (int counter = 0; counter < in.size();counter++)
	{
	  EXPECT_THAT(in[counter], Eq(out[counter]));
	}
    
    }

} // namespace testing
} // namespace DataLogger_Test
} // namespace CEM
<commit_msg>Adding unit test case to change the vector size for writing<commit_after>#include "DataLogger_HDF5.h"

#include <string>
  using std::string;

#include <gmock/gmock.h>
  using ::testing::Eq;
#include <gtest/gtest.h>
  using ::testing::Test;
using ::testing::TestWithParam;

#include "MockInputDataInterface.h"
#include "CEMdefs.h"


namespace CEM
{
namespace DataLogger_Test
{
namespace testing
{
  class DataLogger_Test : public TestWithParam<int>
    {
    protected:
       DataLogger_Test(){}
       ~DataLogger_Test(){}

      virtual void SetUp()
      {
	input = new MockInputData;
	EXPECT_CALL(*input, getOutputFileName()).WillRepeatedly(::testing::Return("CEMTest.h5"));
	
      }
      virtual void TearDown(){ delete dl; delete input;}

      DataLoggerHDF5* dl;
      MockInputData* input;
      std::string outputFileName;

      int size;

    };


    TEST_F(DataLogger_Test, write_read_vector_fixed_size)
    {
      EXPECT_CALL(*input, getVectorLength()).WillRepeatedly(::testing::Return(15));
      dl = new DataLoggerHDF5(input);
      std::vector<double> in = {1,5.87,7.993,8,10.2,2.0190,30,50,100,150,-100,-20,-30.5, 3.4, 5.776};
      dl->WriteDataArray(in);
      std::vector<double> out = dl->ReadDataArray(input->getOutputFileName(),"/Ex", 0);

      EXPECT_THAT(in.size(),Eq(out.size()));
      
      for (int counter = 0; counter < in.size();counter++)
	{
	  EXPECT_THAT(in[counter], Eq(out[counter]));
	}
    
    }

  TEST_P(DataLogger_Test, write_read_vector_variable_sizes)
  {
     size = GetParam();
     EXPECT_CALL(*input, getVectorLength()).WillRepeatedly(::testing::Return(size));
      dl = new DataLoggerHDF5(input);

     std::vector<double>(in);
     in.resize(size);
     for (int i = 0; i < size; i++)
       {
	 in[i] = rand();
       }

      dl->WriteDataArray(in);

     std::vector<double> out = dl->ReadDataArray(input->getOutputFileName(),"/Ex", 0);

      EXPECT_THAT(in.size(),Eq(out.size()));
      
      for (int counter = 0; counter < in.size();counter++)
	{
	  EXPECT_THAT(in[counter], Eq(out[counter]));
	}
      
    std::cout<<size <<std::endl;
  }

  INSTANTIATE_TEST_CASE_P(NewVectorSizes, DataLogger_Test,::testing::Values(5,7));//,10,30,50));

} // namespace testing
} // namespace DataLogger_Test
} // namespace CEM

{'fraction_non_alphanumeric': 0.16075778078484437, 'fraction_numerical': 0.029769959404600813, 'mean_word_length': 3.5405405405405403, 'pattern_counts': {'":': 0, '<': 24, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '406391', 'n_tokens_mistral': 1353, 'n_tokens_neox': 1271, 'n_words': 220}