Vodafone Test Suite

Dependencies:   mbed-rtos mbed HTTPClient VodafoneUSBModem

Tests/Test10.cpp

Committer:
ashleymills
Date:
2012-09-14
Revision:
40:32b0558320ea
Child:
44:6d0ac4747f5b

File content as of revision 40:32b0558320ea:

#include "Test10.h"

Test10::Test10(VodafoneUSBModem *m) : VodafoneTestCase(m) {
   _description = gTest10Description;
   _testCaseNumber = 10;
}
      
void Test10::setupTest() {}
   
bool Test10::execute() {
   HTTPClient http;
   char msgBuffer[125];
   bool outcome = true;
   LOG("Description: %s",gTest10Description);
   LOG("Connecting to internet");
   if(_modem->connect("internet","web","web")==0) {
      LOG("Connected to internet");
   } else {
      LOG("Failed to connect to internet");
      outcome = false;
   }
       
   LOG("Doing HTTP GET for http://www.m2mthings.com/test100.txt");
   if(http.get("http://www.m2mthings.com/test100.txt", msgBuffer, 125)==0) {
      LOG("Got buffer");
      char c = 0;
      for(int i=0; i<100; i++) {
         if(msgBuffer[i]!=c) {
            LOG("Strings do not match at char %d (%x,%x)",i,c,msgBuffer[i]);
            outcome = false;
            break;
         }
         c++;
         if(c==256)
            c = 0;
      }
      LOG("All bytes match! PASS.");
   } else {
      LOG("HTTP get failure");
      outcome = false;
   }
   _modem->disconnect();
   return outcome;
}
      
void Test10::endTest() { }