source: Sophya/trunk/SophyaProg/Tests/tstsegdb.cc@ 2877

Last change on this file since 2877 was 2694, checked in by ansari, 20 years ago

ajout test operateur = pour SegDataBlock ds tstsegdb.cc - Reza 26/4/2005

File size: 3.7 KB
RevLine 
[2659]1#include "sopnamsp.h"
2#include "machdefs.h"
3#include <stdio.h>
4#include <stdlib.h>
5#include "math.h"
6#include <iostream>
7#include <string>
8
9#include <typeinfo>
10#include "timing.h"
11#include "histinit.h"
12#include "pexceptions.h"
13#include "segdatablock.h"
14#include "fiosegdb.h"
15#include "swsegdb.h"
16#include "ppfswapper.h"
17#include "ppfwrapstlv.h"
18
19/* Programme test des classes SegDataBlock<T> et son PPF writer */
20/* SwSegDataBlock<T> avec le swapper PPF */
21/* SOPHYA - R. Ansari (LAL) - Avril 2005 */
22
23int main(int narg, char* arg[])
24{
25 cout << " ---- Programme tstsegdb.cc ----- \n"
26 << " Test classe SegDataBlock<T> et SwSegDataBlock<T> " << endl;
27 int rc = 0;
28 try {
29 SophyaInit();
30
31 InitTim();
32 cout << "1/ Test SegDataBlock Creation,remplissage, impression (segi, ssegi, sgds" << endl;
33 SegDataBlock<int> segi;
34 segi.Extend();
35 cout << segi;
36
37 SegDataBlock<int> ssegi(segi);
38 segi = 432;
39 ssegi.Extend();
40 ssegi.Print(cout, 4, " , ");
41 SegDataBlock<string> sgds(5,3);
42 cout << sgds;
43 sgds[2] = "bonjour"; sgds[5] = "AAAA";
44 sgds[8] = "BbbBBbb";
45 sgds.Print(cout, 4, " ; ");
[2694]46 cout << "1.b/ Appel operateur copie : sgsdscp = sgds " << endl;
47 SegDataBlock<string> sgdscp;
48 sgdscp = sgds;
[2659]49 {
50 cout << "2/ Ecriture segi sgds et ssegi dans segdb.ppf " << endl;
51 POutPersist so("segdb.ppf");
52 so << segi << sgds << ssegi;
53 }
54 {
55 cout << "3/ Lecture depuis segdb.ppf et print " << endl;
56 SegDataBlock<int> rsd1, rsd2;
57 SegDataBlock<string> rsds;
58 PInPersist si("segdb.ppf");
59 si >> rsd1 >> rsds >> rsd2;
60 rsds.Print(cout, 4, " ; ");
61 cout << "4/ On modifie certains elements de rsd1 et on verifie le partage de reference en lecture" << endl;
62 for(int jj=0; jj<rsd1.Size(); jj += 9)
63 rsd1[jj] = 999;
64 rsd1.Print(cout, 4, " , ");
65 rsd2.Print(cout, 4, " , ");
66 }
67 cout << "5/ Test SwSegDataBlock<T> creation/remplissage " << endl;
68 int SWSEGSZ = 4;
69 {
70 cout << " Creation PPFDataSwapper<float> swout(so) avec swseg.ppf " << endl;
71 POutPersist so("swseg.ppf");
72 PPFDataSwapper<float> swout(so);
73 SwSegDataBlock<float> swsd(swout, SWSEGSZ, 3);
74 float * fp = swsd.GetSegment(0);
75 fp[0] = 6.54321; fp[1] = 65.4321; fp[2] = 654.321; fp[3] = 6543.21;
76 fp = swsd.GetSegment(1);
77 fp[0] = 2.56789; fp[1] = 25.6789; fp[2] = 256.789; fp[3] = 2567.89;
78 fp = swsd.GetSegment(2);
79 fp[0] = 12.567; fp[1] = 225.67; fp[2] = 3256.7; fp[3] = 42567.;
80 vector<int_8> tags = swsd.GetSwapPosTagTable();
81 so << tags;
82 }
83 {
84 cout << "6/ Creation PPFDataSwapper<float> avec lecture depuis swseg.ppf " << endl;
85 PInPersist si("swseg.ppf");
86 PPFDataSwapper<float> swin(si);
87 vector<int_8> tags;
88 si >> tags;
89 SwSegDataBlock<float> swsd(swin, tags, SWSEGSZ);
90 cout <<"7/ Recopie ds SegDataBlock<float> depuis SwSegDataBlock<float> et print" << endl;
91 SegDataBlock<float> segf,segf2;
92 segf = swsd;
93 segf.Print(cout, 4, " ");
94 segf2 = swsd;
95 segf2.Print(cout, 4, " ");
96 }
97
98 }
99 catch (PThrowable & exc) {
100 cerr << " tstsegdb.cc: Catched Exception (PThrowable)" << (string)typeid(exc).name()
101 << " - Msg= " << exc.Msg() << endl;
102 rc = 99;
103 }
104 catch (std::exception & e) {
105 cerr << " tstsegdb.cc: Catched std::xception "
106 << " - what()= " << e.what() << endl;
107 rc = 98;
108 }
109 catch (...) {
110 cerr << " tstsegdb.cc: some other exception (...) was caught ! " << endl;
111 rc = 97;
112 }
113 PrtTim("End tstsegdb " );
114 cout << " ---- Programme tstsegdb.cc - FIN (Rc=" << rc << ") --- " << endl;
115 return rc;
116}
Note: See TracBrowser for help on using the repository browser.