From 8f5bde279724a2e7cc9682a88f0770f2cacb121e Mon Sep 17 00:00:00 2001 From: daboe01 Date: Thu, 2 Jul 2020 19:38:34 +0200 Subject: [PATCH 1/6] new: unittest for replaceOccurrencesOfString:withString:options:range: --- Tests/Foundation/CPAttributedStringTest.j | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Tests/Foundation/CPAttributedStringTest.j b/Tests/Foundation/CPAttributedStringTest.j index 43321a28c..fab444a57 100644 --- a/Tests/Foundation/CPAttributedStringTest.j +++ b/Tests/Foundation/CPAttributedStringTest.j @@ -629,6 +629,17 @@ var sharedObject = [CPObject new]; [self assertTrue:[[self stringForTesting] isEqual:string] message:"setAttributedString should have made strings equal, but they were not"]; } +- (void)testReplaceAttributedString +{ + var string = [[CPMutableAttributedString alloc] initWithString:"HELLO
THERE"]; + [string replaceOccurrencesOfString:"
" + withString:"" + options:0 + range:nil] + + [self assertTrue:[string isEqual:"HELLO THERE"] message:"replaceOccurrencesOfString:withString:options:range: did not properly replace the search string with the replacement string"]; +} + - (void)testEncoding { // We can't test using [self stringForTesting] because it contains attributes without coding support. From 05f9fd22fe346dcf73a006c82b6d8cfb17b4a8e8 Mon Sep 17 00:00:00 2001 From: daboe01 Date: Fri, 3 Jul 2020 19:36:06 +0200 Subject: [PATCH 2/6] formatting --- Tests/Foundation/CPAttributedStringTest.j | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Tests/Foundation/CPAttributedStringTest.j b/Tests/Foundation/CPAttributedStringTest.j index fab444a57..86de83469 100644 --- a/Tests/Foundation/CPAttributedStringTest.j +++ b/Tests/Foundation/CPAttributedStringTest.j @@ -635,9 +635,9 @@ var sharedObject = [CPObject new]; [string replaceOccurrencesOfString:"
" withString:"" options:0 - range:nil] + range:nil]; - [self assertTrue:[string isEqual:"HELLO THERE"] message:"replaceOccurrencesOfString:withString:options:range: did not properly replace the search string with the replacement string"]; + [self assertTrue:[string isEqual:"HELLO THERE"] message:"replaceOccurrencesOfString:withString:options:range: did not properly replace the search string with the replacement string. Result is: " + string]; } - (void)testEncoding From 26e8432bb031c7ae3d57ad6b8f704ff43fad29ae Mon Sep 17 00:00:00 2001 From: daboe01 Date: Fri, 3 Jul 2020 19:55:51 +0200 Subject: [PATCH 3/6] debugging --- Tests/Foundation/CPAttributedStringTest.j | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/Foundation/CPAttributedStringTest.j b/Tests/Foundation/CPAttributedStringTest.j index 86de83469..7f64ff167 100644 --- a/Tests/Foundation/CPAttributedStringTest.j +++ b/Tests/Foundation/CPAttributedStringTest.j @@ -637,7 +637,7 @@ var sharedObject = [CPObject new]; options:0 range:nil]; - [self assertTrue:[string isEqual:"HELLO THERE"] message:"replaceOccurrencesOfString:withString:options:range: did not properly replace the search string with the replacement string. Result is: " + string]; + [self assertTrue:[string isEqual:"HELLO THERE"] message:"replaceOccurrencesOfString:withString:options:range: did not properly replace the search string with the replacement string. Result is: " + string._string]; } - (void)testEncoding From bd6b8e4b7f70f64a569ea37d2e5c96969e016ce5 Mon Sep 17 00:00:00 2001 From: daboe01 Date: Fri, 3 Jul 2020 21:27:48 +0200 Subject: [PATCH 4/6] fixed: comparison between wrong objects --- Tests/Foundation/CPAttributedStringTest.j | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/Foundation/CPAttributedStringTest.j b/Tests/Foundation/CPAttributedStringTest.j index 7f64ff167..2dab05e28 100644 --- a/Tests/Foundation/CPAttributedStringTest.j +++ b/Tests/Foundation/CPAttributedStringTest.j @@ -637,7 +637,7 @@ var sharedObject = [CPObject new]; options:0 range:nil]; - [self assertTrue:[string isEqual:"HELLO THERE"] message:"replaceOccurrencesOfString:withString:options:range: did not properly replace the search string with the replacement string. Result is: " + string._string]; + [self assertTrue:[string._string isEqual:"HELLO THERE"] message:"replaceOccurrencesOfString:withString:options:range: did not properly replace the search string with the replacement string. Result is: " + string._string]; } - (void)testEncoding From 4b052e74f14e963f52866e5dc43ea2541aa6a2b5 Mon Sep 17 00:00:00 2001 From: daboe01 Date: Sun, 5 Jul 2020 16:06:04 +0200 Subject: [PATCH 5/6] test whether range restriction works --- Tests/Foundation/CPAttributedStringTest.j | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Tests/Foundation/CPAttributedStringTest.j b/Tests/Foundation/CPAttributedStringTest.j index 2dab05e28..07061b958 100644 --- a/Tests/Foundation/CPAttributedStringTest.j +++ b/Tests/Foundation/CPAttributedStringTest.j @@ -640,6 +640,18 @@ var sharedObject = [CPObject new]; [self assertTrue:[string._string isEqual:"HELLO THERE"] message:"replaceOccurrencesOfString:withString:options:range: did not properly replace the search string with the replacement string. Result is: " + string._string]; } +- (void)testReplaceAttributedStringWithRange +{ + var string = [[CPMutableAttributedString alloc] initWithString:"HELLO
THERE"]; + [string replaceOccurrencesOfString:"
" + withString:"" + options:0 + range:CPMakeRange(0, 4)]; + + [self assertTrue:[string._string isEqual:"HELLO
THERE"] message:"replaceOccurrencesOfString:withString:options:range: did not respect the range restriction. Result is: " + string._string]; +} + + - (void)testEncoding { // We can't test using [self stringForTesting] because it contains attributes without coding support. From 9c95c9c6e9fa7d21c2a399e8bd0ea1c587722941 Mon Sep 17 00:00:00 2001 From: daboe01 Date: Mon, 13 Jul 2020 20:37:52 +0200 Subject: [PATCH 6/6] formatting --- Tests/Foundation/CPAttributedStringTest.j | 1 - 1 file changed, 1 deletion(-) diff --git a/Tests/Foundation/CPAttributedStringTest.j b/Tests/Foundation/CPAttributedStringTest.j index 07061b958..70d8b7c04 100644 --- a/Tests/Foundation/CPAttributedStringTest.j +++ b/Tests/Foundation/CPAttributedStringTest.j @@ -651,7 +651,6 @@ var sharedObject = [CPObject new]; [self assertTrue:[string._string isEqual:"HELLO
THERE"] message:"replaceOccurrencesOfString:withString:options:range: did not respect the range restriction. Result is: " + string._string]; } - - (void)testEncoding { // We can't test using [self stringForTesting] because it contains attributes without coding support.