mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-22 16:33:29 +00:00
Add tests
This commit is contained in:
parent
1286af2365
commit
17418f6ffc
4 changed files with 77 additions and 0 deletions
|
@ -175,6 +175,22 @@
|
|||
}
|
||||
}
|
||||
break;
|
||||
case 5:
|
||||
{
|
||||
NSString *first = [[nameArray objectAtIndex: 0] lowercaseString];
|
||||
if([first isEqualToString: @"mr."] ||
|
||||
[first isEqualToString: @"ms."] ||
|
||||
[first isEqualToString: @"mrs."] ||
|
||||
[first isEqualToString: @"dr."])
|
||||
{
|
||||
[pnc setNamePrefix: [nameArray objectAtIndex: 0]];
|
||||
[pnc setGivenName: [nameArray objectAtIndex: 1]];
|
||||
[pnc setMiddleName: [nameArray objectAtIndex: 2]];
|
||||
[pnc setFamilyName: [nameArray objectAtIndex: 3]];
|
||||
[pnc setNameSuffix: [nameArray objectAtIndex: 4]];
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
NSLog(@"Not sure how to parse %@", string);
|
||||
pnc = nil;
|
||||
|
|
29
Tests/base/NSPersonNameComponentsFormatter/GNUmakefile
Normal file
29
Tests/base/NSPersonNameComponentsFormatter/GNUmakefile
Normal file
|
@ -0,0 +1,29 @@
|
|||
# __GENERATED__ makefile marker
|
||||
#
|
||||
|
||||
include $(GNUSTEP_MAKEFILES)/common.make
|
||||
-include ../GNUmakefile.super
|
||||
|
||||
GNUSTEP_OBJ_DIR=./obj
|
||||
|
||||
TEST_TOOL_NAME = basic
|
||||
|
||||
ifeq ($(gcov),yes)
|
||||
ADDITIONAL_OBJCFLAGS += -ftest-coverage -fprofile-arcs
|
||||
ADDITIONAL_OBJCCFLAGS += -ftest-coverage -fprofile-arcs
|
||||
ADDITIONAL_LDFLAGS += -ftest-coverage -fprofile-arcs
|
||||
ADDITIONAL_TOOL_LIBS+=-lgcov
|
||||
endif
|
||||
|
||||
|
||||
basic_OBJC_FILES=basic.m
|
||||
|
||||
-include GNUmakefile.preamble
|
||||
-include make-check.mak
|
||||
include $(GNUSTEP_MAKEFILES)/test-tool.make
|
||||
-include GNUmakefile.postamble
|
||||
|
||||
after-clean::
|
||||
rm -f core core.* *.core \
|
||||
tests.log tests.sum oldtests.log oldtests.sum
|
||||
|
0
Tests/base/NSPersonNameComponentsFormatter/TestInfo
Normal file
0
Tests/base/NSPersonNameComponentsFormatter/TestInfo
Normal file
32
Tests/base/NSPersonNameComponentsFormatter/basic.m
Normal file
32
Tests/base/NSPersonNameComponentsFormatter/basic.m
Normal file
|
@ -0,0 +1,32 @@
|
|||
#import "ObjectTesting.h"
|
||||
#import <Foundation/NSAutoreleasePool.h>
|
||||
#import <Foundation/NSPersonNameComponentsFormatter.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
START_SET("NSPersonNameComponentsFormatter base");
|
||||
|
||||
NSPersonNameComponents *pnc = [[NSPersonNameComponents alloc] init];
|
||||
[pnc setGivenName: @"Gregory"];
|
||||
[pnc setMiddleName: @"John"];
|
||||
[pnc setFamilyName: @"Casamento"];
|
||||
[pnc setNameSuffix: @"PhD"];
|
||||
[pnc setNamePrefix: @"Dr."];
|
||||
|
||||
NSPersonNameComponentsFormatter *fmt = [[NSPersonNameComponentsFormatter alloc] init];
|
||||
NSPersonNameComponents *pnc2 = [fmt personNameComponentsFromString:
|
||||
@"Dr. Gregory John Casamento PhD"];
|
||||
PASS([[pnc givenName] isEqualToString:
|
||||
[pnc2 givenName]], "First name matches");
|
||||
PASS([[pnc middleName] isEqualToString:
|
||||
[pnc2 middleName]], "Middle name matches");
|
||||
PASS([[pnc familyName] isEqualToString:
|
||||
[pnc2 familyName]], "Family name matches");
|
||||
PASS([[pnc nameSuffix] isEqualToString:
|
||||
[pnc2 nameSuffix]], "Suffix name matches");
|
||||
PASS([[pnc namePrefix] isEqualToString:
|
||||
[pnc2 namePrefix]], "Prefix name matches");
|
||||
|
||||
END_SET("NSPersonNameComponentsFormatter base");
|
||||
return 0;
|
||||
}
|
Loading…
Reference in a new issue