#include "String.hh"

#include <iostream>
#include <cstring>

int main() {
	String str("Blubaloo");
	std::cout << "String '" << str.data() << "' is " << str.length() << " chars long." << std::endl;


	// Chain Assignment 
	std::cout << "String assignment" << std::endl;
	String a, b;
	a = b = String("Empty");
	std::cout << "String '" << a.data() << "' is " << a.length() << " chars long." << std::endl;
	std::cout << "String '" << b.data() << "' is " << b.length() << " chars long." << std::endl;


	// Operator+
	std::cout << "Operator +" << std::endl;
	a = String("Loose") + String(" Statement");
	std::cout << "String '" << a.data() << "' is " << a.length() << " chars long." << std::endl;


	// Operator+=
	std::cout << "Operator +=" << std::endl;
	b += " " ; // String takes a const char* as input to constructor, so autoconversion available
	b += a ;
	std::cout << "String '" << b.data() << "' is " << b.length() << " chars long." << std::endl;

	// Type Conversion
	std::cout << "Type Conversion" << std::endl;
	String c("Almost Empty");

	std::cout << "String '" << c.data() << "' is " << strlen(c) << " chars long." << std::endl;


	// Substring
	std::cout << "First five characters: " << c.subString(0, 5) << std::endl;
	std::cout << "First five characters reversed: " << c.subString(5, 0) << std::endl;
	std::cout << "Last five characters: " << c.subString(-5, -1) << std::endl;
}
