Ignore:
Timestamp:
Oct 17, 2009, 9:01:23 PM (15 years ago)
Author:
dkearney
Message:

updates for the rappture objects, object examples, and object apis. small fix for rpunits c interface to check string length. there should probably be more of these checks in the c interface, but units should also be rewritten. added folders to separate out octave2 and octave3 app-fermi examples

Location:
trunk/examples/objects
Files:
25 added
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/examples/objects/app-fermi/fermi4.cc

    r1566 r1581  
    2323    // create a rappture library from the file filePath
    2424    Rappture::Library lib(argv[1]);
     25    Rappture::Number *T;
    2526
    26     Rappture::Number T;
    2727    double Ef           = 0.0;
     28    double E            = 0.0;
    2829    double dE           = 0.0;
    2930    double kT           = 0.0;
    3031    double Emin         = 0.0;
    3132    double Emax         = 0.0;
     33    double f            = 0.0;
    3234    size_t nPts         = 200;
    33     double E[nPts];
    34     double f[nPts];
     35    double EArr[nPts];
     36    double fArr[nPts];
    3537
    3638    if (lib.error() != 0) {
    3739        // cannot open file or out of memory
    38         fprintf(stderr, lib.traceback());
     40        Rappture::Outcome o = lib.outcome();
     41        fprintf(stderr, "%s",o.context());
     42        fprintf(stderr, "%s",o.remark());
    3943        exit(lib.error());
    4044    }
    4145
    42     Rappture::connect(&lib,"temperature",&T);
    43     lib.value("Ef", &Ef, "units=eV");
     46    Rappture::connect(&lib,"temperature",T);
     47    lib.value("Ef", &Ef, 1, "units=eV");
    4448
    4549    if (lib.error() != 0) {
    4650        // there were errors while retrieving input data values
    4751        // dump the tracepack
    48         fprintf(stderr, lib.traceback());
     52        Rappture::Outcome o = lib.outcome();
     53        fprintf(stderr, "%s",o.context());
     54        fprintf(stderr, "%s",o.remark());
    4955        exit(lib.error());
    5056    }
     
    7177    // create a plot to add to the library
    7278    // plot is registered with lib upon object creation
    73     // p1->add(nPts,xArr,yArr,format,curveLabel,curveDesc);
     79    // p1.add(nPts,xArr,yArr,format,curveLabel,curveDesc);
    7480
    7581    Rappture::Plot p1(lib);
  • trunk/examples/objects/library/library.cc

    r1566 r1581  
    11#include <iostream>
    2 #include <errno.h>
    32#include "RpLibObj.h"
    43#include "RpInt.h"
    54#include "RpChain.h"
     5#include "RpTest.h"
    66
    77int library_0_0 ()
    88{
    9     const char *testdesc = "test creating library object";
     9    const char *testdesc = "test creating library object with loadFile()";
    1010    const char *testname = "library_0_0";
    1111    const char *filePath = "library_0_0_in.xml";
     
    1313
    1414    Rappture::Library lib;
     15
     16    lib.loadFile(filePath);
     17
     18    const char *expected = NULL;
     19
     20    readFile(filePath, &expected);
     21    const char *received = lib.xml();
     22
     23    retVal |= testStringVal(testname,testdesc,expected,received);
     24
     25    delete expected;
     26
     27    return retVal;
     28}
     29
     30int library_0_1 ()
     31{
     32    const char *testdesc = "test creating library object with loadXml()";
     33    const char *testname = "library_0_1";
     34    int retVal = 0;
     35
     36    Rappture::Library lib;
     37
     38    const char *buf =
     39"<?xml version=\"1.0\"?>\n\
     40<run>\n\
     41    <input>\n\
     42        <number id=\"Ef\">\n\
     43            <about>\n\
     44                <label>Fermi Level</label>\n\
     45                <description>Energy at center of distribution.</description>\n\
     46            </about>\n\
     47            <units>eV</units>\n\
     48            <min>-10eV</min>\n\
     49            <max>10eV</max>\n\
     50            <default>0eV</default>\n\
     51            <current>5eV</current>\n\
     52            <preset>\n\
     53                <label>300K (room temperature)</label>\n\
     54                <value>300K</value>\n\
     55            </preset>\n\
     56            <preset>\n\
     57                <label>77K (liquid nitrogen)</label>\n\
     58                <value>77K</value>\n\
     59            </preset>\n\
     60            <preset>\n\
     61                <label>4.2K (liquid helium)</label>\n\
     62                <value>4.2K</value>\n\
     63            </preset>\n\
     64        </number>\n\
     65    </input>\n\
     66</run>\n\
     67";
     68
     69    lib.loadXml(buf);
     70
     71    const char *expected = buf;
     72    const char *received = lib.xml();
     73
     74    retVal |= testStringVal(testname,testdesc,expected,received);
     75
     76    return retVal;
     77}
     78
     79int library_1_0 ()
     80{
     81    const char *testdesc = "test contains() function on empty library";
     82    const char *testname = "library_1_0";
     83    int retVal = 0;
     84
     85    Rappture::Library lib;
    1586    const Rp_Chain *contents = NULL;
    16 
    17     lib.loadFile(filePath);
    1887    contents = lib.contains();
    1988
    20     std::printf("lib contains %d item(s)\n", Rp_ChainGetLength(contents));
    21 
    22     return retVal;
    23 }
    24 
    25 int library_1_0 ()
    26 {
    27     const char *testdesc = "test creating library object";
    28     const char *testname = "library_1_0";
    29     const char *filePath = "library_0_0_in.xml";
     89    int expected = 0;
     90    int received = Rp_ChainGetLength(contents);
     91
     92    retVal |= testDoubleVal(testname,testdesc,expected,received);
     93
     94    return retVal;
     95}
     96
     97int library_1_1 ()
     98{
     99    const char *testdesc = "test contains() function on populated library";
     100    const char *testname = "library_1_1";
    30101    int retVal = 0;
    31102
    32103    Rappture::Library lib;
    33104    const Rp_Chain *contents = NULL;
    34 
    35     lib.loadFile(filePath);
    36 
    37     const char *xmltext = lib.xml();
    38     printf("xmltext = %s\n",xmltext);
    39 
    40     return retVal;
    41 }
    42 
    43 /*
    44 int number_0_1 ()
    45 {
    46     const char *testdesc = "test number constuctor";
    47     const char *testname = "number_0_0";
    48     int retVal = 0;
    49 
    50     const char *name = "eV";
    51     const char *units = "eV";
    52     double def = 1.4;
    53 
    54     Rappture::Number *n = NULL;
    55 
    56     n = new Rappture::Number(name,units,def);
    57 
    58     if (n == NULL) {
    59         printf("Error: %s\n", testname);
    60         printf("\t%s\n", testdesc);
    61         printf("\terror creating number object\n");
    62         retVal = 1;
    63     }
    64 
    65     retVal |= testStringVal(testname,testdesc,name,n->name());
    66     retVal |= testStringVal(testname,testdesc,units,n->units());
    67     retVal |= testDoubleVal(testname,testdesc,def,n->def());
    68 
    69     if (n != NULL) {
    70         delete n;
    71     }
    72 
    73     return retVal;
    74 }
    75 
    76 int number_1_0 ()
    77 {
    78     const char *testdesc = "test constructing number from xml";
    79     const char *testname = "number_1_0";
    80     const char *filePath = "number_1_0_in.xml";
    81     int retVal = 0;
    82 
    83     const char *buf = NULL;
    84     readFile(filePath,&buf);
    85 
    86     const char *name = "Ef";
    87     const char *units = "eV";
    88     double def = 0;
    89     double cur = 5;
    90     double min = -10;
    91     double max = 10;
    92     const char *label = "Fermi Level";
    93     const char *desc = "Energy at center of distribution.";
    94 
    95     Rappture::Number n;
    96 
    97     n.xml(buf);
    98 
    99     retVal |= testStringVal(testname,testdesc,name,n.name());
    100     retVal |= testStringVal(testname,testdesc,units,n.units());
    101     retVal |= testDoubleVal(testname,testdesc,def,n.def());
    102     retVal |= testDoubleVal(testname,testdesc,cur,n.cur());
    103     retVal |= testDoubleVal(testname,testdesc,min,n.min());
    104     retVal |= testDoubleVal(testname,testdesc,max,n.max());
    105     retVal |= testStringVal(testname,testdesc,label,n.label());
    106     retVal |= testStringVal(testname,testdesc,desc,n.desc());
    107 
    108     return retVal;
    109 }
    110 */
     105    const char *buf =
     106"<?xml version=\"1.0\"?>\
     107<run>\
     108    <input>\
     109        <number id=\"Ef\">\
     110            <about>\
     111                <label>Fermi Level</label>\
     112                <description>Energy at center of distribution.</description>\
     113            </about>\
     114            <units>eV</units>\
     115            <min>-10eV</min>\
     116            <max>10eV</max>\
     117            <default>0eV</default>\
     118            <current>5eV</current>\
     119            <preset>\
     120                <value>300K</value>\
     121                <label>300K (room temperature)</label>\
     122            </preset>\
     123            <preset>\
     124                <value>77K</value>\
     125                <label>77K (liquid nitrogen)</label>\
     126            </preset>\
     127            <preset>\
     128                <value>4.2K</value>\
     129                <label>4.2K (liquid helium)</label>\
     130            </preset>\
     131        </number>\
     132    </input>\
     133</run>";
     134
     135    lib.loadXml(buf);
     136    contents = lib.contains();
     137
     138    int expected = 1;
     139    int received = Rp_ChainGetLength(contents);
     140
     141    retVal |= testDoubleVal(testname,testdesc,expected,received);
     142
     143    return retVal;
     144}
     145
     146int library_2_0 ()
     147{
     148    const char *testdesc = "test value(), 0 hints";
     149    const char *testname = "library_2_0";
     150    int retVal = 0;
     151
     152    Rappture::Library lib;
     153    const char *buf =
     154"<?xml version=\"1.0\"?>\
     155<run>\
     156    <input>\
     157        <number id=\"temperature\">\
     158            <about>\
     159                <label>Ambient temperature</label>\
     160                <description>Temperature of the environment.</description>\
     161            </about>\
     162            <units>K</units>\
     163            <min>0K</min>\
     164            <max>500K</max>\
     165            <default>300K</default>\
     166        </number>\
     167        <number id=\"Ef\">\
     168            <about>\
     169                <label>Fermi Level</label>\
     170                <description>Energy at center of distribution.</description>\
     171            </about>\
     172            <units>eV</units>\
     173            <min>-10eV</min>\
     174            <max>10eV</max>\
     175            <default>4eV</default>\
     176        </number>\
     177    </input>\
     178</run>";
     179
     180    lib.loadXml(buf);
     181
     182    double expected = 4.0;
     183    double received = 0.0;
     184    lib.value("Ef",&received,0);
     185
     186    retVal |= testDoubleVal(testname,testdesc,expected,received);
     187
     188    return retVal;
     189}
     190
     191int library_2_1 ()
     192{
     193    const char *testdesc = "test value(), 1 hint, units=eV";
     194    const char *testname = "library_2_1";
     195    int retVal = 0;
     196
     197    Rappture::Library lib;
     198    const char *buf =
     199"<?xml version=\"1.0\"?>\
     200<run>\
     201    <input>\
     202        <number id=\"temperature\">\
     203            <about>\
     204                <label>Ambient temperature</label>\
     205                <description>Temperature of the environment.</description>\
     206            </about>\
     207            <units>K</units>\
     208            <min>0K</min>\
     209            <max>500K</max>\
     210            <default>300K</default>\
     211        </number>\
     212        <number id=\"Ef\">\
     213            <about>\
     214                <label>Fermi Level</label>\
     215                <description>Energy at center of distribution.</description>\
     216            </about>\
     217            <units>eV</units>\
     218            <min>-10eV</min>\
     219            <max>10eV</max>\
     220            <default>4eV</default>\
     221        </number>\
     222    </input>\
     223</run>";
     224
     225    lib.loadXml(buf);
     226
     227    double expected = 4.0;
     228    double received = 0.0;
     229    lib.value("Ef",&received,1,"units=eV");
     230
     231    retVal |= testDoubleVal(testname,testdesc,expected,received);
     232
     233    return retVal;
     234}
     235
     236int library_2_2 ()
     237{
     238    const char *testdesc = "test value(), 1 hint, units=J";
     239    const char *testname = "library_2_2";
     240    int retVal = 0;
     241
     242    Rappture::Library lib;
     243    const char *buf =
     244"<?xml version=\"1.0\"?>\
     245<run>\
     246    <input>\
     247        <number id=\"temperature\">\
     248            <about>\
     249                <label>Ambient temperature</label>\
     250                <description>Temperature of the environment.</description>\
     251            </about>\
     252            <units>K</units>\
     253            <min>0K</min>\
     254            <max>500K</max>\
     255            <default>300K</default>\
     256        </number>\
     257        <number id=\"Ef\">\
     258            <about>\
     259                <label>Fermi Level</label>\
     260                <description>Energy at center of distribution.</description>\
     261            </about>\
     262            <units>eV</units>\
     263            <min>-10eV</min>\
     264            <max>10eV</max>\
     265            <default>4eV</default>\
     266        </number>\
     267    </input>\
     268</run>";
     269
     270    lib.loadXml(buf);
     271
     272    // double expected = 6.40871e-19;
     273    double expected = 4*1.602177e-19;
     274    double received = 0.0;
     275    lib.value("Ef",&received,1,"units=J");
     276
     277    retVal |= testDoubleVal(testname,testdesc,expected,received);
     278
     279    return retVal;
     280}
     281
     282int library_2_3 ()
     283{
     284    const char *testdesc = "test value(), object does not exist";
     285    const char *testname = "library_2_3";
     286    int retVal = 0;
     287
     288    Rappture::Library lib;
     289    const char *buf =
     290"<?xml version=\"1.0\"?>\
     291<run>\
     292    <input>\
     293        <number id=\"temperature\">\
     294            <about>\
     295                <label>Ambient temperature</label>\
     296                <description>Temperature of the environment.</description>\
     297            </about>\
     298            <units>K</units>\
     299            <min>0K</min>\
     300            <max>500K</max>\
     301            <default>300K</default>\
     302        </number>\
     303        <number id=\"Ef\">\
     304            <about>\
     305                <label>Fermi Level</label>\
     306                <description>Energy at center of distribution.</description>\
     307            </about>\
     308            <units>eV</units>\
     309            <min>-10eV</min>\
     310            <max>10eV</max>\
     311            <default>4eV</default>\
     312        </number>\
     313    </input>\
     314</run>";
     315
     316    lib.loadXml(buf);
     317
     318    // library should not change the value of received
     319    // if it cannot find the requested object
     320    double expected = -101.01;
     321    double received = -101.01;
     322    lib.value("EF",&received,1,"units=J");
     323
     324    retVal |= testDoubleVal(testname,testdesc,1,lib.error());
     325    retVal |= testDoubleVal(testname,testdesc,expected,received);
     326
     327    return retVal;
     328}
    111329
    112330int main()
    113331{
    114332    library_0_0();
    115     // library_0_1();
     333    library_0_1();
    116334    library_1_0();
     335    library_2_0();
     336    library_2_1();
     337    library_2_2();
     338    library_2_3();
    117339
    118340    return 0;
  • trunk/examples/objects/library/library_0_0_in.xml

    r1566 r1581  
    1313            <current>5eV</current>
    1414            <preset>
     15                <label>300K (room temperature)</label>
    1516                <value>300K</value>
    16                 <label>300K (room temperature)</label>
    1717            </preset>
    1818            <preset>
     19                <label>77K (liquid nitrogen)</label>
    1920                <value>77K</value>
    20                 <label>77K (liquid nitrogen)</label>
    2121            </preset>
    2222            <preset>
     23                <label>4.2K (liquid helium)</label>
    2324                <value>4.2K</value>
    24                 <label>4.2K (liquid helium)</label>
    2525            </preset>
    2626        </number>
  • trunk/examples/objects/number/Makefile.in

    r1560 r1581  
    3434FILES   = \
    3535                $(srcdir)/number.cc \
    36                 $(srcdir)/number_1_0_in.xml \
    3736                Makefile
    3837
  • trunk/examples/objects/number/number.cc

    r1566 r1581  
    11#include <iostream>
    2 #include <errno.h>
    3 #include <fstream>
    4 #include <sys/stat.h>
    52#include "RpNumber.h"
    6 
    7 size_t indent = 0;
    8 size_t tabstop = 4;
     3#include "RpTest.h"
    94
    105int
     
    2419}
    2520
    26 int testStringVal(
    27     const char *testname,
    28     const char *desc,
    29     const char *expected,
    30     const char *received)
    31 {
    32     if ((!expected && received) ||
    33         (expected && !received) ||
    34         (expected && received && strcmp(expected,received) != 0)) {
    35         printf("Error: %s\n", testname);
    36         printf("\t%s\n", desc);
    37         printf("\texpected \"%s\"\n",expected);
    38         printf("\treceived \"%s\"\n",received);
    39         return 1;
    40     }
    41     return 0;
    42 }
    43 
    44 int testDoubleVal(
    45     const char *testname,
    46     const char *desc,
    47     double expected,
    48     double received)
    49 {
    50     if (expected != received) {
    51         printf("Error: %s\n", testname);
    52         printf("\t%s\n", desc);
    53         printf("\texpected \"%g\"\n",expected);
    54         printf("\treceived \"%g\"\n",received);
    55         return 1;
    56     }
    57     return 0;
    58 }
    59 
    60 size_t
    61 readFile (
    62     const char *filePath,
    63     const char **buf)
    64 {
    65     if (buf == NULL) {
    66         fprintf(stderr,"buf is NULL while opening file \"%s\"", filePath);
    67         return 0;
    68     }
    69 
    70     FILE *f;
    71     f = fopen(filePath, "rb");
    72     if (f == NULL) {
    73         fprintf(stderr,"can't open \"%s\": %s", filePath, strerror(errno));
    74         return 0;
    75     }
    76     struct stat stat;
    77     if (fstat(fileno(f), &stat) < 0) {
    78         fprintf(stderr,"can't stat \"%s\": %s", filePath, strerror(errno));
    79         return 0;
    80     }
    81     off_t size;
    82     size = stat.st_size;
    83     char* memblock;
    84     memblock = new char [size+1];
    85     if (memblock == NULL) {
    86         fprintf(stderr,"can't allocate %zu bytes for file \"%s\": %s",
    87             (size_t)size, filePath, strerror(errno));
    88         fclose(f);
    89         return 0;
    90     }
    91 
    92     size_t nRead;
    93     nRead = fread(memblock, sizeof(char), size, f);
    94     fclose(f);
    95 
    96     if (nRead != (size_t)size) {
    97         fprintf(stderr,"can't read %zu bytes from \"%s\": %s",
    98             (size_t) size, filePath, strerror(errno));
    99         return 0;
    100     }
    101 
    102     memblock[size] = '\0';
    103     *buf = memblock;
    104     return nRead;
    105 }
    10621int number_0_0 ()
    10722{
     
    18095    const char *testdesc = "test constructing number from xml";
    18196    const char *testname = "number_1_0";
    182     const char *filePath = "number_1_0_in.xml";
    183     int retVal = 0;
    184 
    185     const char *buf = NULL;
    186     readFile(filePath,&buf);
    187 
    188     const char *name = "Ef";
    189     const char *units = "eV";
    190     double def = 0;
    191     double cur = 5;
    192     double min = -10;
    193     double max = 10;
     97    int retVal = 0;
     98
     99    const char *buf =
     100"<?xml version=\"1.0\"?>\
     101<number id=\"Ef\">\
     102    <about>\
     103        <label>Fermi Level</label>\
     104        <description>Energy at center of distribution.</description>\
     105    </about>\
     106    <units>eV</units>\
     107    <min>-10eV</min>\
     108    <max>10eV</max>\
     109    <default>0eV</default>\
     110    <current>5eV</current>\
     111    <preset>\
     112        <value>300K</value>\
     113        <label>300K (room temperature)</label>\
     114    </preset>\
     115    <preset>\
     116        <value>77K</value>\
     117        <label>77K (liquid nitrogen)</label>\
     118    </preset>\
     119    <preset>\
     120        <value>4.2K</value>\
     121        <label>4.2K (liquid helium)</label>\
     122    </preset>\
     123</number>";
     124
     125    const char *name = "Ef";
     126    const char *units = "eV";
     127    double def = 0;
     128    double cur = 5;
     129    double min = -10;
     130    double max = 10;
     131    const char *label = "Fermi Level";
     132    const char *desc = "Energy at center of distribution.";
     133
     134    Rappture::Number n;
     135
     136    n.configure(Rappture::RPCONFIG_XML,(void*)buf);
     137
     138    retVal |= testStringVal(testname,testdesc,name,n.name());
     139    retVal |= testStringVal(testname,testdesc,units,n.units());
     140    retVal |= testDoubleVal(testname,testdesc,def,n.def());
     141    retVal |= testDoubleVal(testname,testdesc,cur,n.cur());
     142    if (n.minset()) {
     143        retVal |= testDoubleVal(testname,testdesc,min,n.min());
     144    }
     145    if (n.maxset()) {
     146        retVal |= testDoubleVal(testname,testdesc,max,n.max());
     147    }
     148    retVal |= testStringVal(testname,testdesc,label,n.label());
     149    retVal |= testStringVal(testname,testdesc,desc,n.desc());
     150
     151    return retVal;
     152}
     153
     154int number_1_1 ()
     155{
     156    const char *testdesc = "test constructing number from xml, no min";
     157    const char *testname = "number_1_1";
     158    int retVal = 0;
     159
     160    const char *buf =
     161"<?xml version=\"1.0\"?>\
     162<number id=\"Ef\">\
     163    <about>\
     164        <label>Fermi Level</label>\
     165        <description>Energy at center of distribution.</description>\
     166    </about>\
     167    <units>eV</units>\
     168    <max>10eV</max>\
     169    <default>0eV</default>\
     170    <current>5eV</current>\
     171</number>";
     172
     173    const char *name = "Ef";
     174    const char *units = "eV";
     175    double def = 0;
     176    double cur = 5;
     177    double min = -10;
     178    double max = 10;
     179    const char *label = "Fermi Level";
     180    const char *desc = "Energy at center of distribution.";
     181
     182    Rappture::Number n;
     183
     184    n.configure(Rappture::RPCONFIG_XML,(void*)buf);
     185
     186    retVal |= testStringVal(testname,testdesc,name,n.name());
     187    retVal |= testStringVal(testname,testdesc,units,n.units());
     188    retVal |= testDoubleVal(testname,testdesc,def,n.def());
     189    retVal |= testDoubleVal(testname,testdesc,cur,n.cur());
     190    if (n.minset()) {
     191        retVal |= testDoubleVal(testname,testdesc,min,n.min());
     192    }
     193    if (n.maxset()) {
     194        retVal |= testDoubleVal(testname,testdesc,max,n.max());
     195    }
     196    retVal |= testStringVal(testname,testdesc,label,n.label());
     197    retVal |= testStringVal(testname,testdesc,desc,n.desc());
     198
     199    return retVal;
     200}
     201
     202int number_1_2 ()
     203{
     204    const char *testdesc = "test constructing number from xml, no max";
     205    const char *testname = "number_1_2";
     206    int retVal = 0;
     207
     208    const char *buf =
     209"<?xml version=\"1.0\"?>\
     210<number id=\"Ef\">\
     211    <about>\
     212        <label>Fermi Level</label>\
     213        <description>Energy at center of distribution.</description>\
     214    </about>\
     215    <units>eV</units>\
     216    <min>-10eV</min>\
     217    <default>0eV</default>\
     218    <current>5eV</current>\
     219</number>";
     220
     221
     222    const char *name = "Ef";
     223    const char *units = "eV";
     224    double def = 0;
     225    double cur = 5;
     226    double min = -10;
     227    double max = 10;
     228    const char *label = "Fermi Level";
     229    const char *desc = "Energy at center of distribution.";
     230
     231    Rappture::Number n;
     232
     233    n.configure(Rappture::RPCONFIG_XML,(void*)buf);
     234
     235    retVal |= testStringVal(testname,testdesc,name,n.name());
     236    retVal |= testStringVal(testname,testdesc,units,n.units());
     237    retVal |= testDoubleVal(testname,testdesc,def,n.def());
     238    retVal |= testDoubleVal(testname,testdesc,cur,n.cur());
     239    if (n.minset()) {
     240        retVal |= testDoubleVal(testname,testdesc,min,n.min());
     241    }
     242    if (n.maxset()) {
     243        retVal |= testDoubleVal(testname,testdesc,max,n.max());
     244    }
     245    retVal |= testStringVal(testname,testdesc,label,n.label());
     246    retVal |= testStringVal(testname,testdesc,desc,n.desc());
     247
     248    return retVal;
     249}
     250
     251int number_1_3 ()
     252{
     253    const char *testdesc = "test constructing number from xml, no min, no max";
     254    const char *testname = "number_1_3";
     255    int retVal = 0;
     256
     257    const char *buf =
     258"<?xml version=\"1.0\"?>\
     259<number id=\"Ef\">\
     260    <about>\
     261        <label>Fermi Level</label>\
     262        <description>Energy at center of distribution.</description>\
     263    </about>\
     264    <units>eV</units>\
     265    <default>0eV</default>\
     266    <current>5eV</current>\
     267</number>";
     268
     269
     270    const char *name = "Ef";
     271    const char *units = "eV";
     272    double def = 0;
     273    double cur = 5;
     274    double min = -10;
     275    double max = 10;
     276    const char *label = "Fermi Level";
     277    const char *desc = "Energy at center of distribution.";
     278
     279    Rappture::Number n;
     280
     281    n.configure(Rappture::RPCONFIG_XML,(void*)buf);
     282
     283    retVal |= testStringVal(testname,testdesc,name,n.name());
     284    retVal |= testStringVal(testname,testdesc,units,n.units());
     285    retVal |= testDoubleVal(testname,testdesc,def,n.def());
     286    retVal |= testDoubleVal(testname,testdesc,cur,n.cur());
     287    if (n.minset()) {
     288        retVal |= testDoubleVal(testname,testdesc,min,n.min());
     289    }
     290    if (n.maxset()) {
     291        retVal |= testDoubleVal(testname,testdesc,max,n.max());
     292    }
     293    retVal |= testStringVal(testname,testdesc,label,n.label());
     294    retVal |= testStringVal(testname,testdesc,desc,n.desc());
     295
     296    return retVal;
     297}
     298
     299int number_1_4 ()
     300{
     301    const char *testdesc = "test constructing number from xml, no cur";
     302    const char *testname = "number_1_4";
     303    int retVal = 0;
     304
     305    const char *buf =
     306"<?xml version=\"1.0\"?>\
     307<number id=\"Ef\">\
     308    <about>\
     309        <label>Fermi Level</label>\
     310        <description>Energy at center of distribution.</description>\
     311    </about>\
     312    <units>eV</units>\
     313    <min>-10eV</min>\
     314    <max>10eV</max>\
     315    <default>0eV</default>\
     316</number>";
     317
     318
     319    const char *name = "Ef";
     320    const char *units = "eV";
     321    double def = 0;
     322    double cur = 0;
     323    double min = -10;
     324    double max = 10;
     325    const char *label = "Fermi Level";
     326    const char *desc = "Energy at center of distribution.";
     327
     328    Rappture::Number n;
     329
     330    n.configure(Rappture::RPCONFIG_XML,(void*)buf);
     331
     332    retVal |= testStringVal(testname,testdesc,name,n.name());
     333    retVal |= testStringVal(testname,testdesc,units,n.units());
     334    retVal |= testDoubleVal(testname,testdesc,def,n.def());
     335    // if no current value is provided it defaults to 0.0.
     336    retVal |= testDoubleVal(testname,testdesc,cur,n.cur());
     337    if (n.minset()) {
     338        retVal |= testDoubleVal(testname,testdesc,min,n.min());
     339    }
     340    if (n.maxset()) {
     341        retVal |= testDoubleVal(testname,testdesc,max,n.max());
     342    }
     343    retVal |= testStringVal(testname,testdesc,label,n.label());
     344    retVal |= testStringVal(testname,testdesc,desc,n.desc());
     345
     346    return retVal;
     347}
     348
     349int number_1_5 ()
     350{
     351    const char *testdesc = "test constructing number from xml, no def";
     352    const char *testname = "number_1_5";
     353    int retVal = 0;
     354
     355    const char *buf =
     356"<?xml version=\"1.0\"?>\
     357<number id=\"Ef\">\
     358    <about>\
     359        <label>Fermi Level</label>\
     360        <description>Energy at center of distribution.</description>\
     361    </about>\
     362    <units>eV</units>\
     363    <min>-10eV</min>\
     364    <max>10eV</max>\
     365    <current>5eV</current>\
     366</number>";
     367
     368
     369    const char *name = "Ef";
     370    const char *units = "eV";
     371    double def = 0;
     372    double cur = 5;
     373    double min = -10;
     374    double max = 10;
     375    const char *label = "Fermi Level";
     376    const char *desc = "Energy at center of distribution.";
     377
     378    Rappture::Number n;
     379
     380    n.configure(Rappture::RPCONFIG_XML,(void*)buf);
     381
     382    retVal |= testStringVal(testname,testdesc,name,n.name());
     383    retVal |= testStringVal(testname,testdesc,units,n.units());
     384    // if no default value is provided it defaults to 0.0.
     385    retVal |= testDoubleVal(testname,testdesc,def,n.def());
     386    retVal |= testDoubleVal(testname,testdesc,cur,n.cur());
     387    if (n.minset()) {
     388        retVal |= testDoubleVal(testname,testdesc,min,n.min());
     389    }
     390    if (n.maxset()) {
     391        retVal |= testDoubleVal(testname,testdesc,max,n.max());
     392    }
     393    retVal |= testStringVal(testname,testdesc,label,n.label());
     394    retVal |= testStringVal(testname,testdesc,desc,n.desc());
     395
     396    return retVal;
     397}
     398
     399int number_1_6 ()
     400{
     401    const char *testdesc = "test constructing number from xml, no def, no cur";
     402    const char *testname = "number_1_6";
     403    int retVal = 0;
     404
     405    const char *buf =
     406"<?xml version=\"1.0\"?>\
     407<number id=\"Ef\">\
     408    <about>\
     409        <label>Fermi Level</label>\
     410        <description>Energy at center of distribution.</description>\
     411    </about>\
     412    <units>eV</units>\
     413    <min>-10eV</min>\
     414    <max>10eV</max>\
     415</number>";
     416
     417
     418    const char *name = "Ef";
     419    const char *units = "eV";
     420    double def = 0;
     421    double cur = 0;
     422    double min = -10;
     423    double max = 10;
     424    const char *label = "Fermi Level";
     425    const char *desc = "Energy at center of distribution.";
     426
     427    Rappture::Number n;
     428
     429    n.configure(Rappture::RPCONFIG_XML,(void*)buf);
     430
     431    retVal |= testStringVal(testname,testdesc,name,n.name());
     432    retVal |= testStringVal(testname,testdesc,units,n.units());
     433    retVal |= testDoubleVal(testname,testdesc,def,n.def());
     434    retVal |= testDoubleVal(testname,testdesc,cur,n.cur());
     435    if (n.minset()) {
     436        retVal |= testDoubleVal(testname,testdesc,min,n.min());
     437    }
     438    if (n.maxset()) {
     439        retVal |= testDoubleVal(testname,testdesc,max,n.max());
     440    }
     441    retVal |= testStringVal(testname,testdesc,label,n.label());
     442    retVal |= testStringVal(testname,testdesc,desc,n.desc());
     443
     444    return retVal;
     445}
     446
     447int number_1_7 ()
     448{
     449    const char *testdesc = "test constructing number from xml, no def cur min max";
     450    const char *testname = "number_1_7";
     451    int retVal = 0;
     452
     453    const char *buf =
     454"<?xml version=\"1.0\"?>\
     455<number id=\"Ef\">\
     456    <about>\
     457        <label>Fermi Level</label>\
     458        <description>Energy at center of distribution.</description>\
     459    </about>\
     460    <units>eV</units>\
     461</number>";
     462
     463
     464    const char *name = "Ef";
     465    const char *units = "eV";
     466    double def = 0;
     467    double cur = 0;
     468    double min = 0;
     469    double max = 0;
    194470    const char *label = "Fermi Level";
    195471    const char *desc = "Energy at center of distribution.";
     
    210486    return retVal;
    211487}
     488
     489int number_1_8 ()
     490{
     491    const char *testdesc = "test constructing number from xml, no explicit units";
     492    const char *testname = "number_1_8";
     493    int retVal = 0;
     494
     495    const char *buf =
     496"<?xml version=\"1.0\"?>\
     497<number id=\"Ef\">\
     498    <about>\
     499        <label>Fermi Level</label>\
     500        <description>Energy at center of distribution.</description>\
     501    </about>\
     502    <min>-10eV</min>\
     503    <max>10eV</max>\
     504    <default>0eV</default>\
     505    <current>5eV</current>\
     506</number>";
     507
     508    const char *name = "Ef";
     509    const char *units = "eV";
     510    double def = 0;
     511    double cur = 5;
     512    double min = -10;
     513    double max = 10;
     514    const char *label = "Fermi Level";
     515    const char *desc = "Energy at center of distribution.";
     516
     517    Rappture::Number n;
     518
     519    n.configure(Rappture::RPCONFIG_XML,(void*)buf);
     520
     521    retVal |= testStringVal(testname,testdesc,name,n.name());
     522    // units are implied from min, max, def, cur values
     523    retVal |= testStringVal(testname,testdesc,units,n.units());
     524    retVal |= testDoubleVal(testname,testdesc,def,n.def());
     525    retVal |= testDoubleVal(testname,testdesc,cur,n.cur());
     526    if (n.minset()) {
     527        retVal |= testDoubleVal(testname,testdesc,min,n.min());
     528    }
     529    if (n.maxset()) {
     530        retVal |= testDoubleVal(testname,testdesc,max,n.max());
     531    }
     532    retVal |= testStringVal(testname,testdesc,label,n.label());
     533    retVal |= testStringVal(testname,testdesc,desc,n.desc());
     534
     535    return retVal;
     536}
     537
     538int number_1_9 ()
     539{
     540    const char *testdesc = "test constructing number from xml, no description";
     541    const char *testname = "number_1_9";
     542    int retVal = 0;
     543
     544    const char *buf =
     545"<?xml version=\"1.0\"?>\
     546<number id=\"Ef\">\
     547    <about>\
     548        <label>Fermi Level</label>\
     549    </about>\
     550    <units>eV</units>\
     551    <min>-10eV</min>\
     552    <max>10eV</max>\
     553    <default>0eV</default>\
     554    <current>5eV</current>\
     555</number>";
     556
     557    const char *name = "Ef";
     558    const char *units = "eV";
     559    double def = 0;
     560    double cur = 5;
     561    double min = -10;
     562    double max = 10;
     563    const char *label = "Fermi Level";
     564    const char *desc = "";
     565
     566    Rappture::Number n;
     567
     568    n.configure(Rappture::RPCONFIG_XML,(void*)buf);
     569
     570    retVal |= testStringVal(testname,testdesc,name,n.name());
     571    retVal |= testStringVal(testname,testdesc,units,n.units());
     572    retVal |= testDoubleVal(testname,testdesc,def,n.def());
     573    retVal |= testDoubleVal(testname,testdesc,cur,n.cur());
     574    if (n.minset()) {
     575        retVal |= testDoubleVal(testname,testdesc,min,n.min());
     576    }
     577    if (n.maxset()) {
     578        retVal |= testDoubleVal(testname,testdesc,max,n.max());
     579    }
     580    retVal |= testStringVal(testname,testdesc,label,n.label());
     581    retVal |= testStringVal(testname,testdesc,desc,n.desc());
     582
     583    return retVal;
     584}
     585
     586int number_1_10 ()
     587{
     588    const char *testdesc = "test constructing number from xml, no label";
     589    const char *testname = "number_1_10";
     590    int retVal = 0;
     591
     592    const char *buf =
     593"<?xml version=\"1.0\"?>\
     594<number id=\"Ef\">\
     595    <about>\
     596        <description>Energy at center of distribution.</description>\
     597    </about>\
     598    <units>eV</units>\
     599    <min>-10eV</min>\
     600    <max>10eV</max>\
     601    <default>0eV</default>\
     602    <current>5eV</current>\
     603</number>";
     604
     605    const char *name = "Ef";
     606    const char *units = "eV";
     607    double def = 0;
     608    double cur = 5;
     609    double min = -10;
     610    double max = 10;
     611    const char *label = "";
     612    const char *desc = "Energy at center of distribution.";
     613
     614    Rappture::Number n;
     615
     616    n.configure(Rappture::RPCONFIG_XML,(void*)buf);
     617
     618    retVal |= testStringVal(testname,testdesc,name,n.name());
     619    retVal |= testStringVal(testname,testdesc,units,n.units());
     620    retVal |= testDoubleVal(testname,testdesc,def,n.def());
     621    retVal |= testDoubleVal(testname,testdesc,cur,n.cur());
     622    if (n.minset()) {
     623        retVal |= testDoubleVal(testname,testdesc,min,n.min());
     624    }
     625    if (n.maxset()) {
     626        retVal |= testDoubleVal(testname,testdesc,max,n.max());
     627    }
     628    retVal |= testStringVal(testname,testdesc,label,n.label());
     629    retVal |= testStringVal(testname,testdesc,desc,n.desc());
     630
     631    return retVal;
     632}
     633
     634int number_1_11 ()
     635{
     636    const char *testdesc = "test constructing number from xml, no label description";
     637    const char *testname = "number_1_11";
     638    int retVal = 0;
     639
     640    const char *buf =
     641"<?xml version=\"1.0\"?>\
     642<number id=\"Ef\">\
     643    <about>\
     644    </about>\
     645    <units>eV</units>\
     646    <min>-10eV</min>\
     647    <max>10eV</max>\
     648    <default>0eV</default>\
     649    <current>5eV</current>\
     650</number>";
     651
     652    const char *name = "Ef";
     653    const char *units = "eV";
     654    double def = 0;
     655    double cur = 5;
     656    double min = -10;
     657    double max = 10;
     658    const char *label = "";
     659    const char *desc = "";
     660
     661    Rappture::Number n;
     662
     663    n.configure(Rappture::RPCONFIG_XML,(void*)buf);
     664
     665    retVal |= testStringVal(testname,testdesc,name,n.name());
     666    retVal |= testStringVal(testname,testdesc,units,n.units());
     667    // if no default value and no current value is provided
     668    // both default to 0.0.
     669    retVal |= testDoubleVal(testname,testdesc,def,n.def());
     670    retVal |= testDoubleVal(testname,testdesc,cur,n.cur());
     671    retVal |= testDoubleVal(testname,testdesc,min,n.min());
     672    retVal |= testDoubleVal(testname,testdesc,max,n.max());
     673    retVal |= testStringVal(testname,testdesc,label,n.label());
     674    retVal |= testStringVal(testname,testdesc,desc,n.desc());
     675
     676    return retVal;
     677}
     678
     679int number_1_12 ()
     680{
     681    const char *testdesc = "test constructing number from xml, no about label description";
     682    const char *testname = "number_1_12";
     683    int retVal = 0;
     684
     685    const char *buf =
     686"<?xml version=\"1.0\"?>\
     687<number id=\"Ef\">\
     688    <units>eV</units>\
     689    <min>-10eV</min>\
     690    <max>10eV</max>\
     691    <default>0eV</default>\
     692    <current>5eV</current>\
     693</number>";
     694
     695    const char *name = "Ef";
     696    const char *units = "eV";
     697    double def = 0;
     698    double cur = 5;
     699    double min = -10;
     700    double max = 10;
     701    const char *label = "";
     702    const char *desc = "";
     703
     704    Rappture::Number n;
     705
     706    n.configure(Rappture::RPCONFIG_XML,(void*)buf);
     707
     708    retVal |= testStringVal(testname,testdesc,name,n.name());
     709    retVal |= testStringVal(testname,testdesc,units,n.units());
     710    // if no default value and no current value is provided
     711    // both default to 0.0.
     712    retVal |= testDoubleVal(testname,testdesc,def,n.def());
     713    retVal |= testDoubleVal(testname,testdesc,cur,n.cur());
     714    retVal |= testDoubleVal(testname,testdesc,min,n.min());
     715    retVal |= testDoubleVal(testname,testdesc,max,n.max());
     716    retVal |= testStringVal(testname,testdesc,label,n.label());
     717    retVal |= testStringVal(testname,testdesc,desc,n.desc());
     718
     719    return retVal;
     720}
     721
     722int number_1_13 ()
     723{
     724    const char *testdesc = "test constructing number from xml, no def cur min max units";
     725    const char *testname = "number_1_13";
     726    int retVal = 0;
     727
     728    const char *buf =
     729"<?xml version=\"1.0\"?>\
     730<number id=\"Ef\">\
     731    <about>\
     732        <label>Fermi Level</label>\
     733        <description>Energy at center of distribution.</description>\
     734    </about>\
     735</number>";
     736
     737
     738    const char *name = "Ef";
     739    const char *units = NULL;
     740    double def = 0;
     741    double cur = 0;
     742    double min = 0;
     743    double max = 0;
     744    const char *label = "Fermi Level";
     745    const char *desc = "Energy at center of distribution.";
     746
     747    Rappture::Number n;
     748
     749    n.configure(Rappture::RPCONFIG_XML,(void*)buf);
     750
     751    retVal |= testStringVal(testname,testdesc,name,n.name());
     752    retVal |= testStringVal(testname,testdesc,units,n.units());
     753    // if no default value and no current value is provided
     754    // both default to 0.0.
     755    retVal |= testDoubleVal(testname,testdesc,def,n.def());
     756    retVal |= testDoubleVal(testname,testdesc,cur,n.cur());
     757    retVal |= testDoubleVal(testname,testdesc,min,n.min());
     758    retVal |= testDoubleVal(testname,testdesc,max,n.max());
     759    retVal |= testStringVal(testname,testdesc,label,n.label());
     760    retVal |= testStringVal(testname,testdesc,desc,n.desc());
     761
     762    return retVal;
     763}
     764
     765int number_1_14 ()
     766{
     767    const char *testdesc = "test constructing number from xml, only name";
     768    const char *testname = "number_1_14";
     769    int retVal = 0;
     770
     771    const char *buf =
     772"<?xml version=\"1.0\"?>\
     773<number id=\"Ef\">\
     774</number>";
     775
     776
     777    const char *name = "Ef";
     778    const char *units = NULL;
     779    double def = 0;
     780    double cur = 0;
     781    double min = 0;
     782    double max = 0;
     783    const char *label = "";
     784    const char *desc = "";
     785
     786    Rappture::Number n;
     787
     788    n.configure(Rappture::RPCONFIG_XML,(void*)buf);
     789
     790    retVal |= testStringVal(testname,testdesc,name,n.name());
     791    retVal |= testStringVal(testname,testdesc,units,n.units());
     792    retVal |= testDoubleVal(testname,testdesc,def,n.def());
     793    retVal |= testDoubleVal(testname,testdesc,cur,n.cur());
     794    retVal |= testDoubleVal(testname,testdesc,min,n.min());
     795    retVal |= testDoubleVal(testname,testdesc,max,n.max());
     796    retVal |= testStringVal(testname,testdesc,label,n.label());
     797    retVal |= testStringVal(testname,testdesc,desc,n.desc());
     798
     799    return retVal;
     800}
     801
     802int number_1_15 ()
     803{
     804    const char *testdesc = "test constructing number from xml, no info";
     805    const char *testname = "number_1_15";
     806    int retVal = 0;
     807
     808    const char *buf =
     809"<?xml version=\"1.0\"?>\
     810<number>\
     811</number>";
     812
     813
     814    const char *name = "";
     815    const char *units = NULL;
     816    double def = 0;
     817    double cur = 0;
     818    double min = 0;
     819    double max = 0;
     820    const char *label = "";
     821    const char *desc = "";
     822
     823    Rappture::Number n;
     824
     825    n.configure(Rappture::RPCONFIG_XML,(void*)buf);
     826
     827    retVal |= testStringVal(testname,testdesc,name,n.name());
     828    retVal |= testStringVal(testname,testdesc,units,n.units());
     829    retVal |= testDoubleVal(testname,testdesc,def,n.def());
     830    retVal |= testDoubleVal(testname,testdesc,cur,n.cur());
     831    retVal |= testDoubleVal(testname,testdesc,min,n.min());
     832    retVal |= testDoubleVal(testname,testdesc,max,n.max());
     833    retVal |= testStringVal(testname,testdesc,label,n.label());
     834    retVal |= testStringVal(testname,testdesc,desc,n.desc());
     835
     836    return retVal;
     837}
     838
     839int number_1_16 ()
     840{
     841    const char *testdesc = "test constructing number from xml, no explicit or implied units";
     842    const char *testname = "number_1_16";
     843    int retVal = 0;
     844
     845    const char *buf =
     846"<?xml version=\"1.0\"?>\
     847<number id=\"Ef\">\
     848    <about>\
     849        <label>Fermi Level</label>\
     850        <description>Energy at center of distribution.</description>\
     851    </about>\
     852    <min>-10</min>\
     853    <max>10</max>\
     854    <default>0</default>\
     855    <current>5</current>\
     856</number>";
     857
     858    const char *name = "Ef";
     859    const char *units = NULL;
     860    double def = 0;
     861    double cur = 5;
     862    double min = -10;
     863    double max = 10;
     864    const char *label = "Fermi Level";
     865    const char *desc = "Energy at center of distribution.";
     866
     867    Rappture::Number n;
     868
     869    n.configure(Rappture::RPCONFIG_XML,(void*)buf);
     870
     871    retVal |= testStringVal(testname,testdesc,name,n.name());
     872    retVal |= testStringVal(testname,testdesc,units,n.units());
     873    retVal |= testDoubleVal(testname,testdesc,def,n.def());
     874    retVal |= testDoubleVal(testname,testdesc,cur,n.cur());
     875    if (n.minset()) {
     876        retVal |= testDoubleVal(testname,testdesc,min,n.min());
     877    }
     878    if (n.maxset()) {
     879        retVal |= testDoubleVal(testname,testdesc,max,n.max());
     880    }
     881    retVal |= testStringVal(testname,testdesc,label,n.label());
     882    retVal |= testStringVal(testname,testdesc,desc,n.desc());
     883
     884    return retVal;
     885}
     886
     887// FIXME: more tests:
     888// what if units in min, max, def, cur differ from units()
     889// what if you can't convert from units in min, max, def, cur to units()
     890// what if units in presets differ from units()
     891// test case for value() function when only cur was configured
     892// test case for value() function when only def was configured
     893// test case for vvalue() function with no hints
     894// test case for vvalue() function with "units=" hint
     895// test case for setting up object, what is cur when only def is provided
     896// test case for setting up object, what is def when only cur is provided
    212897
    213898int main()
     
    216901    number_0_1();
    217902    number_1_0();
     903    number_1_1();
     904    number_1_2();
     905    number_1_3();
     906    number_1_4();
     907    number_1_5();
     908    number_1_6();
     909    number_1_7();
     910    number_1_8();
     911    number_1_9();
     912    number_1_10();
     913    number_1_11();
     914    number_1_12();
     915    number_1_13();
     916    number_1_14();
     917    number_1_15();
     918    number_1_16();
    218919
    219920    return 0;
  • trunk/examples/objects/path/path.cc

    r1560 r1581  
    782782//        input.number2(eee)
    783783//        input.number(eee)2
     784// FIXME: add test for _ifs inside of id tags
    784785
    785786int main()
  • trunk/examples/objects/plot/plot.cc

    r1569 r1581  
    154154    std::printf("curveCnt = %zu\n",curveCnt);
    155155
    156     size_t indent = 0;
    157     size_t tabstop = 4;
    158 
    159     std::printf("xml: %s\n",p1->xml(indent,tabstop));
     156    Rappture::ClientDataXml d;
     157    d.indent = 0;
     158    d.tabstop = 4;
     159    p1->dump(Rappture::RPCONFIG_XML,&d);
     160    std::printf("xml: %s\n",d.retStr);
    160161
    161162    delete p1;
  • trunk/examples/objects/xmlparser/Makefile.in

    r1566 r1581  
    3535                $(srcdir)/xmlparser.cc \
    3636                $(srcdir)/xmlparser_1_0_in.xml \
     37                $(srcdir)/xmlparser_1_1_in.xml \
    3738                $(srcdir)/xmlparser_1_0_out.xml \
     39                $(srcdir)/xmlparser_1_1_out.xml \
    3840                $(srcdir)/xmlparser_2_0_in.xml \
    3941                $(srcdir)/xmlparser_5_0_in.xml \
  • trunk/examples/objects/xmlparser/xmlparser.cc

    r1566 r1581  
    3232    if (memblock == NULL) {
    3333        fprintf(stderr,"can't allocate %zu bytes for file \"%s\": %s",
    34             size, filePath, strerror(errno));
     34            (size_t) size, filePath, strerror(errno));
    3535        fclose(f);
    3636        return 0;
     
    4242
    4343    if (nRead != (size_t)size) {
    44         fprintf(stderr,"can't read %zu bytes from \"%s\": %s", size, filePath,
     44        fprintf(stderr,"can't read %zu bytes from \"%s\": %s", (size_t) size, filePath,
    4545            strerror(errno));
    4646        return 0;
     
    8686    const char *infile = "xmlparser_1_0_in.xml";
    8787    const char *outfile = "xmlparser_1_0_out.xml";
     88    int retVal = 0;
     89
     90    const char *xmltext = NULL;
     91    const char *expected = NULL;
     92
     93    readFile(infile,&xmltext);
     94    readFile(outfile,&expected);
     95
     96    const char *received = NULL;
     97
     98    Rp_ParserXml *p = NULL;
     99
     100    p = Rp_ParserXmlCreate();
     101
     102    Rp_ParserXmlParse(p, xmltext);
     103
     104    received = Rp_ParserXmlXml(p);
     105
     106
     107    if (strcmp(expected,received) != 0) {
     108        printf("Error: %s\n", testname);
     109        printf("\t%s\n", desc);
     110        printf("\texpected %zu bytes: \"%s\"\n",strlen(expected), expected);
     111        printf("\treceived %zu bytes: \"%s\"\n",strlen(received), received);
     112        retVal = 1;
     113    }
     114
     115    if (p) {
     116        Rp_ParserXmlDestroy(&p);
     117    }
     118
     119    return retVal;
     120}
     121
     122
     123int xmlparser_1_1 ()
     124{
     125    const char *desc = "test sending xml text to xml parser";
     126    const char *testname = "xmlparser_1_1";
     127    const char *infile = "xmlparser_1_1_in.xml";
     128    const char *outfile = "xmlparser_1_1_out.xml";
    88129    int retVal = 0;
    89130
     
    313354    xmlparser_0_0();
    314355    xmlparser_1_0();
     356    xmlparser_1_1();
    315357    xmlparser_2_0();
    316358    xmlparser_3_0();
Note: See TracChangeset for help on using the changeset viewer.