FRAQRUtilsTests.m revision a4c96a094a3d715ef793b60cfabfdb2ee088b319
9ebd9a731316dfd624ce3bcc4ea6519d10899936Ken Stubbings/*
9ebd9a731316dfd624ce3bcc4ea6519d10899936Ken Stubbings * The contents of this file are subject to the terms of the Common Development and
9ebd9a731316dfd624ce3bcc4ea6519d10899936Ken Stubbings * Distribution License (the License). You may not use this file except in compliance with the
9ebd9a731316dfd624ce3bcc4ea6519d10899936Ken Stubbings * License.
9ebd9a731316dfd624ce3bcc4ea6519d10899936Ken Stubbings *
9ebd9a731316dfd624ce3bcc4ea6519d10899936Ken Stubbings * You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
9ebd9a731316dfd624ce3bcc4ea6519d10899936Ken Stubbings * specific language governing permission and limitations under the License.
9ebd9a731316dfd624ce3bcc4ea6519d10899936Ken Stubbings *
9ebd9a731316dfd624ce3bcc4ea6519d10899936Ken Stubbings * When distributing Covered Software, include this CDDL Header Notice in each file and include
9ebd9a731316dfd624ce3bcc4ea6519d10899936Ken Stubbings * the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
9ebd9a731316dfd624ce3bcc4ea6519d10899936Ken Stubbings * Header, with the fields enclosed by brackets [] replaced by your own identifying
9ebd9a731316dfd624ce3bcc4ea6519d10899936Ken Stubbings * information: "Portions copyright [year] [name of copyright owner]".
9ebd9a731316dfd624ce3bcc4ea6519d10899936Ken Stubbings *
9ebd9a731316dfd624ce3bcc4ea6519d10899936Ken Stubbings * Copyright 2016 ForgeRock AS.
9ebd9a731316dfd624ce3bcc4ea6519d10899936Ken Stubbings */
9ebd9a731316dfd624ce3bcc4ea6519d10899936Ken Stubbings
9ebd9a731316dfd624ce3bcc4ea6519d10899936Ken Stubbings#import <XCTest/XCTest.h>
9ebd9a731316dfd624ce3bcc4ea6519d10899936Ken Stubbings
9ebd9a731316dfd624ce3bcc4ea6519d10899936Ken Stubbings#import "FRAQRUtils.h"
9ebd9a731316dfd624ce3bcc4ea6519d10899936Ken Stubbings
9ebd9a731316dfd624ce3bcc4ea6519d10899936Ken Stubbings@interface FRAQRUtilsTests : XCTestCase
9ebd9a731316dfd624ce3bcc4ea6519d10899936Ken Stubbings
9ebd9a731316dfd624ce3bcc4ea6519d10899936Ken Stubbings@end
9ebd9a731316dfd624ce3bcc4ea6519d10899936Ken Stubbings
9ebd9a731316dfd624ce3bcc4ea6519d10899936Ken Stubbings@implementation FRAQRUtilsTests
9ebd9a731316dfd624ce3bcc4ea6519d10899936Ken Stubbings
9ebd9a731316dfd624ce3bcc4ea6519d10899936Ken Stubbings- (void)testReplaceCharactersForURLDecodingReplacesDashes {
9ebd9a731316dfd624ce3bcc4ea6519d10899936Ken Stubbings
9ebd9a731316dfd624ce3bcc4ea6519d10899936Ken Stubbings NSString *content = @"-123-456-";
9ebd9a731316dfd624ce3bcc4ea6519d10899936Ken Stubbings
9ebd9a731316dfd624ce3bcc4ea6519d10899936Ken Stubbings NSString *result = [FRAQRUtils replaceCharactersForURLDecoding:content];
9ebd9a731316dfd624ce3bcc4ea6519d10899936Ken Stubbings
9ebd9a731316dfd624ce3bcc4ea6519d10899936Ken Stubbings XCTAssertEqualObjects(result, @"+123+456+");
9ebd9a731316dfd624ce3bcc4ea6519d10899936Ken Stubbings}
9ebd9a731316dfd624ce3bcc4ea6519d10899936Ken Stubbings
9ebd9a731316dfd624ce3bcc4ea6519d10899936Ken Stubbings- (void)testReplaceCharactersForURLDecodingReplacesUnderscores {
c0a2f8c6e84ddf9a597f19e5f161382b0e2cf81bDiego Colantoni
c0a2f8c6e84ddf9a597f19e5f161382b0e2cf81bDiego Colantoni NSString *content = @"_123_456_";
c0a2f8c6e84ddf9a597f19e5f161382b0e2cf81bDiego Colantoni
c0a2f8c6e84ddf9a597f19e5f161382b0e2cf81bDiego Colantoni NSString *result = [FRAQRUtils replaceCharactersForURLDecoding:content];
c0a2f8c6e84ddf9a597f19e5f161382b0e2cf81bDiego Colantoni
c0a2f8c6e84ddf9a597f19e5f161382b0e2cf81bDiego Colantoni XCTAssertEqualObjects(result, @"/123/456/");
9ebd9a731316dfd624ce3bcc4ea6519d10899936Ken Stubbings}
- (void)testReplaceCharactersForURLDecodingDoesntReplaceIfValid {
NSString *content = @"123456";
NSString *result = [FRAQRUtils replaceCharactersForURLDecoding:content];
XCTAssertEqualObjects(result, @"123456");
}
- (void)testDecodeBase64NilReturnsNil {
NSData *result = [FRAQRUtils decodeBase64:nil];
XCTAssertNil(result);
}
@end