Sha256: 4f6695b2ef9dc3fb1ca601c85398b0b1d169096e9caaf5f30482dfbda0df53c3

Contents?: true

Size: 1.68 KB

Versions: 31

Compression:

Stored size: 1.68 KB

Contents

//
//  NSStringTests.m
//  SampleProject
//
//  Created by Neil on 05/12/2012.
//  Copyright (c) 2012 @supermarin | supermar.in | All rights reserved.
//

#import "Kiwi.h"
#import "ObjectiveSugar.h"

SPEC_BEGIN(StringAdditions)

describe(@"Foundation-style functions", ^{

    it(@"NSStringWithFormat makes NSString -stringWithFormat", ^{

        [[NSStringWithFormat(@"This is %@", @1) should] equal:@"This is 1"];
    });

});

describe(@"Additions", ^{

    NSString *sentence = @"Jane Doe's going    in a shop,and,yeah;";

    it(@"-split splits by whitespace", ^{
        [[[@" the\r\nquick brown\t \tfox\n" split] should] equal:@[@"the", @"quick", @"brown", @"fox"]];
    });

    it(@"-split: splits with given delimiter", ^{
        [[[sentence split:@","] should] equal:@[@"Jane Doe's going    in a shop", @"and", @"yeah;"]];
    });

    it(@"-split: splits with delimiter string, not just a char", ^{
        [[[@"one / two / three" split:@" / "] should] equal:@[@"one", @"two", @"three"]];
    });

    it(@"contains string", ^{
        [[@([sentence containsString:@"jane doe"]) should] beTrue];
    });

    context(@"CamelCase and snake_case", ^{

        it(@"converts snake_cased to CamelCased", ^{
            [[[@"snake_case" camelCase] should] equal:@"SnakeCase"];
        });

        it(@"handles correctly snake case on beginning and at the end", ^{
            [[[@"_snake_case" camelCase] should] equal:@"SnakeCase"];
            [[[@"snake_case_" camelCase] should] equal:@"SnakeCase"];
        });

    });

    it(@"-strip strips whitespaces and newlines from both ends", ^{
        [[[@"  Look mo, no empties!   " strip] should] equal:@"Look mo, no empties!"];
    });

});



SPEC_END

Version data entries

31 entries across 31 versions & 3 rubygems

Version Path
xcpretty-0.4.0 spec/fixtures/NSStringTests.m
xcpretty-security-patched-0.3.2 spec/fixtures/NSStringTests.m
xcpretty-security-patched-0.3.0 spec/fixtures/NSStringTests.m
xcpretty-0.3.0 spec/fixtures/NSStringTests.m
xcpretty-0.2.8 spec/fixtures/NSStringTests.m
xcpretty-0.2.7 spec/fixtures/NSStringTests.m
xcpretty-0.2.6 spec/fixtures/NSStringTests.m
xcpretty-0.2.4 spec/fixtures/NSStringTests.m
xcpretty-0.2.3 spec/fixtures/NSStringTests.m
xcpretty-bb-0.1.12.bb14 spec/fixtures/NSStringTests.m
xcpretty-bb-0.1.12.bb13 spec/fixtures/NSStringTests.m
xcpretty-bb-0.1.12.bb12 spec/fixtures/NSStringTests.m
xcpretty-bb-0.1.12.bb11 spec/fixtures/NSStringTests.m
xcpretty-bb-0.1.12.bb10 spec/fixtures/NSStringTests.m
xcpretty-bb-0.1.12.bb9 spec/fixtures/NSStringTests.m
xcpretty-bb-0.1.12.bb8 spec/fixtures/NSStringTests.m
xcpretty-0.2.2 spec/fixtures/NSStringTests.m
xcpretty-bb-0.1.12.bb7 spec/fixtures/NSStringTests.m
xcpretty-0.2.1 spec/fixtures/NSStringTests.m
xcpretty-bb-0.1.12.bb6 spec/fixtures/NSStringTests.m