NSString+ZZExTest.m 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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 * chinese = @"你莫走";
  13. NSString * chineseCharacter = @"你好,李银河!";
  14. NSString * num = @"1232131321";
  15. NSString * characterNum = @"Zz1232131321";
  16. describe(@"split", ^{
  17. it(@"emptyStr should have 1 component", ^{
  18. [[[emptyStr ZZSplit:@"3"] should] haveCountOf:1];
  19. });
  20. it(@"chinese should have 2 component", ^{
  21. [[[chinese ZZSplit:@"走"] should] haveCountOf:2];
  22. });
  23. it(@"chineseCharacter should have 2 component", ^{
  24. [[[chineseCharacter ZZSplit:@","] should] haveCountOf:2];
  25. });
  26. it(@"num should have 3 component", ^{
  27. [[[num ZZSplit:@"3"] should] haveCountOf:4];
  28. });
  29. });
  30. describe(@"replace", ^{
  31. it(@"emptyStr search with someone should return itself", ^{
  32. [[[emptyStr ZZReplace:@"" with:@" "] should] equal:emptyStr];
  33. });
  34. it(@"1 in num with $", ^{
  35. [[[num ZZReplace:@"1" with:@"$"] should] equal:@"$232$3$32$"];
  36. });
  37. });
  38. SPEC_END