<commit_before>#include <AppStd_Application.hxx>
#include <TDocStd_Document.hxx>
#include <TDocStd_Application.hxx>
#include <OSD_File.hxx>
#include <OSD_Path.hxx>
#include <TCollection_ExtendedString.hxx>
#include <gtest/gtest.h>

Handle(TDocStd_Application) app = new AppStd_Application();

TEST(OCAFExportTestSuite, testExportAscii)
{
    const char * filename = "ascii.cbf";
    Handle(TDocStd_Document) doc;
    app->NewDocument("BinOcaf", doc);
    app->SaveAs(doc, filename);
    app->Close(doc);

    OSD_Path path(filename);
    OSD_File file(path);
    ASSERT_TRUE(file.Exists());
    file.Remove();
    ASSERT_FALSE(file.Failed());
}

TEST(OCAFExportTestSuite, testExportNonAscii)
{
    // Use codepoints and not characters to avoid encoding problems
    TCollection_ExtendedString extName("XX.cbf");
    extName.SetValue(1, 0x439);
    extName.SetValue(2, 0x446);
    char* filename = new char[extName.LengthOfCString()+1];
    extName.ToUTF8CString(filename);

    Handle(TDocStd_Document) doc;
    app->NewDocument("BinOcaf", doc);
    app->SaveAs(doc, filename);
    app->Close(doc);

    OSD_Path path(filename);
    OSD_File file(path);
    ASSERT_TRUE(file.Exists());
    file.Remove();
    ASSERT_FALSE(file.Failed());
    delete[] filename;
}

int main(int argc, char **argv){
  testing::InitGoogleTest(&argc, argv);
  return RUN_ALL_TESTS();
}<commit_msg>Add a test case for issue #441<commit_after>#include <AppStd_Application.hxx>
#include <TDocStd_Document.hxx>
#include <TDocStd_Application.hxx>
#include <OSD_File.hxx>
#include <OSD_Path.hxx>
#include <TCollection_ExtendedString.hxx>
#include <LDOM_OSStream.hxx>
#include <iostream>
#include <gtest/gtest.h>

Handle(TDocStd_Application) app = new AppStd_Application();

TEST(OCAFExportTestSuite, testExportAscii)
{
    const char * filename = "ascii.cbf";
    Handle(TDocStd_Document) doc;
    app->NewDocument("BinOcaf", doc);
    app->SaveAs(doc, filename);
    app->Close(doc);

    OSD_Path path(filename);
    OSD_File file(path);
    ASSERT_TRUE(file.Exists());
    file.Remove();
    ASSERT_FALSE(file.Failed());
}

TEST(OCAFExportTestSuite, testExportNonAscii)
{
    // Use codepoints and not characters to avoid encoding problems
    TCollection_ExtendedString extName("XX.cbf");
    extName.SetValue(1, 0x439);
    extName.SetValue(2, 0x446);
    char* filename = new char[extName.LengthOfCString()+1];
    extName.ToUTF8CString(filename);

    Handle(TDocStd_Document) doc;
    app->NewDocument("BinOcaf", doc);
    app->SaveAs(doc, filename);
    app->Close(doc);

    OSD_Path path(filename);
    OSD_File file(path);
    ASSERT_TRUE(file.Exists());
    file.Remove();
    ASSERT_FALSE(file.Failed());
    delete[] filename;
}

TEST(OCAFExportTestSuite, testOverflow)
{
    // See https://github.com/tpaviot/oce/pull/441
    LDOM_OSStream oss(128);
    oss << "line 1" << std::endl;
    oss << "line 2" << std::endl;
    ASSERT_TRUE(strlen(oss.str()) == 14);
}

int main(int argc, char **argv){
  testing::InitGoogleTest(&argc, argv);
  return RUN_ALL_TESTS();
}
{'fraction_non_alphanumeric': 0.14416775884665792, 'fraction_numerical': 0.012123197903014417, 'mean_word_length': 4.643253234750462, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 31, 'https://': 1, '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': '238726', 'n_tokens_mistral': 1119, 'n_tokens_neox': 1076, 'n_words': 196}