NSString+ZZExTest.m 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. //
  2. // NSString+ZZExTest.m
  3. // ZZFoundation_Tests
  4. //
  5. // Created by Max on 2020/12/28.
  6. // Copyright © 2020 bymiracles@163.com. All rights reserved.
  7. //
  8. #import "Kiwi.h"
  9. #import <ZZFoundation.h>
  10. SPEC_BEGIN(StringEx)
  11. NSString * emptyStr = @"";
  12. NSString * emptyStr2 = @" ";
  13. NSString * emptyStr3 = @" ";
  14. NSString * emptyStr4 = @"\n";
  15. NSString * chinese = @"你莫走";
  16. NSString * chineseCharacter = @"你好,李银河!";
  17. NSString * num = @"1232131321";
  18. NSString * characterNum = @"Zz1232131321";
  19. describe(@"split", ^{
  20. it(@"emptyStr should passCheck", ^{
  21. [[theValue([emptyStr ZZEmpty]) should] beYes];
  22. // [[theValue([emptyStr1 ZZEmpty]) should] beYes];
  23. [[theValue([emptyStr2 ZZEmpty]) should] beYes];
  24. [[theValue([emptyStr3 ZZEmpty]) should] beYes];
  25. [[theValue([emptyStr4 ZZEmpty]) should] beYes];
  26. });
  27. it(@"emptyStr should have 1 component", ^{
  28. [[[emptyStr ZZSplit:@"3"] should] haveCountOf:1];
  29. });
  30. it(@"chinese should have 2 component", ^{
  31. [[[chinese ZZSplit:@"走"] should] haveCountOf:2];
  32. });
  33. it(@"chineseCharacter should have 2 component", ^{
  34. [[[chineseCharacter ZZSplit:@","] should] haveCountOf:2];
  35. });
  36. it(@"num should have 3 component", ^{
  37. [[[num ZZSplit:@"3"] should] haveCountOf:4];
  38. });
  39. });
  40. describe(@"replace", ^{
  41. it(@"emptyStr search with someone should return itself", ^{
  42. [[[emptyStr ZZReplace:@"" with:@" "] should] equal:emptyStr];
  43. });
  44. it(@"1 in num with $", ^{
  45. [[[num ZZReplace:@"1" with:@"$"] should] equal:@"$232$3$32$"];
  46. });
  47. });
  48. SPEC_END