mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
v2.8.1.1
This commit is contained in:
@@ -26,15 +26,15 @@ public class Pfunc_case_tst {
|
||||
@Test public void Uc() {fxt.Test_parse_tmpl_str_test("{{uc:abc}}" , "{{test}}", "ABC");}
|
||||
@Test public void Uc_first() {fxt.Test_parse_tmpl_str_test("{{ucfirst:abc}}" , "{{test}}", "Abc");}
|
||||
@Test public void Multi_byte() {// NOTE: separate test b/c will sometimes fail in suite
|
||||
fxt.Wiki().Lang().Case_mgr_utf8_();
|
||||
fxt.Wiki().Lang().Case_mgr_u8_();
|
||||
fxt.Test_parse_tmpl_str_test("{{uc:ĉ}}" , "{{test}}", "Ĉ"); // upper all
|
||||
}
|
||||
@Test public void Multi_byte_asymmetric() {
|
||||
fxt.Wiki().Lang().Case_mgr_utf8_();
|
||||
fxt.Wiki().Lang().Case_mgr_u8_();
|
||||
fxt.Test_parse_tmpl_str_test("{{uc:ⱥ}}" , "{{test}}", "Ⱥ"); // handle multi-byte asymmetry (lc is 3 bytes; uc is 2 bytes)
|
||||
}
|
||||
@Test public void Multi_byte_first() {
|
||||
fxt.Wiki().Lang().Case_mgr_utf8_();
|
||||
fxt.Wiki().Lang().Case_mgr_u8_();
|
||||
fxt.Test_parse_tmpl_str_test("{{ucfirst:провинция}}" , "{{test}}", "Провинция"); // upper first; DATE:2014-02-04
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ public class Pfunc_pad extends Pf_func_base {
|
||||
int val_len = Utf8_.Len_of_bry(val); // NOTE: length must be in chars, not bytes, else won't work for non-ASCII chars; EX:niǎo has length of 4, not 5; PAGE:zh.d:不 DATE:2014-08-27
|
||||
|
||||
byte[] pad_len = Pf_func_.Eval_arg_or_empty(ctx, src, caller, self, self_args_len, 0);
|
||||
int pad_len_int = Bry_.Xto_int_or(pad_len, 0, pad_len.length, -1);
|
||||
int pad_len_int = Bry_.To_int_or(pad_len, 0, pad_len.length, -1);
|
||||
if (pad_len_int == -1) {bfr.Add(val); return;} // NOTE: if pad_len is non-int, add val and exit silently; EX: {{padleft: a|bad|0}}
|
||||
if (pad_len_int > 500) pad_len_int = 500; // MW: force it to be <= 500
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ public class Pfunc_pad_tst {
|
||||
@Test public void L_len_neg1() {fxt.Test_parse_tmpl_str_test("{{padleft: a|-1|01}}" , "{{test}}" , "a");}
|
||||
@Test public void L_val_null() {fxt.Test_parse_tmpl_str_test("{{padleft: |4|0}}" , "{{test}}" , "0000");}
|
||||
@Test public void L_word_3() {fxt.Test_parse_tmpl_str_test("{{padleft: abc|4}}" , "{{test}}" , "0abc");}
|
||||
@Test public void L_word_3_utf8() {fxt.Test_parse_tmpl_str_test("{{padleft: niǎo|5}}" , "{{test}}" , "0niǎo");} // PURPOSE:use length of String in chars, not bytes; PAGE:zh.d:不 DATE:2014-08-27
|
||||
@Test public void L_word_3_u8() {fxt.Test_parse_tmpl_str_test("{{padleft: niǎo|5}}" , "{{test}}" , "0niǎo");} // PURPOSE:use length of String in chars, not bytes; PAGE:zh.d:不 DATE:2014-08-27
|
||||
@Test public void L_exc_len_bad1() {fxt.Test_parse_tmpl_str_test("{{padleft:a|bad|01}}" , "{{test}}" , "a");}
|
||||
@Test public void L_exc_pad_ws() {fxt.Test_parse_tmpl_str_test("{{padleft:a|4|\n \t}}" , "{{test}}" , "a");}
|
||||
@Test public void R_len_3() {fxt.Test_parse_tmpl_str_test("{{padright:a|4|0}}" , "{{test}}" , "a000");}
|
||||
|
||||
Reference in New Issue
Block a user