<commit_before>#include <cmath>
#include <iostream>
#include <sstream>

#include <pqxx/pqxx>

using namespace PGSTD;
using namespace pqxx;


// Streams test program for libpqxx.  Insert a result field into various
// types of streams.
//
// Usage: test046 [connect-string]
//
// Where connect-string is a set of connection options in Postgresql's
// PQconnectdb() format, eg. "dbname=template1" to select from a database
// called template1, or "host=foo.bar.net user=smith" to connect to a
// backend running on host foo.bar.net, logging in as user smith.
int main(int, char *argv[])
{
  try
  {
    connection C(argv[1]);
    work T(C, "test46");
    result R( T.exec("SELECT count(*) FROM pg_tables") );

    cout << "Count was " << R.at(0).at(0) << endl;

    // Read the value into a stringstream
    stringstream I;
    I << R[0][0];

    // Now convert the stringstream into a numeric type
    long L, L2;
    I >> L;
    cout << "As a long, it's " << L << endl;

    R[0][0].to(L2);
    if (L != L2)
      throw logic_error("Different conversion methods gave different results!");

    float F, F2;
    stringstream I2;
    I2 << R[0][0];
    I2 >> F;
    cout << "As a float, it's " << F << endl;
    R[0][0].to(F2);
    if (fabs(F2-F) > 0.01)
      throw logic_error("Inconsistent floating-point result: " + to_string(F2));

    float F3;
    from_string(R[0][0].c_str(), F3);
    if (fabs(F3-F) > 0.01)
      throw logic_error("Inconsistent float result from from_string");

    double D;
    from_string(R[0][0].c_str(), D);
    if (fabs(D-F) > 0.01)
      throw logic_error("Inconsistent double result from from_string");

    long double LD;
    from_string(R[0][0].c_str(), LD);
    if (fabs(LD-F) > 0.01)
      throw logic_error("Inconsistent long double result from from_string");

    string S, S2, S3;
    from_string(R[0][0].c_str(), S);
    from_string(string(R[0][0].c_str()), S2);
    from_string(R[0][0], S3);
    if (S != S2)
      throw runtime_error("from_string(const char[],std::string &) "
	  "is inconsistent with "<commit_msg>Added check for "long double" support<commit_after>#include <cmath>
#include <iostream>
#include <sstream>

#include <pqxx/pqxx>

using namespace PGSTD;
using namespace pqxx;


// Streams test program for libpqxx.  Insert a result field into various
// types of streams.
//
// Usage: test046 [connect-string]
//
// Where connect-string is a set of connection options in Postgresql's
// PQconnectdb() format, eg. "dbname=template1" to select from a database
// called template1, or "host=foo.bar.net user=smith" to connect to a
// backend running on host foo.bar.net, logging in as user smith.
int main(int, char *argv[])
{
  try
  {
    connection C(argv[1]);
    work T(C, "test46");
    result R( T.exec("SELECT count(*) FROM pg_tables") );

    cout << "Count was " << R.at(0).at(0) << endl;

    // Read the value into a stringstream
    stringstream I;
    I << R[0][0];

    // Now convert the stringstream into a numeric type
    long L, L2;
    I >> L;
    cout << "As a long, it's " << L << endl;

    R[0][0].to(L2);
    if (L != L2)
      throw logic_error("Different conversion methods gave different results!");

    float F, F2;
    stringstream I2;
    I2 << R[0][0];
    I2 >> F;
    cout << "As a float, it's " << F << endl;
    R[0][0].to(F2);
    if (fabs(F2-F) > 0.01)
      throw logic_error("Inconsistent floating-point result: " + to_string(F2));

    float F3;
    from_string(R[0][0].c_str(), F3);
    if (fabs(F3-F) > 0.01)
      throw logic_error("Inconsistent float result from from_string");

    double D;
    from_string(R[0][0].c_str(), D);
    if (fabs(D-F) > 0.01)
      throw logic_error("Inconsistent double result from from_string");

#if defined(PQXX_HAVE_LONG_DOUBLE)
    long double LD;
    from_string(R[0][0].c_str(), LD);
    if (fabs(LD-F) > 0.01)
      throw logic_error("Inconsistent long double result from from_string");
#endif

    string S, S2, S3;
    from_string(R[0][0].c_str(), S);
    from_string(string(R[0][0].c_str()), S2);
    from_string(R[0][0], S3);
    if (S != S2)
      throw runtime_error("from_string(const char[],std::string &) "
	  "is inconsistent with "
{'fraction_non_alphanumeric': 0.15734098517455763, 'fraction_numerical': 0.028694404591104734, 'mean_word_length': 3.1374876360039563, 'pattern_counts': {'":': 0, '<': 55, '<?xml version=': 0, '>': 27, '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': '1325706', 'n_tokens_mistral': 1570, 'n_tokens_neox': 1493, 'n_words': 440}