#include "StdAfx.h"
#include "UnitTestFrameWork.h"
#include <string.h>
#include "TestUtils.h"
#include "..\p4bridge\utils.h"
CREATE_TEST_SUITE(TestUtils)
TestUtils::TestUtils(void)
{
    UnitTestSuite::RegisterTest(&TestCopyStr, "TestCopyStr");
    UnitTestSuite::RegisterTest(&TestCopyWStr, "TestCopyWStr");
    UnitTestSuite::RegisterTest(&TestCopyWStr, "TestAddStr");
    UnitTestSuite::RegisterTest(&TestCopyWStr, "TestCpyStrBuff");
    UnitTestSuite::RegisterTest(&TestCopyWStr, "TestAddStrBuff");
}
TestUtils::~TestUtils(void)
{
}
bool TestUtils::Setup()
{
    return true;
}
bool TestUtils::TearDown(char* testName)
{
    return true;
}
bool TestUtils::TestCopyStr(void)
{
    char * pCopy = CopyStr("12345");
    ASSERT_EQUAL(5,strlen(pCopy));
    ASSERT_EQUAL(0,strcmp(pCopy, "12345"));
	delete[] pCopy;
    return true;
}
bool TestUtils::TestCopyWStr(void)
{
    wchar_t * pCopy = CopyWStr(L"12345");
    ASSERT_EQUAL(5,wcslen(pCopy));
    ASSERT_EQUAL(0,wcscmp(pCopy, L"12345"));
	delete[] pCopy;
	return true;
}
bool TestUtils::TestAddStr(void)
{
    char * pCopy = AddStr("12345", "6789");
    ASSERT_EQUAL(5,strlen(pCopy));
    ASSERT_EQUAL(0,strcmp(pCopy, "123456789"));
	delete[] pCopy;
	return true;
}
bool TestUtils::TestCpyStrBuff(void)
{
    char * pStr = "123\'0'45";
    char * pCopy = CpyStrBuff(pStr, 6);
    for (int i = 0; i < 6; i++)
        ASSERT_EQUAL(pCopy[i], pStr[i]);
	delete[] pCopy;
	return true;
}
bool TestUtils::TestAddStrBuff(void)
{
    char * pStr1 = "123\'0'5";
    char * pStr2 = "678\'0'";
    char * pCopy = AddStrBuff(pStr1, 5, pStr2, 4);
    
    int i = 0;
    for (i = 0; i < 5; i++)
        ASSERT_EQUAL(pCopy[i], pStr1[i]);
    for (i = 0; i < 4; i++)
        ASSERT_EQUAL(pCopy[i+5], pStr2[i]);
	delete[] pCopy;
	return true;
}
                     
                                
                    
                
            
                | # | 
                Change | 
                User | 
                Description | 
                Committed | 
                 | 
            
        
        
        
        
            
                | 
                    
                        #3                    
                 | 
                
                    28480                 | 
                
                    eskopljak                 | 
                
                    submit                 | 
                
                    
                 | 
                
                                            
                                                                
                                                                
                                                         | 
            
        
            
                | 
                    
                        #2                    
                 | 
                
                    28479                 | 
                
                    eskopljak                 | 
                
                    submit                 | 
                
                    
                 | 
                
                                                                                                        
                                     | 
            
        
            
                | 
                    
                        #1                    
                 | 
                
                    28441                 | 
                
                    eskopljak                 | 
                
                    Merging using p4api.net_branch                 | 
                
                    
                 | 
                
                                            
                                                                
                                                                
                                                         | 
            
                
    
                
            
                | 
                    
                    //guest/perforce_software/p4api-net/main/p4bridge-unit-test/TestUtils.cpp                 | 
            
        
        
        
        
            
                | 
                    
                        #1                    
                 | 
                
                    19043                 | 
                
                    Liz Lam                 | 
                
                    Rename p4api.net to p4api-net                 | 
                
                    
                 | 
                
                                            
                                                                
                                                                
                                                         | 
            
                
    
                
            
                | 
                    
                    //guest/perforce_software/p4api.net/main/p4bridge-unit-test/TestUtils.cpp                 | 
            
        
        
        
        
            
                | 
                    
                        #1                    
                 | 
                
                    19042                 | 
                
                    Liz Lam                 | 
                
                    Rename/move file(s) to proper main branch.                 | 
                
                    
                 | 
                
                                            
                                                                
                                                                
                                                         | 
            
                
    
                
            
                | 
                    
                    //guest/perforce_software/p4api.net/p4bridge-unit-test/TestUtils.cpp                 | 
            
        
        
        
        
            
                | 
                    
                        #3                    
                 | 
                
                    11220                 | 
                
                    Matt Attaway                 | 
                
                    Update Workshop version with most recent 14.2 patch of p4api.net                 | 
                
                    
                 | 
                
                                            
                                                                
                                                                
                                                         | 
            
        
            
                | 
                    
                        #2                    
                 | 
                
                    8964                 | 
                
                    Bill                 | 
                
                    fix line endings                 | 
                
                    
                 | 
                
                                            
                                                                
                                                                
                                                         | 
            
        
            
                | 
                    
                        #1                    
                 | 
                
                    8873                 | 
                
                    Matt Attaway                 | 
                
                    Initial add of the P4API.NET source code                 | 
                
                    
                 | 
                
                                            
                                                                
                                                                
                                                         |