SVN / public / code / vorlesung-06 / StringTest.cpp

Revision 11340
Date
Committerhb1003
Download
// Copyright 2016, University of Freiburg,
// Chair of Algorithms and Data Structures.
// Author: Hannah Bast <bast@cs.uni-freiburg.de>.

#include <gtest/gtest.h>
#include "./String.h"

// _____________________________________________________________________________
TEST(StringTest, constructor) {
  String s;
  ASSERT_EQ(0, s._length);
  ASSERT_EQ(NULL, s._contents);
}

// _____________________________________________________________________________
TEST(StringTest, set) {
  String s;
  s.set("Doof");
  ASSERT_EQ(4, s._length);
  ASSERT_EQ('D', s._contents[0]);
  ASSERT_EQ('o', s._contents[1]);
  ASSERT_EQ('o', s._contents[2]);
  ASSERT_EQ('f', s._contents[3]);
}