PageRenderTime 8ms CodeModel.GetById 1ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/Tests/Objective-J/sprintfTest.j

http://github.com/cacaodev/cappuccino
Unknown | 37 lines | 28 code | 9 blank | 0 comment | 0 complexity | cda14bf75f7b3ec788a02674907071d7 MD5 | raw file
 1var sprintf = ObjectiveJ.sprintf;
 2
 3@implementation sprintfTest : OJTestCase
 4
 5// TODO: add many many more of these...
 6
 7- (void)testObjectWithPrefixAndSuffix
 8{
 9  [self assert:@"[hello world]" equals:sprintf(@"[%@]", @"hello world")];
10}
11
12- (void)testDecimalWithPrefixAndSuffix
13{
14  [self assert:@"[123]" equals:sprintf(@"[%d]", 123)];
15}
16
17- (void)testFloatWithPrefixAndSuffix
18{
19  [self assert:@"[123.1234]" equals:sprintf(@"[%f]", 123.1234)];
20}
21
22- (void)testZeroPaddingWithWidthAndPercentEscaping
23{
24  [self assert:@"099%" equals:sprintf(@"%03d%%", 99)];
25}
26
27- (void)testOutOfOrderExplicitFormatParameterIndexes
28{
29  [self assert:@"2 > 1" equals:sprintf(@"%2$d > %1$d", 1, 2)];
30}
31
32- (void)testMixingImplicitAndExplicitFormatParameterIndexes
33{
34  [self assert:@"a < b && b > a" equals:sprintf(@"%@ < %2$@ && %@ > %1$@", @"a", @"b")];
35}
36
37@end