summaryrefslogtreecommitdiff
path: root/SmartDeviceLinkTests/RPCSpecs/StructSpecs/SDLTTSChunkSpec.m
blob: ef4d741ecaad162287d73e979dd221d1d34e341e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
//
//  SDLTTSChunkSpec.m
//  SmartDeviceLink


#import <Foundation/Foundation.h>

#import <Quick/Quick.h>
#import <Nimble/Nimble.h>

#import "SDLNames.h"
#import "SDLSpeechCapabilities.h"
#import "SDLTTSChunk.h"


QuickSpecBegin(SDLTTSChunkSpec)

describe(@"TTS Chunk Tests", ^{
    __block SDLTTSChunk *testStruct = nil;
    __block NSArray<SDLTTSChunk *> *testChunks = nil;
    __block NSString *testText = @"Text";
    __block SDLSpeechCapabilities testCapabilities = SDLSpeechCapabilitiesFile;

    describe(@"initializers", ^{
        it(@"should correctly initialize with init", ^{
            testStruct = [[SDLTTSChunk alloc] init];

            expect(testStruct.text).to(beNil());
            expect(testStruct.type).to(beNil());
        });

        it(@"should correctly initialize with initWithDictionary", ^{
            NSDictionary* dict = @{SDLNameText: testText,
                                   SDLNameType: testCapabilities};
            testStruct = [[SDLTTSChunk alloc] initWithDictionary:dict];

            expect(testStruct.text).to(equal(testText));
            expect(testStruct.type).to(equal(testCapabilities));
        });

        it(@"should correctly initialize with initWithText:type:", ^{
            testStruct = [[SDLTTSChunk alloc] initWithText:testText type:testCapabilities];

            expect(testStruct.text).to(equal(testText));
            expect(testStruct.type).to(equal(testCapabilities));
        });

        it(@"should correctly initialize with textChunksFromString:", ^{
            testChunks = [SDLTTSChunk textChunksFromString:testText];

            expect(testChunks).to(haveCount(1));
            expect(testChunks[0].text).to(equal(testText));
            expect(testChunks[0].type).to(equal(SDLSpeechCapabilitiesText));
        });

        it(@"should correctly initialize with sapiChunksFromString:", ^{
            testChunks = [SDLTTSChunk sapiChunksFromString:testText];

            expect(testChunks).to(haveCount(1));
            expect(testChunks[0].text).to(equal(testText));
            expect(testChunks[0].type).to(equal(SDLSpeechCapabilitiesSAPIPhonemes));
        });

        it(@"should correctly initialize with lhPlusChunksFromString:", ^{
            testChunks = [SDLTTSChunk lhPlusChunksFromString:testText];

            expect(testChunks).to(haveCount(1));
            expect(testChunks[0].text).to(equal(testText));
            expect(testChunks[0].type).to(equal(SDLSpeechCapabilitiesLHPlusPhonemes));
        });

        it(@"should correctly initialize with prerecordedChunksFromString:", ^{
            testChunks = [SDLTTSChunk prerecordedChunksFromString:testText];

            expect(testChunks).to(haveCount(1));
            expect(testChunks[0].text).to(equal(testText));
            expect(testChunks[0].type).to(equal(SDLSpeechCapabilitiesPrerecorded));
        });

        it(@"should correctly initialize with silenceChunksFromString:", ^{
            testChunks = [SDLTTSChunk silenceChunks];

            expect(testChunks).to(haveCount(1));
            expect(testChunks[0].text).to(beEmpty());
            expect(testChunks[0].type).to(equal(SDLSpeechCapabilitiesSilence));
        });

        it(@"should correctly initialize with fileChunksWithName:", ^{
            testChunks = [SDLTTSChunk fileChunksWithName:testText];

            expect(testChunks).to(haveCount(1));
            expect(testChunks[0].text).to(equal(testText));
            expect(testChunks[0].type).to(equal(SDLSpeechCapabilitiesFile));
        });
    });

    describe(@"Getter/Setter Tests", ^ {
        it(@"Should set and get correctly", ^ {
            SDLTTSChunk* testStruct = [[SDLTTSChunk alloc] init];

            testStruct.text = testText;
            testStruct.type = testCapabilities;

            expect(testStruct.text).to(equal(testText));
            expect(testStruct.type).to(equal(testCapabilities));
        });
    });
});



QuickSpecEnd