コード例 #1
0
ファイル: brushmanip.cpp プロジェクト: ChunHungLiu/GtkRadiant
 TestRefcountedString()
 {
   {
     // copy construct
     SmartString string1("string1");
     SmartString string2(string1);
     SmartString string3(string2);
   }
   {
     // refcounted assignment
     SmartString string1("string1");
     SmartString string2("string2");
     string1 = string2;
   }
   {
     // copy assignment
     SmartString string1("string1");
     SmartString string2("string2");
     string1 = string2.c_str();
   }
   {
     // self-assignment
     SmartString string1("string1");
     string1 = string1;
   }
   {
     // self-assignment via another reference
     SmartString string1("string1");
     SmartString string2(string1);
     string1 = string2;
   }
 }
コード例 #2
0
int HK_CALL hkRemoveHighLowPrefixFilter(const char* str1, const char* str2)
{
	hkString string1(str1);
	hkString string2(str2);

	if (string1.beginsWith("High "))
	{
		string1 = string1.substr(5);
	}
	if (string2.beginsWith("High "))
	{
		string2 = string2.substr(5);
	}

	if (string1.beginsWith("Low "))
	{
		string1 = string1.substr(4);
	}
	if (string2.beginsWith("Low "))
	{
		string2 = string2.substr(4);
	}

	return string1.compareToIgnoreCase( string2 );
}
コード例 #3
0
ファイル: DiffColoring.cpp プロジェクト: seanedwards/COS-420
/**
* @brief Bug #1639453: Imaginary difference highlighted in character level mode.
*/
void DiffColoring::Bug1639453()
{
	wdiffarray diffs;
	CString string1(_T("[12, 34]"));
	CString string2(_T("[12, 34, 56]"));
	int count = 0;

	// Compare case, all white spaces, whitespace break + punctuation, char level
	sd_ComputeWordDiffs(string1, string2,
		true, WHITESPACE_COMPARE_ALL, 1, true,
		&diffs);
	count = diffs.GetSize();
	CPPUNIT_ASSERT(count == 1);
	CPPUNIT_ASSERT(diffs[0] == wdiff(8, 7, 7, 10));

	// A more complex strings.
	string1 = _T("[overlay_oid_origin, overlay_oid_target], [nil, nil]");
	string2 = _T("[overlay_oid_origin, overlay_oid_target, origin_file_name, target_file_name], [nil, nil, \"origin.txt\", \"target.txt\"]");

	// Compare case, all white spaces, whitespace break + punctuation, char level
	diffs.RemoveAll();
	sd_ComputeWordDiffs(string1, string2,
		true, WHITESPACE_COMPARE_ALL, 1, true,
		&diffs);
	count = diffs.GetSize();
	CPPUNIT_ASSERT(count == 1);
	CPPUNIT_ASSERT(diffs[0] == wdiff(39, 50, 39, 114));
}
コード例 #4
0
ファイル: TestCase1.cpp プロジェクト: seanedwards/COS-420
/**
 * @brief Test different two-words are detected as such.
 * This function tests that two different two-words are detected
 * as different with different word-compare settings.
 */
void TestCase1::Difference2()
{
	wdiffarray diffs;
	CString string1(_T("Test string"));
	CString string2(_T("test strIng"));
	int count = 0;

	// Break type is whitespace or punctuation

	// Check strings with different settings
	sd_ComputeWordDiffs(string1, string2,
		false, WHITESPACE_COMPARE_ALL, 0, false,
		&diffs);
	count = diffs.GetSize();
	CPPUNIT_ASSERT(count == 0);

	// Expect to find one differences since difference starts from the first
	// non-matching word and ends in the predecessor of the first matching
	// word.
	diffs.RemoveAll();
	sd_ComputeWordDiffs(string1, string2,
		true, WHITESPACE_COMPARE_ALL, 0, false,
		&diffs);
	count = diffs.GetSize();
	CPPUNIT_ASSERT(count == 1);
	diffs.RemoveAll();
}
コード例 #5
0
ファイル: StatusWindow.cpp プロジェクト: mmanley/Antares
bool 
StatusWindow::UpdateStatusBar(uint32 page, uint32 copy)
{
	Lock();
		Activate(true);		
			// Frontmost Window
		char buffer[20];
		
		sprintf(buffer,"%d", (int)(page + 1));
		BString string1(buffer);
		
		sprintf(buffer,"%d",(int)fNops );						
		BString string2(buffer);
		string1.Append(BString(" / "));
		string1.Append(string2);
		
		BString string3 = BString("Remaining Document Copies:  ");	
		if (fDocumentCopy == true) {
			sprintf(buffer, "%d", (int)(fDocCopies));
			BString string4(buffer);
			string3.Append(string4);
		} else {
			string3 = BString("Remaining Page Copies:  ");	
			char buffer[20];
			sprintf(buffer,"%d",(int)(fCopies - copy) );						
			BString string4(buffer);
			string3.Append(string4);		
		}
		
		fStatusBar->Update(fStatusDelta*100.0/fNops, string1.String(), string3.String());
		if ( (fStatusBar->MaxValue()) == (fStatusBar->CurrentValue()) )
				fCancelButton->SetEnabled(false);
	Unlock();
	return fCancelBar;
}
コード例 #6
0
ファイル: uint256_union.cpp プロジェクト: kuhaku17/raiblocks
TEST (json, fetch_object)
{
	std::string string1 ("{ \"thing\": \"junktest\" }");
	std::stringstream stream1 (string1);
	json_upgrade_test object1;
	auto error1 (rai::fetch_object (object1, stream1));
	ASSERT_FALSE (error1);
	ASSERT_EQ ("changed", object1.text);
	boost::property_tree::ptree tree1;
	stream1.seekg (0);
	boost::property_tree::read_json (stream1, tree1);
	ASSERT_EQ ("changed", tree1.get <std::string> ("thing"));
	std::string string2 ("{ \"thing\": \"junktest2\" }");
	std::stringstream stream2 (string2);
	json_upgrade_test object2;
	auto error2 (rai::fetch_object (object2, stream2));
	ASSERT_FALSE (error2);
	ASSERT_EQ ("junktest2", object2.text);
	ASSERT_EQ ("{ \"thing\": \"junktest2\" }", string2);
	std::string string3 ("{ \"thing\": \"error\" }");
	std::stringstream stream3 (string3);
	json_upgrade_test object3;
	auto error3 (rai::fetch_object (object3, stream3));
	ASSERT_TRUE (error3);
	std::fstream stream4;
	rai::open_or_create (stream4, rai::unique_path().string());
	json_upgrade_test object4;
	auto error4 (rai::fetch_object (object4, stream4));
	ASSERT_FALSE (error4);
	ASSERT_EQ ("created", object4.text);
	boost::property_tree::ptree tree2;
	stream4.seekg (0);
	boost::property_tree::read_json (stream4, tree2);
	ASSERT_EQ ("created", tree2.get <std::string> ("thing"));
}
コード例 #7
0
// This is the string comparison we use to match names from the animation skeleton
// to names in the ragdoll skeleton. The filter just extracts the bone name,
// from either, so we will use the same filter for both skeletons.
// For example, it will match "Rig Pelvis" to "Ragdoll_Pelvis".
int HK_CALL CharacterAttachmentsHelpers::compareWithoutPrefix( const char* str1, const char* str2 )
{
	hkString string1(str1);
	stripPrefix(string1);

	hkString string2(str2);
	stripPrefix(string2);

	return string1.compareToIgnoreCase( string2 );
}
コード例 #8
0
void reverse ( const char *arg ) {
//  Round trip
    string_ref sr1 ( arg );
    std::string string1 ( sr1.rbegin (), sr1.rend ());
    string_ref sr2 ( string1 );
    std::string string2 ( sr2.rbegin (), sr2.rend ());

    BOOST_CHECK ( std::equal ( sr2.rbegin (), sr2.rend (), arg ));
    BOOST_CHECK ( string2 == arg );
    BOOST_CHECK ( std::equal ( sr1.begin (), sr1.end (), string2.begin ()));
    }
コード例 #9
0
static void halt(string* const s, int64_t _ln, int32_t _fn) {
#line 215 "ChapelIO.chpl"
  string local__str_literal_302;
#line 215 "ChapelIO.chpl"
  string call_tmp;
#line 215 "ChapelIO.chpl"
  string call_tmp2;
#line 215 "ChapelIO.chpl"
  _ref_string ret_to_arg_ref_tmp_ = NULL;
#line 215 "ChapelIO.chpl"
  int32_t coerce_tmp;
#line 215 "ChapelIO.chpl"
  chpl_bool call_tmp3;
#line 215 "ChapelIO.chpl"
  c_ptr_uint8_t coerce_tmp2 = NULL;
#line 215 "ChapelIO.chpl"
  c_string call_tmp4;
#line 215 "ChapelIO.chpl"
  _ref_string _ref_tmp_ = NULL;
#line 689 "ChapelIO.chpl"
  local__str_literal_302 = _str_literal_302;
#line 689 "ChapelIO.chpl"
  ret_to_arg_ref_tmp_ = &call_tmp2;
#line 689 "ChapelIO.chpl"
  string2(s, UINT8(false), ret_to_arg_ref_tmp_, _ln, _fn);
#line 689 "ChapelIO.chpl"
  call_tmp = call_tmp2;
#line 689 "ChapelIO.chpl"
  coerce_tmp = (&call_tmp)->locale_id;
#line 689 "ChapelIO.chpl"
  call_tmp3 = (coerce_tmp != chpl_nodeID);
#line 689 "ChapelIO.chpl"
  if (call_tmp3) /* ZLINE: 689 /home/agobin/Documents/chapel-1.13.0/modules/internal/ChapelIO.chpl */
#line 689 "ChapelIO.chpl"
  {
#line 689 "ChapelIO.chpl"
    halt(&local__str_literal_302, _ln, _fn);
#line 689 "ChapelIO.chpl"
  }
#line 689 "ChapelIO.chpl"
  coerce_tmp2 = (&call_tmp)->buff;
#line 689 "ChapelIO.chpl"
  call_tmp4 = ((c_string)(coerce_tmp2));
#line 689 "ChapelIO.chpl"
  halt2(call_tmp4, _ln, _fn);
#line 689 "ChapelIO.chpl"
  _ref_tmp_ = &call_tmp;
#line 689 "ChapelIO.chpl"
  chpl___TILDE_string(_ref_tmp_, _ln, _fn);
#line 688 "ChapelIO.chpl"
  return;
#line 688 "ChapelIO.chpl"
}
コード例 #10
0
ファイル: DiffColoring.cpp プロジェクト: seanedwards/COS-420
/**
* @brief Test a string against an empty string difference.
*/
void DiffColoring::DiffWithEmpty()
{
	wdiffarray diffs;
	CString string1(_T("First line to check"));
	CString string2(_T(""));
	int count = 0;

	// Compare case, all white spaces, whitespace break
	sd_ComputeWordDiffs(string1, string2,
		true, WHITESPACE_COMPARE_ALL, 0, false,
		&diffs);
	count = diffs.GetSize();
	CPPUNIT_ASSERT(count == 1);
	CPPUNIT_ASSERT(diffs[0] == wdiff(0, 18, 0, -1));
}
コード例 #11
0
ファイル: DiffColoring.cpp プロジェクト: seanedwards/COS-420
/**
* @brief Test a single word difference.
*/
void DiffColoring::OneWord()
{
	wdiffarray diffs;
	CString string1(_T("Left"));
	CString string2(_T("Right"));
	int count = 0;

	// Compare case, all white spaces, whitespace break
	sd_ComputeWordDiffs(string1, string2,
		true, WHITESPACE_COMPARE_ALL, 0, false,
		&diffs);
	count = diffs.GetSize();
	CPPUNIT_ASSERT(count == 1);
	CPPUNIT_ASSERT(diffs[0] == wdiff(0, 3, 0, 4));
}
コード例 #12
0
ファイル: DiffColoring.cpp プロジェクト: seanedwards/COS-420
/**
* @brief Test word difference in the middle of the line.
*/
void DiffColoring::OneWordDiff()
{
	wdiffarray diffs;
	CString string1(_T("This is the first line"));
	CString string2(_T("This is the last line"));
	int count = 0;

	// Compare case, all white spaces, whitespace break
	sd_ComputeWordDiffs(string1, string2,
		true, WHITESPACE_COMPARE_ALL, 0, false,
		&diffs);
	count = diffs.GetSize();
	CPPUNIT_ASSERT(count == 1);
	CPPUNIT_ASSERT(diffs[0] == wdiff(12, 16, 12, 15));
}
コード例 #13
0
ファイル: DiffColoring.cpp プロジェクト: seanedwards/COS-420
/**
* @brief Bug #1491334: Thinly highlighted position is wrong.
*/
void DiffColoring::Bug1491334()
{
	wdiffarray diffs;
	CString string1(_T("00 52 C8 52"));
	CString string2(_T("00 00 00 52"));
	int count = 0;

	// Compare case, all white spaces, whitespace break
	sd_ComputeWordDiffs(string1, string2,
		true, WHITESPACE_COMPARE_ALL, 0, false,
		&diffs);
	count = diffs.GetSize();
	CPPUNIT_ASSERT(count == 1);
	CPPUNIT_ASSERT(diffs[0] == wdiff(3, 7, 3, 7));
}
コード例 #14
0
ファイル: DiffColoring.cpp プロジェクト: seanedwards/COS-420
/**
* @brief Test a different string length difference.
*/
void DiffColoring::DifferentLength()
{
	wdiffarray diffs;
	CString string1(_T("First line to check"));
	CString string2(_T("Second line"));
	int count = 0;

	// Compare case, all white spaces, whitespace break
	sd_ComputeWordDiffs(string1, string2,
		true, WHITESPACE_COMPARE_ALL, 0, false,
		&diffs);
	count = diffs.GetSize();
	CPPUNIT_ASSERT(count == 2);
	CPPUNIT_ASSERT(diffs[0] == wdiff(0, 4, 0, 5));
	CPPUNIT_ASSERT(diffs[1] == wdiff(11, 18, 11, 10));
}
コード例 #15
0
ファイル: DiffColoring.cpp プロジェクト: seanedwards/COS-420
/**
* @brief Bug #1683061: Displays not existing content.
*/
void DiffColoring::Bug1714088()
{
	wdiffarray diffs;
	CString string1(_T("arg_separator.output = \";\""));
	CString string2(_T(";arg_separator.output = \"&amp;\""));
	int count = 0;

	// Compare case, all white spaces, whitespace break, char level
	sd_ComputeWordDiffs(string1, string2,
		true, WHITESPACE_COMPARE_ALL, 0, true,
		&diffs);
	count = diffs.GetSize();
	CPPUNIT_ASSERT(count == 2);
	CPPUNIT_ASSERT(diffs[0] == wdiff(26, 25, 0, 0));
	CPPUNIT_ASSERT(diffs[1] == wdiff(26, 25, 25, 28));
}
コード例 #16
0
/**
 * @brief Test we handle simple case difference correctly.
 * This function tests we handle one-char case difference correctly
 * with different compare options. In this test the difference is
 * in the middle of word.
 */
void DifferentStrings1::CasesDiffer2()
{
	wdiffarray diffs;
	CString string1(_T("test"));
	CString string2(_T("teSt"));
	int count = 0;

	// Compare case, all whitespaces, whitespace break
	// We must find one difference
	diffs.RemoveAll();
	sd_ComputeWordDiffs(string1, string2,
		true, WHITESPACE_COMPARE_ALL, 0, false,
		&diffs);
	count = diffs.GetSize();
	CPPUNIT_ASSERT(count == 1);

	// Ignore case, all whitespaces, whitespace break
	// No difference
	diffs.RemoveAll();
	sd_ComputeWordDiffs(string1, string2,
		false, WHITESPACE_COMPARE_ALL, 0, false,
		&diffs);
	count = diffs.GetSize();
	CPPUNIT_ASSERT(count == 0);

	// Compare case, whitespaces change, whitespace break
	// We must find one difference
	diffs.RemoveAll();
	sd_ComputeWordDiffs(string1, string2,
		true, WHITESPACE_IGNORE_CHANGE, 0, false,
		&diffs);
	count = diffs.GetSize();
	CPPUNIT_ASSERT(count == 1);

	// Compare case, whitespaces ignore, whitespace break
	// We must find one difference
	diffs.RemoveAll();
	sd_ComputeWordDiffs(string1, string2,
		true, WHITESPACE_IGNORE_ALL, 0, false,
		&diffs);
	count = diffs.GetSize();
	CPPUNIT_ASSERT(count == 1);
}
コード例 #17
0
void TestChainTraverserComments::TestStringHighlightStyles()
{
	ComparisonContext cContext;
	CRTF_String string(&cContext, Detached);
	assertTest(string.GetHighlightStyle()==DV_STYLE_INSERTION);

	string.DeleteAll();
	assertTest(string.GetHighlightStyle()==DV_STYLE_DELETION);

	CRTF_String string2(&cContext, Detached);
	string2.MarkMatched();
	assertTest(string2.GetHighlightStyle()==DV_STYLE_MATCH);

	CRTF_String string3(&cContext, Detached);
	string3.SetAsDVPComment();
	assertTest(string3.GetHighlightStyle()==DV_STYLE_INSERTEDCOMMENT); // COMMENT_STUFF
	string3.DeleteAll();
	assertTest(string3.GetHighlightStyle()==DV_STYLE_DELETEDCOMMENT); // COMMENT_STUFF
}
コード例 #18
0
ファイル: TestCase1.cpp プロジェクト: seanedwards/COS-420
/**
 * @brief Test identical words are detected as such.
 * This function tests that two identical words are detected
 * as identical with different word-compare settings.
 */
void TestCase1::Identical1()
{
	wdiffarray diffs;
	CString string1(_T("Test"));
	CString string2(_T("Test"));
	int count = 0;

	// Compare case, all whitespaces, whitespace break
	sd_ComputeWordDiffs(string1, string2,
		true, WHITESPACE_COMPARE_ALL, 0, false,
		&diffs);
	count = diffs.GetSize();
	CPPUNIT_ASSERT(count == 0);

	// Ignore case, all whitespaces, whitespace break
	diffs.RemoveAll();
	sd_ComputeWordDiffs(string1, string2,
		false, WHITESPACE_COMPARE_ALL, 0, false,
		&diffs);
	count = diffs.GetSize();
	CPPUNIT_ASSERT(count == 0);

	// Compare case, whitespaces change, whitespace break
	diffs.RemoveAll();
	sd_ComputeWordDiffs(string1, string2,
		true, WHITESPACE_IGNORE_CHANGE, 0, false,
		&diffs);
	count = diffs.GetSize();
	CPPUNIT_ASSERT(count == 0);

	// Compare case, whitespaces ignore, whitespace break
	diffs.RemoveAll();
	sd_ComputeWordDiffs(string1, string2,
		true, WHITESPACE_IGNORE_ALL, 0, false,
		&diffs);
	count = diffs.GetSize();
	CPPUNIT_ASSERT(count == 0);
}
コード例 #19
0
ファイル: TestCase1.cpp プロジェクト: seanedwards/COS-420
/**
 * @brief Test different words are detected as such.
 * This function tests that two different words are detected
 * as different with different word-compare settings.
 */
void TestCase1::Difference1()
{
	wdiffarray diffs;
	CString string1(_T("Test"));
	CString string2(_T("test"));
	int count = 0;

	// Break type is whitespace or punctuation

	// Check strings with different settings
	sd_ComputeWordDiffs(string1, string2,
		false, WHITESPACE_COMPARE_ALL, 0, false,
		&diffs);
	count = diffs.GetSize();
	CPPUNIT_ASSERT(count == 0);
	diffs.RemoveAll();

	// Check strings with different settings
	diffs.RemoveAll();
	sd_ComputeWordDiffs(string1, string2,
		true, WHITESPACE_COMPARE_ALL, 0, false,
		&diffs);
	count = diffs.GetSize();
	CPPUNIT_ASSERT(count == 1);
	diffs.RemoveAll();

	// Check strings with different settings
	string1 = _T("tesT");
	string2 = _T("test");
	diffs.RemoveAll();
	sd_ComputeWordDiffs(string1, string2,
		true, WHITESPACE_COMPARE_ALL, 0, false,
		&diffs);
	count = diffs.GetSize();
	CPPUNIT_ASSERT_MESSAGE(_T("testT & test difference not found!"), count == 1);
	diffs.RemoveAll();
}
コード例 #20
0
ファイル: DiffColoring.cpp プロジェクト: seanedwards/COS-420
/**
* @brief Bug #1683061: Bug in highlighting.
*/
void DiffColoring::Bug1683061()
{
	wdiffarray diffs;
	CString string1(_T("ABC"));
	CString string2(_T("ABCD"));
	int count = 0;

	// Compare case, all white spaces, whitespace break
	sd_ComputeWordDiffs(string1, string2,
		true, WHITESPACE_COMPARE_ALL, 0, false,
		&diffs);
	count = diffs.GetSize();
	CPPUNIT_ASSERT(count == 1);
	CPPUNIT_ASSERT(diffs[0] == wdiff(0, 2, 0, 3));

	// Compare case, all white spaces, whitespace break + punctuation
	diffs.RemoveAll();
	sd_ComputeWordDiffs(string1, string2,
		true, WHITESPACE_COMPARE_ALL, 0, true,
		&diffs);
	count = diffs.GetSize();
	CPPUNIT_ASSERT(count == 1);
	CPPUNIT_ASSERT(diffs[0] == wdiff(3, 2, 3, 3));
}
コード例 #21
0
ファイル: DiffColoring.cpp プロジェクト: seanedwards/COS-420
/**
* @brief Test punctuation break mode at word level.
*/
void DiffColoring::PunctuationWord()
{
	wdiffarray diffs;
	CString string1(_T("00,52,C8,52"));
	CString string2(_T("00,00,00,52"));
	int count = 0;

	// Compare case, all white spaces, whitespace break
	sd_ComputeWordDiffs(string1, string2,
		true, WHITESPACE_COMPARE_ALL, 0, false,
		&diffs);
	count = diffs.GetSize();
	CPPUNIT_ASSERT(count == 1);
	CPPUNIT_ASSERT(diffs[0] == wdiff(0, 10, 0, 10));

	// Compare case, all white spaces, whitespace break + punctuation
	diffs.RemoveAll();
	sd_ComputeWordDiffs(string1, string2,
		true, WHITESPACE_COMPARE_ALL, 1, false,
		&diffs);
	count = diffs.GetSize();
	CPPUNIT_ASSERT(count == 1);
	CPPUNIT_ASSERT(diffs[0] == wdiff(3, 7, 3, 7));
};
コード例 #22
0
int main(int argc, const char* argv[]) {
    std::string string1("Testing the comparision functions.");
    std::string string2("Hello");
    std::string string3("stinger");
    std::string string4(string2);

    std::cout << "string1: " << string1 << "\nstring2: " << string2
              << "\nstring3: " << string3 << "\nstring4: " << string4 << "\n\n";

    // comparing string1 and string4
    if (string1 == string4)
        std::cout << "string1 == string4\n";
    else {
        if (string1 > string4)
            std::cout << "string1 > string4\n";
        else
            std::cout << "string1 < string4\n";
    }

    // comparing string1 and string2
    int result = string1.compare(string2);

    if (result == 0)
        std::cout << "string1.compare(string2) == 0\n";
    else {
        if (result > 0)
            std::cout << "string1.compare(string2) > 0\n";
        else
            std::cout << "string1.compare(string2) < 0\n";
    }

    // comparing string1 (elements 2-5) and string3 (elements 0-5)
    result = string1.compare(2, 5, string3, 0, 5);

    if (result == 0)
        std::cout << "string1.compare(2, 5, string3, 0, 5) == 0\n";
    else {
        if (result > 0)
            std::cout << "string1.compare(2, 5, string3, 0, 5) > 0\n";
        else
            std::cout << "string1.compare(2, 5, string3, 0, 5) < 0\n";
    }

    // comparing string2 and string4
    result = string4.compare(0, string2.length(), string2);

    if (result == 0)
        std::cout << "string4.compare(0, string2.length(), string2) == 0"
                  << std::endl;
    else {
        if (result > 0)
            std::cout << "string4.compare(0, string2.length(), string2) > 0"
                      << std::endl;
        else
            std::cout << "string4.compare(0, string2.length(), string2) < 0"
                      << std::endl;
    }

    // comparing string2 and string4
    result = string2.compare(0, 3, string4);

    if (result == 0)
        std::cout << "string2.compare(0, 3, string4) == 0" << std::endl;
    else {
        if (result > 0)
            std::cout << "string2.compare(0, 3, string4) > 0" << std::endl;
        else
            std::cout << "string2.compare(0, 3, string4) < 0" << std::endl;
    }

    return 0;
}