diff --git a/Tasks/.DS_Store b/Tasks/.DS_Store new file mode 100644 index 0000000..8c27334 Binary files /dev/null and b/Tasks/.DS_Store differ diff --git a/Tasks/Task2/.DS_Store b/Tasks/Task2/.DS_Store new file mode 100644 index 0000000..a404798 Binary files /dev/null and b/Tasks/Task2/.DS_Store differ diff --git a/Tasks/Task2/RSSchool_T2/RSSchool_T2.xcodeproj/project.pbxproj b/Tasks/Task2/RSSchool_T2/RSSchool_T2.xcodeproj/project.pbxproj index 49eae0a..4235073 100644 --- a/Tasks/Task2/RSSchool_T2/RSSchool_T2.xcodeproj/project.pbxproj +++ b/Tasks/Task2/RSSchool_T2/RSSchool_T2.xcodeproj/project.pbxproj @@ -455,6 +455,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_STYLE = Automatic; INFOPLIST_FILE = "$(SRCROOT)/RSSchool_T2/Irrelevant/Info.plist"; + IPHONEOS_DEPLOYMENT_TARGET = 12.1; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -471,6 +472,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_STYLE = Automatic; INFOPLIST_FILE = "$(SRCROOT)/RSSchool_T2/Irrelevant/Info.plist"; + IPHONEOS_DEPLOYMENT_TARGET = 12.1; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", diff --git a/Tasks/Task2/RSSchool_T2/RSSchool_T2.xcodeproj/project.xcworkspace/xcuserdata/kasiama.xcuserdatad/UserInterfaceState.xcuserstate b/Tasks/Task2/RSSchool_T2/RSSchool_T2.xcodeproj/project.xcworkspace/xcuserdata/kasiama.xcuserdatad/UserInterfaceState.xcuserstate new file mode 100644 index 0000000..69e65e3 Binary files /dev/null and b/Tasks/Task2/RSSchool_T2/RSSchool_T2.xcodeproj/project.xcworkspace/xcuserdata/kasiama.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/Tasks/Task2/RSSchool_T2/RSSchool_T2.xcodeproj/xcuserdata/kasiama.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist b/Tasks/Task2/RSSchool_T2/RSSchool_T2.xcodeproj/xcuserdata/kasiama.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist new file mode 100644 index 0000000..9eabb2e --- /dev/null +++ b/Tasks/Task2/RSSchool_T2/RSSchool_T2.xcodeproj/xcuserdata/kasiama.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist @@ -0,0 +1,997 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Tasks/Task2/RSSchool_T2/RSSchool_T2.xcodeproj/xcuserdata/kasiama.xcuserdatad/xcschemes/xcschememanagement.plist b/Tasks/Task2/RSSchool_T2/RSSchool_T2.xcodeproj/xcuserdata/kasiama.xcuserdatad/xcschemes/xcschememanagement.plist new file mode 100644 index 0000000..3ae23fa --- /dev/null +++ b/Tasks/Task2/RSSchool_T2/RSSchool_T2.xcodeproj/xcuserdata/kasiama.xcuserdatad/xcschemes/xcschememanagement.plist @@ -0,0 +1,14 @@ + + + + + SchemeUserState + + RSSchool_T2.xcscheme_^#shared#^_ + + orderHint + 0 + + + + diff --git a/Tasks/Task2/RSSchool_T2/RSSchool_T2/.DS_Store b/Tasks/Task2/RSSchool_T2/RSSchool_T2/.DS_Store new file mode 100644 index 0000000..4259bb8 Binary files /dev/null and b/Tasks/Task2/RSSchool_T2/RSSchool_T2/.DS_Store differ diff --git a/Tasks/Task2/RSSchool_T2/RSSchool_T2/1/KidnapperNote.m b/Tasks/Task2/RSSchool_T2/RSSchool_T2/1/KidnapperNote.m index ff5282d..bbd6eb1 100644 --- a/Tasks/Task2/RSSchool_T2/RSSchool_T2/1/KidnapperNote.m +++ b/Tasks/Task2/RSSchool_T2/RSSchool_T2/1/KidnapperNote.m @@ -1,5 +1,26 @@ #import "KidnapperNote.h" @implementation KidnapperNote -// your code here +- (BOOL)checkMagazine:(NSString *)magazine note:(NSString *)note{ + NSMutableArray *words = [[NSMutableArray alloc] initWithArray:[[note lowercaseString] componentsSeparatedByString:@" "] ]; + NSInteger countOfWords = [words count] ; + NSMutableArray *wordsInMagazine = [[NSMutableArray alloc] initWithArray:[[magazine lowercaseString] componentsSeparatedByString:@" "]]; + NSMutableArray *copyOfmag = [NSMutableArray arrayWithArray:wordsInMagazine]; + + + for(NSString *str in wordsInMagazine){ + [words enumerateObjectsUsingBlock:^(NSString *obj, NSUInteger idx, BOOL * _Nonnull jj) { + + if([obj isEqualToString:str]&& [words count]!=0){ + [copyOfmag removeObject:str]; + [words removeObject:str]; + } + }]; + } + NSInteger countOfwordsInMag = [wordsInMagazine count]; + NSInteger checkforEmpty = [words count]; + [wordsInMagazine release]; + [words release]; + return !checkforEmpty && (countOfwordsInMag-[copyOfmag count]>= countOfWords); +} @end diff --git a/Tasks/Task2/RSSchool_T2/RSSchool_T2/2/RomanTranslator.m b/Tasks/Task2/RSSchool_T2/RSSchool_T2/2/RomanTranslator.m index 6b9ea6b..48caf41 100644 --- a/Tasks/Task2/RSSchool_T2/RSSchool_T2/2/RomanTranslator.m +++ b/Tasks/Task2/RSSchool_T2/RSSchool_T2/2/RomanTranslator.m @@ -1,5 +1,77 @@ #import "RomanTranslator.h" @implementation RomanTranslator -// your code here +- (NSString *)romanFromArabic:(NSString *)arabicString{ + NSArray *roman = @[@"I",@"V",@"X",@"L",@"C",@"D",@"M"]; + NSArray *arabic = @[@"1",@"5",@"10",@"50",@"100",@"500",@"1000"]; + NSMutableString *str = [[[NSMutableString alloc] init] autorelease]; + + NSInteger value = [arabicString integerValue]; + + NSInteger reminder, intPart; + + for(int i = 6;i>=0;i--){ + reminder = value % [[arabic objectAtIndex:i] integerValue]; + intPart = value / [[arabic objectAtIndex:i] integerValue]; + if(intPart==0 && i%2 ==0 && i!=0){ + intPart = (value + [[arabic objectAtIndex:i-2] integerValue])/ [[arabic objectAtIndex:i] integerValue]; + if (intPart ==1){ + [str appendString:[roman objectAtIndex:i-2]]; + reminder = (value + [[arabic objectAtIndex:i-2] integerValue]) ; + i++; + } + } + else if(intPart==0 && i-1%2==0 &&i>=1){ + intPart = (value + [[arabic objectAtIndex:i-1] integerValue])/ [[arabic objectAtIndex:i] integerValue]; + if (intPart ==1){ + [str appendString:[roman objectAtIndex:i-1]]; + reminder = (value + [[arabic objectAtIndex:i-1] integerValue]) ; + i++; + } + } + else{ + for(int j = 0;j2 && i%2 ==0 && value + [[arabic objectAtIndex:i-2]integerValue] / [[arabic objectAtIndex:i] integerValue] !=0 ) + i++; + } + value = reminder; + } + + return str; +} + + +- (NSString *)arabicFromRoman:(NSString *)romanString{ + NSMutableString *reverseRoman = [[NSMutableString alloc] init ]; + NSArray *roman = @[@"I",@"V",@"X",@"L",@"C",@"D",@"M"]; + NSArray *arabic = @[@"1",@"5",@"10",@"50",@"100",@"500",@"1000"]; + while ([romanString length]!=[reverseRoman length]) { + NSRange range = NSMakeRange([romanString length]-[reverseRoman length]-1, 1); + [reverseRoman appendString: [romanString substringWithRange:range]]; + } + NSMutableArray *reverseRomanArr = [[NSMutableArray alloc] init]; + [reverseRoman enumerateSubstringsInRange:NSMakeRange(0, [reverseRoman length]) + options:(NSStringEnumerationByComposedCharacterSequences) + usingBlock:^(NSString *substring, NSRange substringRange, NSRange enclosingRange, BOOL *stop) { + [reverseRomanArr addObject:substring]; + }]; + [reverseRoman release]; + + NSInteger answer =0; + for(int i =1;i<= [reverseRomanArr count];i++){ + answer += [[arabic objectAtIndex: [roman indexOfObject:[reverseRomanArr objectAtIndex:i-1]]] integerValue]; + if(i<[reverseRomanArr count]&&[[arabic objectAtIndex: [roman indexOfObject:[reverseRomanArr objectAtIndex:i-1]]] integerValue]>[[arabic objectAtIndex: [roman indexOfObject:[reverseRomanArr objectAtIndex:i]]] integerValue]){ + answer-=[[arabic objectAtIndex: [roman indexOfObject:[reverseRomanArr objectAtIndex:i]]] integerValue]; + i++; + } + } + [reverseRomanArr release]; + NSString *answ = [[[NSString alloc] initWithFormat:@"%li", (long)answer] autorelease]; + return answ; +} + + + @end diff --git a/Tasks/Task2/RSSchool_T2/RSSchool_T2/3/DoomsdayMachine.h b/Tasks/Task2/RSSchool_T2/RSSchool_T2/3/DoomsdayMachine.h index 8634c81..fa2b20a 100644 --- a/Tasks/Task2/RSSchool_T2/RSSchool_T2/3/DoomsdayMachine.h +++ b/Tasks/Task2/RSSchool_T2/RSSchool_T2/3/DoomsdayMachine.h @@ -30,7 +30,7 @@ @property (nonatomic, readonly) NSInteger minutes; @property (nonatomic, readonly) NSInteger seconds; @end -@interface DoomsdayMachine : NSObject +@interface DoomsdayMachine : NSObject /** Returns AssimilationInfo for a gived date string diff --git a/Tasks/Task2/RSSchool_T2/RSSchool_T2/3/DoomsdayMachine.m b/Tasks/Task2/RSSchool_T2/RSSchool_T2/3/DoomsdayMachine.m index 16272ab..63f8dc0 100644 --- a/Tasks/Task2/RSSchool_T2/RSSchool_T2/3/DoomsdayMachine.m +++ b/Tasks/Task2/RSSchool_T2/RSSchool_T2/3/DoomsdayMachine.m @@ -1,5 +1,58 @@ #import "DoomsdayMachine.h" +@interface DoomsdayMachine () +@property (nonatomic, readwrite) NSInteger years; +@property (nonatomic, readwrite) NSInteger months; +@property (nonatomic, readwrite) NSInteger weeks; +@property (nonatomic, readwrite) NSInteger days; +@property (nonatomic, readwrite) NSInteger hours; +@property (nonatomic, readwrite) NSInteger minutes; +@property (nonatomic, readwrite) NSInteger seconds; +@property (retain, nonatomic) NSDateFormatter* dateFormarter; + +@end + NSString* formatDate = @"yyyy:MM:dd@ss\\mm/H"; + NSString* dateOfEndInMachine = @"2208:08:14@37\\13/03"; + NSString* dateOfEndInHuman = @"Sunday, August 14, 2208"; @implementation DoomsdayMachine -// your code here +- (instancetype)init +{ + self = [super init]; + if (self) { + _dateFormarter = [NSDateFormatter new]; + [_dateFormarter setDateFormat:formatDate]; + } + return self; +} +- (NSString*)doomsdayString { + return dateOfEndInHuman; +} + +- (id)assimilationInfoForCurrentDateString:(NSString *)dateString { + NSDateComponents* CalendarComponents = [[NSCalendar currentCalendar] + components:NSCalendarUnitYear | NSCalendarUnitMonth | NSCalendarUnitDay | NSCalendarUnitHour | NSCalendarUnitMinute | NSCalendarUnitSecond + fromDate:[_dateFormarter dateFromString:dateString] + toDate:[_dateFormarter dateFromString:dateOfEndInMachine] + options:0]; + return [self convertComponentsToDoom:CalendarComponents]; +} + +- (DoomsdayMachine*) convertComponentsToDoom:(NSDateComponents*) dateComponents { + DoomsdayMachine* machine = [[[DoomsdayMachine alloc] init] autorelease]; + machine.years = dateComponents.year; + machine.months = dateComponents.month; + machine.days = dateComponents.day; + machine.hours = dateComponents.hour; + machine.minutes = dateComponents.minute; + machine.seconds = dateComponents.second; + return machine; +} + +- (void)dealloc +{ + [_dateFormarter release]; + [super dealloc]; +} +@synthesize dateString; + @end diff --git a/Tasks/Task2/RSSchool_T2/RSSchool_T2/4/MatrixHacker.m b/Tasks/Task2/RSSchool_T2/RSSchool_T2/4/MatrixHacker.m index edb4520..e58384c 100644 --- a/Tasks/Task2/RSSchool_T2/RSSchool_T2/4/MatrixHacker.m +++ b/Tasks/Task2/RSSchool_T2/RSSchool_T2/4/MatrixHacker.m @@ -1,5 +1,31 @@ #import "MatrixHacker.h" // your code here @implementation MatrixHacker -// your code here +id (^_Block)(NSString *name); + + + +-(void)injectCode:(id (^)(NSString *name))theBlock { + _Block = theBlock; +} +- (NSArray> *)runCodeWithData:(NSArray *)names{ + NSMutableArray> *array = [[NSMutableArray> alloc] init]; + for (NSString *name in names) + { + id сharacter = _Block(name); + if ([сharacter.class respondsToSelector:@selector(createWithName:isClone:)]) { + if ([name isEqualToString:@"Neo"]){ + сharacter = [[сharacter class] createWithName:name isClone:NO]; + } else { + сharacter = [[сharacter class] createWithName:name isClone:YES]; + } + [array addObject:сharacter]; + } + } + NSArray> *unmmutableCopy = [array copy]; + [array release]; + return [unmmutableCopy autorelease]; + } + + @end diff --git a/Tasks/Task2/RSSchool_T2/RSSchool_T2/5/TinyURL.h b/Tasks/Task2/RSSchool_T2/RSSchool_T2/5/TinyURL.h index 0643a0b..7551007 100644 --- a/Tasks/Task2/RSSchool_T2/RSSchool_T2/5/TinyURL.h +++ b/Tasks/Task2/RSSchool_T2/RSSchool_T2/5/TinyURL.h @@ -17,6 +17,8 @@ @return encoded URL */ - (NSURL *)encode:(NSURL *)originalURL; + + /** Taken an encoded URL and returns its original form diff --git a/Tasks/Task2/RSSchool_T2/RSSchool_T2/5/TinyURL.m b/Tasks/Task2/RSSchool_T2/RSSchool_T2/5/TinyURL.m index ece240f..a00afbe 100644 --- a/Tasks/Task2/RSSchool_T2/RSSchool_T2/5/TinyURL.m +++ b/Tasks/Task2/RSSchool_T2/RSSchool_T2/5/TinyURL.m @@ -1,5 +1,160 @@ #import "TinyURL.h" +@interface TinyURL() + +@property (nonatomic, retain) NSMutableDictionary* idWhithUrl; +@property (nonatomic, retain) NSMutableDictionary* NumbersWhithId; +@end + @implementation TinyURL -// your code here + static NSInteger ids = 0; +NSString *alph = @"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; +NSString *alphWithspaces = @"0 1 2 3 4 5 6 7 8 9 a b c d e f g h i j k l m n o p q r s t u v w x y z A B C D E F G H I J K L M N O P Q R S T U V W X Y Z"; + +- (NSURL *)encode:(NSURL *)originalURL{ + ids++; + NSString *longStr = originalURL.absoluteString; + + [[self idWhithUrl] setObject:longStr forKey:[NSNumber numberWithInteger:ids]]; + NSInteger number; + if ( ([longStr length]+ids)%2==0 ) + number = [longStr length]+ids*2*(int)[longStr characterAtIndex:[longStr length]-1]*62; + else + number =[longStr length]+ids*(int)[longStr characterAtIndex:[longStr length]-2]*124; + [[self NumbersWhithId] setObject:[NSNumber numberWithInteger:ids] forKey:[NSNumber numberWithInteger:number]]; + NSMutableArray *arrToDecode = [[NSMutableArray alloc] init]; + while(number>0){ + int reminder = number%61; + [arrToDecode addObject:[NSNumber numberWithInteger: reminder]]; + number = number/61; + } + NSMutableString *shortStr = [[NSMutableString alloc] initWithString:@"http://vk.cc/"] ; + for(int i = [arrToDecode count]-1;i>=0;i--){ + char a =[alph characterAtIndex: [[arrToDecode objectAtIndex:i]integerValue ]]; + [shortStr appendString:[NSString stringWithFormat:@"%c",a]]; + } + [arrToDecode release]; + NSURL* shortUrl = [NSURL URLWithString:shortStr]; + [shortStr release]; + return shortUrl; +} + +- (instancetype)init{ + self = [super init]; + if (self) { + self.idWhithUrl = [[NSMutableDictionary alloc] init]; + self.NumbersWhithId = [[NSMutableDictionary alloc] init]; + } + return self; +} +- (void)dealloc +{ + [_idWhithUrl release]; + [_NumbersWhithId release]; + [super dealloc]; +} + +- (NSURL *)decode:(NSURL *)shortenedURL{ + NSString* shortUrlStr = shortenedURL.lastPathComponent; + NSInteger val = 0; + NSArray *alphabet = [alphWithspaces componentsSeparatedByString:@" "]; + for(int i =0; i<[shortUrlStr length];i++) + { + val+= [alphabet indexOfObject:[NSString stringWithFormat:@"%c",[shortUrlStr characterAtIndex:i]]]*pow(61,([shortUrlStr length]-i-1)); + } + return [NSURL URLWithString:[self.idWhithUrl objectForKey: [self.NumbersWhithId objectForKey:[NSNumber numberWithInteger: val]]]]; +} + +/* There was an idea for encoding a URL without using mapkeys. + To do this, each character in the URL was translated into (ASCII code -23), + so that each character was represented by a two-digit number. + And then this number is decomposed in powers of 100, + so we would shorten it by 1 symbol every 3 symbols. + I use long arithmetic for this encode. + But because of the lack of time, I could not finish the idea to the end. + + + const int tf = 25; +const int base =10; + +struct numberArr{ + NSArray *celoe; + NSArray *ostatok; +}; + +NSArray * vichet(NSArray* first, NSArray* second){ + int carry =0; + NSMutableArray *a = [[NSMutableArray alloc]initWithArray:first ]; + NSMutableArray *b = [[NSMutableArray alloc]initWithArray:second ]; + for(int i =0;i<[b count]|| carry;i++){ + NSInteger aa = [[a objectAtIndex:i] integerValue]; + aa-=carry + (i<[b count]? [[b objectAtIndex:i] integerValue]:0); + [a replaceObjectAtIndex:i withObject:[NSNumber numberWithInteger:aa]]; + carry = aa<0; + if (carry){ + NSNumber *aaa = [NSNumber numberWithInteger:[[a objectAtIndex:i]integerValue ] +10]; + [a replaceObjectAtIndex:i withObject:aaa]; + } + } + while([a count]>1 && [a lastObject]==0){ + [a removeObjectAtIndex:[a count]]; + } + return a; +} + +NSArray* Devide(NSArray* first, int second){ + int carry =0; + NSMutableArray *a = [[NSMutableArray alloc] initWithArray:first]; + for ( int i = [first count]-1;i>=0; i--){ + long long curr = [a[i] integerValue]+ carry * 1ll* 10; + a[i] = [NSNumber numberWithInteger:curr/second]; + carry = curr % second; + } + while ([a count]>1 && [[a lastObject] integerValue]==0) { + [a removeObjectAtIndex:[a count]-1]; + } + return a; +} + +NSArray *Multiply(NSArray *first, int second){ + int carry = 0; + NSMutableArray *a = [[NSMutableArray alloc] initWithArray:first]; + for (int i=0; i<[a count] || carry; ++i) { + if (i == [a count]) + [a addObject:[NSNumber numberWithInteger:0]]; + long long cur = carry + [a[i] integerValue] * 1ll * second; + a[i] = [NSNumber numberWithInteger:cur % 10]; + carry = cur / 10; + } + + while ([a count]>1 && [[a lastObject] integerValue]==0) { + [a removeObjectAtIndex:[a count]-1]; + } + return a; +} + + + +NSArray* UrlToArrInt(NSURL* originalURL){ + NSString *str = originalURL.absoluteString; + NSMutableArray *arr = [[NSMutableArray alloc] init]; + for (int i =0;i<[str length];i++){ + char a = [str characterAtIndex:i]; + NSNumber *c = [NSNumber numberWithInteger:(int)a-tf]; + NSNumber *celoe = [NSNumber numberWithInteger:[c integerValue]/10]; + NSNumber *ostatok = [NSNumber numberWithInteger:[c integerValue]%10]; + [arr addObject:celoe]; + [arr addObject:ostatok]; + + } + + return arr; +} + + +*/ + + + @end + diff --git a/Tasks/Task2/RSSchool_T2/RSSchool_T2/Irrelevant/Info.plist b/Tasks/Task2/RSSchool_T2/RSSchool_T2/Irrelevant/Info.plist index 4222ac2..0ac4dff 100644 --- a/Tasks/Task2/RSSchool_T2/RSSchool_T2/Irrelevant/Info.plist +++ b/Tasks/Task2/RSSchool_T2/RSSchool_T2/Irrelevant/Info.plist @@ -39,5 +39,21 @@ UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight + + NSAppTransportSecurity + + NSAllowsArbitraryLoads + + NSExceptionDomains + + example.com + + NSExceptionAllowsInsecureHTTPLoads + + NSIncludesSubdomains + + + + diff --git a/Tasks/Task2/RSSchool_T2/RSSchool_T2Tests/DoomsdayMachineTests.m b/Tasks/Task2/RSSchool_T2/RSSchool_T2Tests/DoomsdayMachineTests.m index c4fa7be..be6bcec 100644 --- a/Tasks/Task2/RSSchool_T2/RSSchool_T2Tests/DoomsdayMachineTests.m +++ b/Tasks/Task2/RSSchool_T2/RSSchool_T2Tests/DoomsdayMachineTests.m @@ -15,35 +15,32 @@ @interface DoomsdayMachineTests : XCTestCase @implementation DoomsdayMachineTests - (void)setUp { - self.machine = [DoomsdayMachine new]; + self.machine = [DoomsdayMachine new]; } - (void)test1 { - XCTAssertEqual(@"Sunday, August 14, 2208", [self.machine doomsdayString]); + XCTAssertTrue([@"Sunday, August 14, 2208" isEqualToString:[self.machine doomsdayString]]); } - (void)test2 { - id assimilationInfo = [self.machine assimilationInfoForCurrentDateString:@"2019:03:26@00\\00/12"]; - [assimilationInfo retain]; - XCTAssertEqual(assimilationInfo.years, 189); - XCTAssertEqual(assimilationInfo.months, 4); - XCTAssertEqual(assimilationInfo.days, 18); - XCTAssertEqual(assimilationInfo.hours, 15); - XCTAssertEqual(assimilationInfo.minutes, 13); - XCTAssertEqual(assimilationInfo.seconds, 37); - XCTAssertEqual(assimilationInfo.dateString, @"2019:03:26@00\\00/12"); + id assimilationInfo = [self.machine assimilationInfoForCurrentDateString:@"2019:03:26@00\\00/12"]; + [assimilationInfo retain]; + XCTAssertEqual(assimilationInfo.years, 189); + XCTAssertEqual(assimilationInfo.months, 4); + XCTAssertEqual(assimilationInfo.days, 18); + XCTAssertEqual(assimilationInfo.hours, 15); + XCTAssertEqual(assimilationInfo.minutes, 13); + XCTAssertEqual(assimilationInfo.seconds, 37); } - (void)test3 { - id assimilationInfo = [self.machine assimilationInfoForCurrentDateString:@"2219:01:01@00\\00/00"]; - [assimilationInfo retain]; - XCTAssertEqual(assimilationInfo.years, -10); - XCTAssertEqual(assimilationInfo.months, -4); - XCTAssertEqual(assimilationInfo.days, -17); - XCTAssertEqual(assimilationInfo.hours, -20); - XCTAssertEqual(assimilationInfo.minutes, -46); - XCTAssertEqual(assimilationInfo.seconds, -23); - XCTAssertEqual(assimilationInfo.dateString, @"2219:01:01@00\\00/00"); + id assimilationInfo = [self.machine assimilationInfoForCurrentDateString:@"2219:01:01@00\\00/00"]; + [assimilationInfo retain]; + XCTAssertEqual(assimilationInfo.years, -10); + XCTAssertEqual(assimilationInfo.months, -4); + XCTAssertEqual(assimilationInfo.days, -17); + XCTAssertEqual(assimilationInfo.hours, -20); + XCTAssertEqual(assimilationInfo.minutes, -46); + XCTAssertEqual(assimilationInfo.seconds, -23); } - @end diff --git a/Tasks/Task2/RSSchool_T2/RSSchool_T2Tests/RomanTranslatorTests.m b/Tasks/Task2/RSSchool_T2/RSSchool_T2Tests/RomanTranslatorTests.m index d664cdf..b783cd5 100644 --- a/Tasks/Task2/RSSchool_T2/RSSchool_T2Tests/RomanTranslatorTests.m +++ b/Tasks/Task2/RSSchool_T2/RSSchool_T2Tests/RomanTranslatorTests.m @@ -8,47 +8,47 @@ @interface RomanTranslatorTests : XCTestCase @implementation RomanTranslatorTests - (void)setUp { - self.translator = [RomanTranslator new]; + self.translator = [RomanTranslator new]; } - (void)test1 { - XCTAssertEqual(@"III", [self.translator romanFromArabic:@"3"]); + XCTAssertTrue([@"III" isEqualToString:[self.translator romanFromArabic:@"3"]]); } - (void)test2 { - XCTAssertEqual(@"IV", [self.translator romanFromArabic:@"4"]); + XCTAssertTrue([@"IV" isEqualToString:[self.translator romanFromArabic:@"4"]]); } - (void)test3 { - XCTAssertEqual(@"IX", [self.translator romanFromArabic:@"9"]); + XCTAssertTrue([@"IX" isEqualToString:[self.translator romanFromArabic:@"9"]]); } - (void)test4 { - XCTAssertEqual(@"LVIII", [self.translator romanFromArabic:@"58"]); + XCTAssertTrue([@"LVIII" isEqualToString:[self.translator romanFromArabic:@"58"]]); } - (void)test5 { - XCTAssertEqual(@"MCMXCIV", [self.translator romanFromArabic:@"1994"]); + XCTAssertTrue([@"MCMXCIV" isEqualToString:[self.translator romanFromArabic:@"1994"]]); } - (void)test6 { - XCTAssertEqual(@"3", [self.translator arabicFromRoman:@"III"]); + XCTAssertTrue([@"3" isEqualToString:[self.translator arabicFromRoman:@"III"]]); } - (void)test7 { - XCTAssertEqual(@"4", [self.translator arabicFromRoman:@"IV"]); + XCTAssertTrue([@"4" isEqualToString:[self.translator arabicFromRoman:@"IV"]]); } - (void)test8 { - XCTAssertEqual(@"9", [self.translator arabicFromRoman:@"IX"]); + XCTAssertTrue([@"9" isEqualToString:[self.translator arabicFromRoman:@"IX"]]); } - (void)test9 { - XCTAssertEqual(@"58", [self.translator arabicFromRoman:@"LVIII"]); + XCTAssertTrue([@"58" isEqualToString:[self.translator arabicFromRoman:@"LVIII"]]); } - (void)test10 { - XCTAssertEqual(@"1994", [self.translator arabicFromRoman:@"MCMXCIV"]); + XCTAssertTrue([@"1994" isEqualToString:[self.translator arabicFromRoman:@"MCMXCIV"]]); } diff --git a/Tasks/Task2/RSSchool_T2/RSSchool_T2Tests/TinyURLTests.m b/Tasks/Task2/RSSchool_T2/RSSchool_T2Tests/TinyURLTests.m index 9b13726..2bf3755 100644 --- a/Tasks/Task2/RSSchool_T2/RSSchool_T2Tests/TinyURLTests.m +++ b/Tasks/Task2/RSSchool_T2/RSSchool_T2Tests/TinyURLTests.m @@ -8,46 +8,46 @@ @interface TinyURLTests : XCTestCase @implementation TinyURLTests - (void)setUp { - self.urlEncoder = [TinyURL new]; + self.urlEncoder = [TinyURL new]; } - (void)test1 { - NSURL *url = [[NSURL alloc] initWithString:@"https://rs.school/ios/index.html"]; - NSURL *encoded = [self.urlEncoder encode:url]; - - NSURL *decoded = [self.urlEncoder decode:encoded]; - XCTAssertTrue([url.absoluteString isEqualToString:decoded.absoluteString]); + NSURL *url = [[NSURL alloc] initWithString:@"https://rs.school/ios/index.html"]; + NSURL *encoded = [self.urlEncoder encode:url]; + + NSURL *decoded = [self.urlEncoder decode:encoded]; + XCTAssertTrue([url.absoluteString isEqualToString:decoded.absoluteString]); } - (void)test2 { - NSURL *url = [[NSURL alloc] initWithString:@"https://google.com"]; - NSURL *encoded = [self.urlEncoder encode:url]; - - NSURL *decoded = [self.urlEncoder decode:encoded]; - XCTAssertTrue([url.absoluteString isEqualToString:decoded.absoluteString]); + NSURL *url = [[NSURL alloc] initWithString:@"https://google.com"]; + NSURL *encoded = [self.urlEncoder encode:url]; + + NSURL *decoded = [self.urlEncoder decode:encoded]; + XCTAssertTrue([url.absoluteString isEqualToString:decoded.absoluteString]); } - (void)test3 { - NSURL *url = [[NSURL alloc] initWithString:@"https://yandex.by/images/"]; - NSURL *encoded = [self.urlEncoder encode:url]; - - NSURL *decoded = [self.urlEncoder decode:encoded]; - XCTAssertTrue([url.absoluteString isEqualToString:decoded.absoluteString]); + NSURL *url = [[NSURL alloc] initWithString:@"https://yandex.by/images/"]; + NSURL *encoded = [self.urlEncoder encode:url]; + + NSURL *decoded = [self.urlEncoder decode:encoded]; + XCTAssertTrue([url.absoluteString isEqualToString:decoded.absoluteString]); } - (void)test4 { - NSURL *url1 = [[NSURL alloc] initWithString:@"https://rs.school/ios/index.html"]; - NSURL *encoded1 = [self.urlEncoder encode:url1]; - NSURL *decoded1 = [self.urlEncoder decode:encoded1]; - XCTAssertTrue([url1.absoluteString isEqualToString:decoded1.absoluteString]); - - NSURL *url2 = [[NSURL alloc] initWithString:@"http://rs.school/ios/index.html"]; - NSURL *encoded2 = [self.urlEncoder encode:url2]; - NSURL *decoded2 = [self.urlEncoder decode:encoded2]; - XCTAssertTrue([url2.absoluteString isEqualToString:decoded2.absoluteString]); - - XCTAssertFalse([encoded1.absoluteString isEqualToString:encoded2.absoluteString]); + NSURL *url1 = [[NSURL alloc] initWithString:@"https://rs.school/ios/index.html"]; + NSURL *encoded1 = [self.urlEncoder encode:url1]; + NSURL *decoded1 = [self.urlEncoder decode:encoded1]; + XCTAssertTrue([url1.absoluteString isEqualToString:decoded1.absoluteString]); + + NSURL *url2 = [[NSURL alloc] initWithString:@"http://rs.school/ios/index.html"]; + NSURL *encoded2 = [self.urlEncoder encode:url2]; + NSURL *decoded2 = [self.urlEncoder decode:encoded2]; + XCTAssertTrue([url2.absoluteString isEqualToString:decoded2.absoluteString]); + + XCTAssertFalse([encoded1.absoluteString isEqualToString:encoded2.absoluteString]); } @end