<commit_before>/* ****************************************************************************
 *
 * FILE            SamsonDataSetTest.cpp
 *
 * AUTHOR          <NAME>
 *
 * DATE            Nov 2012
 *
 *
 * Telefónica Digital - Product Development and Innovation
 *
 * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
 * EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
 *
 * Copyright (c) Telefónica Investigación y Desarrollo S.A.U.
 * All rights reserved.
 *
 * DESCRIPTION
 * unit testing of the class SamsonDataSet in the samson common library
 *
 */
#include "gtest/gtest.h"
#include "logMsg/logMsg.h"

#include "samson/common/SamsonDataSet.h"
#include "unitTest/common_engine_test.h"


// -----------------------------------------------------------------------------
// Test the SamsonDataSet create method
//
TEST(samson_common_SamsonDataSet, constructor) {
  init_engine_test();

  // Test on Empty directory
  au::ErrorManager                          eManager;
  au::SharedPointer<samson::SamsonDataSet>  dataSetP = samson::SamsonDataSet::create("test_data/EmptyDir", eManager);
  EXPECT_TRUE(eManager.HasErrors());
  EXPECT_STREQ(eManager.GetLastError().c_str(), "No content");

  // Test on Non-existing directory
  eManager.Reset();
  dataSetP = samson::SamsonDataSet::create("/tmp/not a directory", eManager);
  EXPECT_TRUE(eManager.HasErrors());
  EXPECT_STREQ(eManager.GetLastError().c_str(), "/tmp/not a directory doesn't exist");

  // Test on correct directory with a correct samson data file inside
  eManager.Reset();
  // dataSetP = samson::SamsonDataSet::create("test_data/SamsonDataSetTest", eManager);
  // EXPECT_STREQ(eManager.GetLastError().c_str(), "Unknown data type for key: system.String");
  // EXPECT_STREQ(eManager.GetLastError().c_str(), "No errors");

  close_engine_test();
}<commit_msg>creating/removing test directory during tests<commit_after>/* ****************************************************************************
 *
 * FILE            SamsonDataSetTest.cpp
 *
 * AUTHOR          <NAME>
 *
 * DATE            Nov 2012
 *
 *
 * Telefónica Digital - Product Development and Innovation
 *
 * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
 * EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
 *
 * Copyright (c) Telefónica Investigación y Desarrollo S.A.U.
 * All rights reserved.
 *
 * DESCRIPTION
 * unit testing of the class SamsonDataSet in the samson common library
 *
 */
#include "gtest/gtest.h"
#include "logMsg/logMsg.h"

#include "samson/common/SamsonDataSet.h"
#include "unitTest/common_engine_test.h"


// -----------------------------------------------------------------------------
// Test the SamsonDataSet create method
//
TEST(samson_common_SamsonDataSet, constructor) {
  init_engine_test();

  // Test on Empty directory
  int status = mkdir("test_data/EmptyDir", 0777);
  EXPECT_EQ(0, status);

  au::ErrorManager                          eManager;
  au::SharedPointer<samson::SamsonDataSet>  dataSetP = samson::SamsonDataSet::create("test_data/EmptyDir", eManager);
  EXPECT_TRUE(eManager.HasErrors());
  EXPECT_STREQ(eManager.GetLastError().c_str(), "No content");

  // Test on Non-existing directory
  eManager.Reset();
  dataSetP = samson::SamsonDataSet::create("/tmp/not a directory", eManager);
  EXPECT_TRUE(eManager.HasErrors());
  EXPECT_STREQ(eManager.GetLastError().c_str(), "/tmp/not a directory doesn't exist");

  // Test on correct directory with a correct samson data file inside
  eManager.Reset();
  // dataSetP = samson::SamsonDataSet::create("test_data/SamsonDataSetTest", eManager);
  // EXPECT_STREQ(eManager.GetLastError().c_str(), "Unknown data type for key: system.String");
  // EXPECT_STREQ(eManager.GetLastError().c_str(), "No errors");

  status = rmdir("test_data/EmptyDir");
  EXPECT_EQ(0, status);

  close_engine_test();
}
{'fraction_non_alphanumeric': 0.1856581532416503, 'fraction_numerical': 0.00343811394891945, 'mean_word_length': 3.5559284116331096, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4042301', 'n_tokens_mistral': 1197, 'n_tokens_neox': 1202, 'n_words': 298}