Changeset 2832 in Sophya for trunk/SophyaProg/Tests/ttimestamp.cc


Ignore:
Timestamp:
Nov 8, 2005, 5:18:06 PM (20 years ago)
Author:
ansari
Message:

Programmes test TimeStamp completes (format YYYY-MM-DDThh:mm:ss) et programme test DataTable (champ DateTime et I/O ascii - Reza 8 Nov 2005

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/SophyaProg/Tests/ttimestamp.cc

    r2828 r2832  
    66#include <iostream>
    77#include <string>
     8#include <vector>
    89
    910#include <typeinfo>
     
    1213#include "histinit.h"
    1314#include "pexceptions.h"
     15#include "ppfwrapstlv.h"
    1416
    1517/*  Programme test de la classe TimeStamp             */
     
    3234    cout << "ts2: 26/8/1974 14:22:35.65 : " << ts2 
    3335         << " double->TimeStamp: " << TimeStamp(ts2.ToDays()) << endl;
    34     TimeStamp ts3("01/01/1905","00:00:00");
    35     cout << "ts3: 01/01/1905 , 00:00:00 : " << ts3 << " (double): "
     36    TimeStamp ts3("08/05/1905","00:00:00");
     37    cout << "ts3: 8/05/1905 , 00:00:00 : " << ts3 << " (double): "
    3638         << (double)ts3 << " double->TimeStamp: " << TimeStamp(ts3.ToDays()) << endl;
    3739    TimeStamp ts4("01/01/1901","03:00:20");
     
    4547    cout << "ts6: 01/12/1899 , 15:30:00 : " << ts6 << " (double): "
    4648         << (double)ts6 << " double->TimeStamp: " << TimeStamp(ts6.ToDays()) << endl;
     49
    4750    cout << " ts.ToString(bool, bool) test : " << endl;
    4851    cout << " ts.ToString()= " << ts.ToString() << endl;
    49     cout << " ts.ToString(fgd=true, fgh=false)= " << ts.ToString(true, false) << endl;
    50     cout << " ts.ToString(fgd=false, fgh=true)= " << ts.ToString(false, true) << endl;
     52    cout << " ts.ToString(FmtDateOnly)= " << ts.ToString(TimeStamp::FmtDateOnly) << endl;
     53    cout << " ts.ToString(FmtTimeOnly)= " << ts.ToString(TimeStamp::FmtTimeOnly) << endl;
     54    cout << " ts.ToString(FmtDateTime)= " << ts.ToString(TimeStamp::FmtDateTime) << endl;
    5155
     56    TimeStamp ts12("1974-08-26T14:22:35.65");
     57    cout << "ts12: 1974-08-26T14:22:35.65 : " << ts12 
     58         << " double->TimeStamp: " << TimeStamp(ts12.ToDays()) << endl;
     59    TimeStamp ts13("1905-05-08T00:00:00");
     60    cout << "ts13: 1905-05-08T00:00:00  " << ts13 << " (double): "
     61         << (double)ts13 << " double->TimeStamp: " << TimeStamp(ts13.ToDays()) << endl;
     62
     63    double diff;
     64    diff = ts12.ToDays()-ts2.ToDays();
     65    if (fabs(diff) > 1.e-6) {
     66      cout << "ttimestamp/Erreur Diff t12-t2 : Rc+=1 " << endl;
     67      rc += 1;
     68    }
     69    diff = ts13.ToDays()-ts3.ToDays();
     70    if (fabs(diff) > 1.e-6) {
     71      cout << "ttimestamp/Erreur Diff t13-t3 : Rc+=2 " << endl;
     72      rc += 2;
     73    }
     74    TimeStamp tsa("1901-1-1T14:0:0");
     75    diff = tsa.ToDays()-38./24.;
     76    if (fabs(diff) > 1.e-6) {
     77      cout << "ttimestamp/Erreur Diff tsa-38/24. : Rc+=4 " << endl;
     78      rc += 4;
     79    }
     80    tsa.Set("1901-02-07T18:00:00");
     81    diff = tsa.ToDays()-38.75;
     82    if (fabs(diff) > 1.e-6) {
     83      cout << "ttimestamp/Erreur Diff tsa-38.75 : Rc+=8 " << endl;
     84      rc += 8;
     85    }
     86    tsa.Set("2004-08-24T18:00:00");
     87    TimeStamp tsb("2004-09-03T21:00:00");
     88    diff = tsb.ToDays()-tsa.ToDays();
     89    if (fabs(diff-10.125) > 1.e-6) {
     90      cout << "ttimestamp/Erreur Diff tsb-tsa : Rc+=16 " << endl;
     91      rc += 16;
     92    }
     93    if (rc == 0)
     94      cout << "ttimestamp/Info CheckDiffs OK (Rc=" << rc << ")" << endl;
     95    else
     96      cout << "ttimestamp/Erreur Pb Diffs  (Rc=" << rc << ")" << endl;
     97
     98    cout << "ttimestamp/Info: Test PPF , vector<TimeStamp> " << endl;
     99    vector<TimeStamp> vts, vtsr;
     100    vts.push_back(ts);
     101    vts.push_back(ts2);
     102    vts.push_back(ts3);
     103    {
     104      POutPersist so("tts.ppf");
     105      so << vts;
     106    }
     107    cout << "ttimestamp/Info: Reading from tts.ppf " << endl;
     108    PInPersist si("tts.ppf");
     109   
     110    si >> vtsr;
     111    for(int kk=0; kk<vtsr.size(); kk++) {
     112      cout << " vtsr[" << kk << "] : " << vtsr[kk] << endl;
     113      diff = vtsr[kk].ToDays()-vts[kk].ToDays();
     114      if (fabs(diff) > 1.e-6) {
     115        cout << "ttimestamp/Erreur Diff   vtsr[kk]-vts[kk] : Rc+=32 " << endl;
     116        rc += 32;
     117      }
     118    }
     119    if (rc >= 32)
     120      cout << "ttimestamp/Info Pb Diffs vector<TimeStamp>/PPF (Rc="
     121           << rc << ")" << endl;
     122    else
     123      cout << "ttimestamp/Erreur  Diffs vector<TimeStamp>/PPF OK" << endl;
    52124  }
    53125  catch (PThrowable & exc) {
Note: See TracChangeset for help on using the changeset viewer.