/* StringNDriver.cpp
2015-11-08 - 2018-06-30
Esp. Ing. Jos Mara Sola
Profesor
UTN FRBA */
#include
#include
#include
#include
#include "StringN.h"
template
void PrintSizesAndContents(std::string, String, std::string);
int main(){
{ // Tests
{ // array ms corto que string
std::array a = PackString("Hello, World!");
assert( "Hello" == UnpackString(a) );
}
{ // String ms corto que string
String s = PackString("Hello, World!");
assert( "Hell" == UnpackString(s) );
}
{ // String igual de largo que string
String s = PackString("Hello, World!");
assert( "Hello, World!" == UnpackString(s) );
}
{ // String ms largo que string
String s = PackString("Hello, World!");
assert( "Hello, World!" == UnpackString(s) );
}
}
{ // Ejemplos
using std::array;
using std::string;
{ // String
string s{"Hello, World!"};
String a = PackString(s);
string t{UnpackString(a)};
assert( t == "Hello" );
}
{ // array
string s{"Hello, World!"};
array a = PackString(s);
string t{UnpackString(a)};
assert( t == "Hello");
}
{ // String ms corto que string
string s{"Texto de largo mayor a lmite de registro."};
String a = PackString(s); // array
auto t{UnpackString(a)}; // desempaque todo lo que se pudo guardar
assert(s.compare(0, 12, t) == 0);
PrintSizesAndContents(s,a,t);
}
{ // String igual de largo que string
string s{"abcd"}; // string type
String a = PackString(s); // array
auto t{UnpackString(a)};
assert(s == t);
PrintSizesAndContents(s,a,t);
}
{ // String ms largo que string
string s{"xyz"};
array a = PackString(s);
auto t{UnpackString(a)};
assert(s == t);
PrintSizesAndContents(s,a,t);
}
}
}
template
void PrintString(const String&);
template
void PrintSizesAndContents(std::string s, String a, std::string t){
std::cout