<commit_before>#! python
from ClassTest import *

START_TEST(String,"$Id: String_test1.py,v 1.1 2003/04/20 16:40:18 oliver Exp $")

CHECK('String::String()')
s = String()
TEST_EQUAL(s is None, false)
RESULT()

CHECK('String::size()/c_str()')
s = String()
TEST_EQUAL(len(s.c_str()), 0)
TEST_EQUAL(s.size(), 0)

s = String("ABC")
TEST_EQUAL(s.size(), 3)
TEST_EQUAL(len(s.c_str()), 3)
TEST_EQUAL(s.c_str()[0], 'A')
TEST_EQUAL(s.c_str()[1], 'B')
TEST_EQUAL(s.c_str()[2], 'C')
RESULT()

CHECK('String::String(String&)')
s2 = String(s)
TEST_EQUAL(s2.size(), 3)

s3 = String()
s2 = String(s3)
TEST_EQUAL(s2.size(), 0)
RESULT()

empty = String()
non_empty = String("Hallo")
CHECK('String::operator == (char*)')
TEST_EQUAL((empty == ""), true)
TEST_EQUAL((empty == "Hallo"), false)
TEST_EQUAL((empty == "Halla"), false)
TEST_EQUAL((empty == "Halloh"), false)
TEST_EQUAL((empty == "Hall"), false)
TEST_EQUAL((empty == empty.c_str()), true)
TEST_EQUAL((non_empty == ""), false)
TEST_EQUAL((non_empty == "Hallo"), true)
TEST_EQUAL((non_empty == "Halloh"), false)
TEST_EQUAL((non_empty == "Hall"), false)
TEST_EQUAL((non_empty == "Halla"), false)
TEST_EQUAL((non_empty == non_empty.c_str()), true)
RESULT()

#String hall("Hall")
#String halloh("Halloh")
#CHECK('String::operator == (String&)')
#	TEST_EQUAL((empty == non_empty), false)
#	TEST_EQUAL((empty == empty), true)
#	TEST_EQUAL((non_empty == non_empty), true)
#	TEST_EQUAL((non_empty == hall), false)
#	TEST_EQUAL((non_empty == halloh), false)
#RESULT()
#
#CHECK('String::create(bool, bool)')
#	s2 = (String*)(halloh.create(true, false))
#	TEST_EQUAL(*s2, halloh)
#	delete s2
#	s2 = (String*)(halloh.create(false, false))
#	TEST_EQUAL(*s2, halloh)
#	delete s2
#	s2 = (String*)(halloh.create(true, true))
#	TEST_EQUAL(*s2, "")
#	delete s2
#	s2 = (String*)(halloh.create(false, true))
#	TEST_EQUAL(*s2, "")
#	delete s2
#RESULT()
#
#CHECK('String::String(String&, Index, Size)')
#	s2 = String(halloh, 2, 4)
#	TEST_EQUAL(*s2, "lloh")
#	delete s2
#	s2 = String(halloh, 4, 2)
#	TEST_EQUAL(*s2, "oh")
#	delete s2
#	s2 = String(halloh, 3)
#	TEST_EQUAL(*s2, "loh")
#	delete s2
#	s2 = String(halloh, -2)
#	TEST_EQUAL(*s2, "oh")
#	delete s2
#	s2 = String(halloh, 0, 0)
#	TEST_EQUAL(*s2, "")
#	delete s2
#	s2 = String(halloh, -1)
#	TEST_EQUAL(*s2, "h")
#	delete s2
#	s2 = 0
#	TEST_EXCEPTION(Exception::IndexOverflow, s2 = String(halloh, 1, 7))
#	if (s2 != 0)
#		delete s2
#RESULT()
#
#CHECK('String::String(const char*, Index, Size)')
#	s2 = String("halloh")
#	TEST_EQUAL(*s2, "halloh")
#	delete s2
#	s2 = String("halloh", 1)
#	TEST_EQUAL(*s2, "alloh")
#	delete s2
#	s2 = String("halloh", 1, 2)
#	TEST_EQUAL(*s2, "al")
#	delete s2
#	s2 = String("halloh", -1, 0)
#	TEST_EQUAL(*s2, "")
#	delete s2
#	s2 = String("halloh", -5)
#	TEST_EQUAL(*s2, "alloh")
#	delete s2
#	s2 = String("halloh", 2, 3)
#	TEST_EQUAL(*s2, "llo")
#	delete s2
#	s2 = 0
#	TEST_EXCEPTION(Exception::IndexOverflow, s2 = String("halloh", 0, 8))
#	if (s2 != 0)
#		delete s2
#	s2 = 0
#	TEST_EXCEPTION(Exception::IndexUnderflow, s2 = String("halloh", -12))
#	if (s2 != 0)
#		delete s2
#RESULT()
#
#CHECK('String::String(Size, char*, ... )')
#	s2 = String(15, "%s", "halloh")
#	TEST_EQUAL(*s2, "halloh")
#	delete s2
#	s2 = String(2, "%s", "halloh")
#	TEST_EQUAL(*s2, "h")
#	delete s2
#	s2 = String(15, "%3.1f", 1.2)
#	TEST_EQUAL(*s2, "1.2")
#	delete s2
#	s2 = 0
#	TEST_EXCEPTION(Exception::IndexUnderflow, s2 = String(0, "%s", "Halloh"))
#	if (s2 != 0)
#	{
#		delete s2
#	}
#	s2 = 0
#	TEST_EXCEPTION(Exception::NullPointer, s2 = String(15, (char*)0, "Halloh", 1.5, 1.2))
#	if (s2 != 0)
#	{
#		delete s2
#	}
#RESULT()
#
#CHECK('String::String(stringstream)')
##ifdef BALL_HAS_SSTREAM
#	std::stringstream instream("ABC DEF")
##else
#	std::strstream instream("ABC DEF", len("ABC DEF"), ios::app)
##endif
#	s2 = String(instream)
#	TEST_NOT_EQUAL(s2, 0)
#	TEST_EQUAL(*s2, "ABC")
#	delete s2
#	s2 = String(instream)
#	TEST_EQUAL(*s2, "DEF")<commit_msg>*** empty log message ***<commit_after>#! python
from ClassTest import *

START_TEST(String,"$Id: String_test1.py,v 1.2 2003/04/21 12:33:39 oliver Exp $")

CHECK('String::String()')
s = String()
TEST_EQUAL(s is None, false)
RESULT()

CHECK('String::size()/c_str()')
s = String()
TEST_EQUAL(len(s.c_str()), 0)
TEST_EQUAL(s.size(), 0)

s = String("ABC")
TEST_EQUAL(s.size(), 3)
TEST_EQUAL(len(s.c_str()), 3)
TEST_EQUAL(s.c_str()[0], 'A')
TEST_EQUAL(s.c_str()[1], 'B')
TEST_EQUAL(s.c_str()[2], 'C')
RESULT()

CHECK('String::String(String&)')
s2 = String(s)
TEST_EQUAL(s2.size(), 3)

s3 = String()
s2 = String(s3)
TEST_EQUAL(s2.size(), 0)
RESULT()

empty = String()
non_empty = String("Hallo")
CHECK('String::operator == (char*)')
TEST_EQUAL((empty == ""), true)
TEST_EQUAL((empty == "Hallo"), false)
TEST_EQUAL((empty == "Halla"), false)
TEST_EQUAL((empty == "Halloh"), false)
TEST_EQUAL((empty == "Hall"), false)
TEST_EQUAL((empty == empty.c_str()), true)
TEST_EQUAL((non_empty == ""), false)
TEST_EQUAL((non_empty == "Hallo"), true)
TEST_EQUAL((non_empty == "Halloh"), false)
TEST_EQUAL((non_empty == "Hall"), false)
TEST_EQUAL((non_empty == "Halla"), false)
TEST_EQUAL((non_empty == non_empty.c_str()), true)
RESULT()

hall = String("Hall")
halloh = String("Halloh")
CHECK('String::operator == (String&)')
TEST_EQUAL((empty == non_empty), false)
TEST_EQUAL((empty == empty), true)
TEST_EQUAL((non_empty == non_empty), true)
TEST_EQUAL((non_empty == hall), false)
TEST_EQUAL((non_empty == halloh), false)
RESULT()

CHECK('String::String(String&, Index, Size)')
s2 = String(halloh, 2, 4)
TEST_EQUAL(s2, "lloh")

s2 = String(halloh, 4, 2)
TEST_EQUAL(s2, "oh")

s2 = String(halloh, 3)
TEST_EQUAL(s2, "loh")

s2 = String(halloh, -2)
TEST_EQUAL(s2, "oh")

s2 = String(halloh, 0, 0)
TEST_EQUAL(s2, "")

s2 = String(halloh, -1)
TEST_EQUAL(s2, "h")

try:
	s2 = String(halloh, 1, 7)
	FAIL()
except:
	pass
RESULT()

CHECK('String::String(const char*, Index, Size)')
s2 = String("halloh")
TEST_EQUAL(s2, "halloh")
s2 = String("halloh", 1)
TEST_EQUAL(s2, "alloh")
s2 = String("halloh", 1, 2)
TEST_EQUAL(s2, "al")
s2 = String("halloh", -1, 0)
TEST_EQUAL(s2, "")
s2 = String("halloh", -5)
TEST_EQUAL(s2, "alloh")
s2 = String("halloh", 2, 3)
TEST_EQUAL(s2, "llo")
try:
	s2 = String("halloh", 0, 8)
	FAIL()
except:
	pass
try:
	s2 = String("halloh", -12)
	FAIL()
except:
	pass
RESULT()

#CHECK('String::String(stringstream)')
##ifdef BALL_HAS_SSTREAM
#	std::stringstream instream("ABC DEF")
##else
#	std::strstream instream("ABC DEF", len("ABC DEF"), ios::app)
##endif
#	s2 = String(instream)
#	TEST_NOT_EQUAL(s2, 0)
#	TEST_EQUAL(*s2, "ABC")
#	delete s2
#	s2 = String(instream)
#	TEST_EQUAL(*s2, "DEF")
{'fraction_non_alphanumeric': 0.22566037735849057, 'fraction_numerical': 0.03879245283018868, 'mean_word_length': 6.186550976138829, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4115380', 'n_tokens_mistral': 2969, 'n_tokens_neox': 2849, 'n_words': 593}