[Biococoa-dev] test question

Scott Christley schristley at mac.com
Sun Sep 24 20:46:34 EDT 2006


Hello,

So I'm looking at the tests, this test case fails:


//initializer with string
//using default symbol set
//string composed only of unknown symbols
- (void)testInitStringAllUnknown
{
	NSString *initial,*expected,*obtained;
	BCSequence *sequence;
	
	initial= @"123458()%$#@!#";
	expected=@"";
	sequence=[BCSequence sequenceWithString:initial symbolSet:  
[BCSymbolSet dnaSymbolSet]];
	//sequence=[BCSequence sequenceWithString:initial  
usingType:BCSequenceTypeDNA];
	obtained=[sequence sequenceString];
	//all the errors are concatenated
	NSMutableString *error=[NSMutableString stringWithString:@""];
	if (sequence==nil)
		[error appendString:@"Sequence is nil\n"];
	if (![obtained isEqual:expected])
		[error appendFormat:@"Sequence should be %@, but is %@\n",
			expected,obtained];
	if ([sequence sequenceType]!=BCSequenceTypeDNA)
		[error appendFormat:@"Sequence should be DNA but is %d\n",
			[sequence sequenceType]];
	if ([sequence symbolSet]!=[BCSymbolSet dnaSymbolSet])
		[error appendFormat:@"Symbol set should be %@ but is %@\n",
			[BCSymbolSet dnaSymbolSet],[sequence symbolSet]];
	if ([[sequence symbolSet] sequenceType]!=[sequence sequenceType])
		[error appendFormat:@"The symbol set is of type %d but should be of  
type %d, the same type as the sequence\n",
			[[sequence symbolSet] sequenceType],[sequence sequenceType]];
	//if error!=@"", the test failed
	STAssertTrue ( [error isEqualToString:@""],error);
}


Now it fails because obtained is nil instead of the empty string @""

I traced this down (pain to debug with the test framework but  
anyways) to the sequenceString method in BCSequence.m



- (NSString*)sequenceString
{
	unsigned int length = [self length];
	
	if ( length )
		return [self subSequenceStringInRange: NSMakeRange( 0, length ) ];
	else
		return nil;
}



So I think it should return the empty string if length == 0, not  
nil.  Sound right?  That fixes the test but wanted to check if that  
is desired behavior.

thanks
Scott

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.bioinformatics.org/pipermail/biococoa-dev/attachments/20060924/efd3d2b7/attachment.html>


More information about the Biococoa-dev mailing list