Exemplo n.º 1
0
 void testString() {
     report(0,"testing string representation...");
     String target = "hello \"my\" \\friend";
     BottleImpl bot;
     bot.addInt(5);
     bot.addString("hello \"my\" \\friend");
     String txt = bot.toString();
     const char *expect = "5 \"hello \\\"my\\\" \\\\friend\"";
     checkEqual(txt,expect,"string rep");
     BottleImpl bot2;
     bot2.fromString(txt);
     checkEqual(2,(int)bot2.size(),"return from string rep");
 }
Exemplo n.º 2
0
 bool read(ConnectionReader& reader) override {
     if (!reader.isValid()) {
         return false;
     }
     receives++;
     BottleImpl bot;
     bot.read(reader);
     if (expectation==std::string("")) {
         report(1,"got unexpected input");
         return false;
     }
     checkEqual(bot.toString(),expectation,"received bottle");
     return true;
 }
Exemplo n.º 3
0
    void testStreaming() {
        report(0,"testing streaming (just text mode)...");

        BottleImpl bot;
        bot.addInt(5);
        bot.addString("hello");

        BufferedConnectionWriter bbw(true);
        bot.write(bbw);
      
        String s;
        StringInputStream sis;
        StreamConnectionReader sbr;
      
        s = bbw.toString();
        sis.add(s);
        Route route;
        sbr.reset(sis,NULL,route,s.length(),true);
      
        BottleImpl bot2;
        bot2.read(sbr);
        checkEqual(bot2.toString(),bot.toString(),"to/from stream");

    }