Skip to content

Commit 7ef8021

Browse files
author
Kirill Makankov
committed
1. no more readwrite absoluteDataPath property.
2. Test for version 3. Test for initWithLanguage:engineMode 4. Tests for configEngine 5. Tests for resetEngine
1 parent 551238a commit 7ef8021

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed

TesseractOCR/G8Tesseract.mm

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ @interface G8Tesseract () {
3131
ETEXT_DESC *_monitor;
3232
}
3333

34-
@property (nonatomic, copy) NSString *absoluteDataPath;
3534
@property (nonatomic, strong) NSDictionary *configDictionary;
3635
@property (nonatomic, strong) NSArray *configFileNames;
3736
@property (nonatomic, strong) NSMutableDictionary *variables;
@@ -50,6 +49,8 @@ @interface G8Tesseract () {
5049

5150
@implementation G8Tesseract
5251

52+
@synthesize absoluteDataPath=_absoluteDataPath;
53+
5354
+ (NSString *)version
5455
{
5556
const char *version = tesseract::TessBaseAPI::Version();

TestsProject/TestsProjectTests/InitializationTests.m

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@
1212
#import <Kiwi/Kiwi.h>
1313
#import "Defaults.h"
1414

15+
@interface G8Tesseract (Tests)
16+
- (BOOL)configEngine;
17+
- (BOOL)resetEngine;
18+
@end
19+
1520
SPEC_BEGIN(TesseractInitialization)
1621

1722
describe(@"Tesseract initialization", ^{
@@ -43,6 +48,13 @@
4348
[[recognizedText should] equal:@"1234567890\n\n"];
4449
};
4550

51+
context(@"Should check common function", ^{
52+
53+
it(@"Should check version", ^{
54+
[[[G8Tesseract version] should] equal:@"3.03"];
55+
});
56+
});
57+
4658
context(@"nil cachesRelatedDataPath", ^{
4759

4860
it(@"Should initialize simple", ^{
@@ -51,6 +63,27 @@
5163
[[tesseract shouldNot] beNil];
5264

5365
[[tesseract.absoluteDataPath should] equal:resourcePath];
66+
67+
tesseract = [G8Tesseract alloc];
68+
[[tesseract shouldNot] beNil];
69+
NSAssert([tesseract respondsToSelector:@selector(configEngine)] == YES, @"Error! G8Tesseract instance does not contain configEngine selector");
70+
[[tesseract should] receive:@selector(configEngine) andReturn:theValue(NO)];
71+
tesseract = [tesseract init];
72+
73+
[[tesseract should] beNil];
74+
75+
tesseract = [[G8Tesseract alloc] init];
76+
NSAssert([tesseract respondsToSelector:@selector(resetEngine)] == YES, @"Error! G8Tesseract instance does not contain resetEngine selector");
77+
[[tesseract should] receive:@selector(configEngine) andReturn:theValue(NO)];
78+
[[theValue([tesseract resetEngine]) should] beNo];
79+
});
80+
81+
it(@"Should initialize simple with engine mode", ^{
82+
[[fileManager shouldNot] receive:@selector(createSymbolicLinkAtPath:withDestinationPath:error:)];
83+
G8Tesseract *tesseract = [[G8Tesseract alloc] initWithLanguage:kG8Languages engineMode:G8OCREngineModeTesseractOnly];
84+
[[tesseract shouldNot] beNil];
85+
86+
[[tesseract.absoluteDataPath should] equal:resourcePath];
5487
});
5588

5689
NSString *debugConfigsFilePathFromTheBundle = [[tessdataFolderPathFromTheBundle stringByAppendingPathComponent:tessConfigsFolderName] stringByAppendingPathComponent:debugConfigsFileName];

0 commit comments

Comments
 (0)