@@ -4,16 +4,17 @@ context("test-wrap.R")
4
4
5
5
test_that(" stri_wrap" , {
6
6
expect_error(stri_wrap(" whatever" , 0 ))
7
- expect_error(stri_wrap(" what\n ever" ))
7
+ expect_error(stri_wrap(" what\n ever" , normalize = FALSE ))
8
8
expect_identical(stri_wrap(c(" " , " singleword" , NA ), cost = 0.0 ), c(" " , " singleword" , NA ))
9
9
expect_identical(stri_wrap(" a12345 b123456 c1234567" , 5 , 0.0 ), c(" a12345" , " b123456" , " c1234567" ))
10
10
expect_identical(stri_wrap(" a12345 b123456 c1234567" , 5 , 1.0 ), c(" a12345" , " b123456" , " c1234567" ))
11
11
expect_identical(stri_wrap(" a12345 b123456 c1234567" , 5 , 2.0 ), c(" a12345" , " b123456" , " c1234567" ))
12
12
expect_identical(stri_wrap(" a12345 b123456 c1234567" , 5 , 3.0 ), c(" a12345" , " b123456" , " c1234567" ))
13
13
14
14
expect_identical(stri_wrap(stri_paste(rep(" \u 0105\u 0105\u 0105\u 0105\u 0105" , 5 ), collapse = " " ), 12 ),
15
- c(" \u 0105\u 0105\u 0105\u 0105\u 0105" , " \u 0105\u 0105\u 0105\u 0105\u 0105 \u 0105\u 0105\u 0105\u 0105\u 0105" ,
16
- " \u 0105\u 0105\u 0105\u 0105\u 0105 \u 0105\u 0105\u 0105\u 0105\u 0105" ))
15
+ c(" \u 0105\u 0105\u 0105\u 0105\u 0105 \u 0105\u 0105\u 0105\u 0105\u 0105" ,
16
+ " \u 0105\u 0105\u 0105\u 0105\u 0105 \u 0105\u 0105\u 0105\u 0105\u 0105" ,
17
+ " \u 0105\u 0105\u 0105\u 0105\u 0105" ))
17
18
expect_identical(stri_wrap(stri_paste(rep(" \u 0105\u 0105\u 0105\u 0105\u 0105" , 5 ), collapse = " " ), 12 , cost = - 1 ),
18
19
c(" \u 0105\u 0105\u 0105\u 0105\u 0105 \u 0105\u 0105\u 0105\u 0105\u 0105" ,
19
20
" \u 0105\u 0105\u 0105\u 0105\u 0105 \u 0105\u 0105\u 0105\u 0105\u 0105" ,
@@ -79,23 +80,23 @@ test_that("stri_wrap", {
79
80
" quis augue ut massa pellentesque tincidunt. In sed pretium eros." )
80
81
)
81
82
82
- for (s in strings ) {
83
- for (i in c(12 ,20 ,30 ,40 )) {
84
- exponents <- c(0 , 1 , 2 , 3 )
85
- res <- vector(' list' , length(exponents ))
86
- for (j in seq_along(exponents ))
87
- res [[j ]] <- stri_wrap(s , i , cost_exponent = exponents [j ])
88
-
89
- for (j in seq_along(exponents ))
90
- expect_true(all(stri_length(res [[j ]]) < = i ))
91
-
92
- for (j in seq_along(exponents )[- 1 ]) {
93
- cost_greedy <- sum((i - stri_length(res [[1 ]]))^ exponents [j ])
94
- cost_dynamic <- sum((i - stri_length(res [[j ]]))^ exponents [j ])
95
- expect_true(cost_greedy > = cost_dynamic )
96
- }
97
- }
98
- }
83
+ # for (s in strings) { # to do: cost of the last line is zero since stringi_0.4-1
84
+ # for (i in c(12,20,30,40)) {
85
+ # exponents <- c(0, 1, 2, 3)
86
+ # res <- vector('list', length(exponents))
87
+ # for (j in seq_along(exponents))
88
+ # res[[j]] <- stri_wrap(s, i, cost_exponent=exponents[j])
89
+ #
90
+ # for (j in seq_along(exponents))
91
+ # expect_true(all(stri_length(res[[j]]) <= i))
92
+ #
93
+ # for (j in seq_along(exponents)[-1]) {
94
+ # cost_greedy <- sum((i-stri_length(res[[1]]))^exponents[j])
95
+ # cost_dynamic <- sum((i-stri_length(res[[j]]))^exponents[j])
96
+ # expect_true(cost_greedy >= cost_dynamic)
97
+ # }
98
+ # }
99
+ # }
99
100
})
100
101
101
102
0 commit comments