File tree Expand file tree Collapse file tree 2 files changed +15
-0
lines changed
tests/bytestring-tests/Properties Expand file tree Collapse file tree 2 files changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -502,9 +502,20 @@ null = coerce BSP.null
502
502
503
503
-- | /O(1)/ The length of a 'OsString'.
504
504
--
505
+ -- This returns the number of code units
506
+ -- (@Word8@ on unix and @Word16@ on windows), not
507
+ -- bytes.
508
+ --
509
+ -- >>> length "abc"
510
+ -- 3
511
+ --
505
512
-- @since 1.4.200.0
506
513
length :: PLATFORM_STRING -> Int
514
+ #ifdef WINDOWS
515
+ length = coerce BSP. numWord16
516
+ #else
507
517
length = coerce BSP. length
518
+ #endif
508
519
509
520
-- | /O(n)/ 'map' @f xs@ is the OsString obtained by applying @f@ to each
510
521
-- element of @xs@.
Original file line number Diff line number Diff line change @@ -454,6 +454,10 @@ tests =
454
454
455
455
, (" length" ,
456
456
property $ \ x -> numWord x === fromIntegral (length (B. unpack x)))
457
+ #if defined(OSWORD) || defined(WIN) || defined(POSIX)
458
+ , (" length abc" ,
459
+ once $ B. length (B. pack [0xbb , 0x03 ]) == 2 )
460
+ #endif
457
461
, (" count" ,
458
462
property $ \ (toElem -> c) x -> B. count c x === fromIntegral (length (elemIndices c (B. unpack x))))
459
463
, (" filter" ,
You can’t perform that action at this time.
0 commit comments