int main() {
  StrBlob sb1;

  StrBlob sb2{"Hello", "World"};

  const StrBlob csb1;
  testStrBlob(csb1);
  std::cout << std::endl;

  const StrBlob csb2{"This", "Blob"};
  testStrBlob(csb2);
  std::cout << std::endl;

  ConstStrBlobPtr csbp1;
  testConstStrBlobPtr(csbp1);
  std::cout << std::endl;

  ConstStrBlobPtr sbp2(sb1);
  testConstStrBlobPtr(sbp2);
  std::cout << std::endl;

  ConstStrBlobPtr sbp3(sb1, sb1.size());
  testConstStrBlobPtr(sbp3);
  std::cout << std::endl;

  ConstStrBlobPtr sbp4(sb2);
  testConstStrBlobPtr(sbp4);
  std::cout << std::endl;

  ConstStrBlobPtr sbp5(sb2, sb2.size());
  testConstStrBlobPtr(sbp5);
  std::cout << std::endl;

  ConstStrBlobPtr csbp2(csb1);
  testConstStrBlobPtr(csbp2);
  std::cout << std::endl;

  ConstStrBlobPtr csbp3(csb1, csb1.size());
  testConstStrBlobPtr(csbp3);
  std::cout << std::endl;

  ConstStrBlobPtr csbp4(csb2);
  testConstStrBlobPtr(csbp4);
  std::cout << std::endl;

  ConstStrBlobPtr csbp5(csb2, csb2.size());
  testConstStrBlobPtr(csbp5);
  std::cout << std::endl;
  return 0;
}
Example #2
0
TEST(CxxCase, StringBlobNoIteratorSupport)
{ 
  using namespace cxx_case_strblob;

  {
    StrBlob sb{"one", "two", "three", "four"};

    EXPECT_THAT(sb.size(), 4);
    EXPECT_THAT(sb.front(), "one");
    EXPECT_THAT(sb.back(), "four");

    sb.push_back("five");

    EXPECT_THAT(sb.size(), 5);
    EXPECT_THAT(sb.front(), "one");
    EXPECT_THAT(sb.back(), "five");
  }

  {
    StrBlob sb;

    EXPECT_THAT(sb.size(), 0);
    EXPECT_THROW(sb.front(), std::out_of_range);
  }
} 
Example #3
0
TEST(CxxCase, StringBlobTemplate)
{ 
  using namespace cxx_case_strblob_template;

  {
    StrBlob<std::string> sb{"one", "two", "three", "four"};

    EXPECT_THAT(sb.size(), 4);
    EXPECT_THAT(sb.front(), "one");
    EXPECT_THAT(sb.back(), "four");

    sb.push_back("five");

    EXPECT_THAT(sb.size(), 5);
    EXPECT_THAT(sb.front(), "one");
    EXPECT_THAT(sb.back(), "five");
  }

  {
    StrBlob<std::string> sb;

    EXPECT_THAT(sb.size(), 0);
    EXPECT_THROW(sb.front(), std::out_of_range);
  }
} 
Example #4
0
int main()
{
	StrBlob v = {"Like", "a", "thunderbolt", "he", "falls"};
	StrBlobPtr p1(v), p2 = p1, p3 = p1;
	ConstStrBlobPtr pc(v);
	for(size_t i = 0; i != v.size(); ++i)
		std::cout << *(p1 + i) << " ";
	std::cout << std::endl;
	p2 += 2;
	std::cout << *pc << std::endl;
	std::cout << pc->size() << std::endl;
	return 0;
}
Example #5
0
int main()
{
    string s;
    StrBlob a;
    while(cin >> s)
    {
        a.push_back(s);
    }
    StrBlobPtr sbpBegin = a.begin();
    for(unsigned int c = 0; c != a.size();sbpBegin.incr())
    {
        cout << sbpBegin.deref() << endl;
        ++c;
    }
    return 0;
}
Example #6
0
int main()
{
	StrBlob v = {"Like", "a", "thunderbolt", "he", "falls"};
	StrBlobPtr p1(v), p2 = p1, p3 = p1;
	ConstStrBlobPtr pc(v);
	for(size_t i = 0; i != v.size(); ++i)
		std::cout << (p1 + i).deref() << " ";
	std::cout << std::endl;
	p2 += 2;
	std::cout << p2.deref() << std::endl;
	p3[4] = "falls.";
	pc[4] = "fall"; // wrong, const pointer
	p2 = 5 + p2; // throw exception
	std::cout << p2.deref() << std::endl;
	return 0;
}
Example #7
0
int main()
{
	ifstream in("ex20.cpp");
	StrBlob text;
	string line;
	while (in >> line)
		text.push_back(line);

	StrBlobPtr ptr = text.begin();
	size_t curr = 0;
	while (curr != text.size())
	{
		cout << ptr.deref() << ' ';
		ptr.incr();
		++curr;
	}

	return 0;
}