1
0
mirror of https://github.com/gnosygnu/xowa.git synced 2026-03-02 03:49:30 +00:00

Refactor: @Test whitespace clean-up and other corelib changes

This commit is contained in:
gnosygnu
2021-11-28 08:16:54 -05:00
parent 2a4abd8f75
commit b0082fd231
1059 changed files with 23816 additions and 21909 deletions

View File

@@ -1,21 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry exported="true" kind="src" path="/baselib"/>
<classpathentry exported="true" kind="src" path="/100_core"/>
<classpathentry exported="true" kind="src" path="/140_dbs"/>
<classpathentry exported="true" kind="src" path="/150_gfui"/>
<classpathentry exported="true" kind="lib" path="lib/jtidy_xowa.jar"/>
<classpathentry exported="true" kind="src" path="/gplx.gflucene"/>
<classpathentry kind="src" path="src"/>
<classpathentry exported="true" kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry exported="true" kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
<classpathentry exported="true" kind="lib" path="lib/icu4j-57_1.jar"/>
<classpathentry exported="true" kind="lib" path="lib/vnu.jar"/>
<classpathentry exported="true" kind="lib" path="lib/Saxon-HE-9.9.1-2.jar"/>
<classpathentry exported="true" kind="src" path="/luaj_xowa"/>
<classpathentry exported="true" kind="lib" path="lib/utils-1.0.jar"/>
<classpathentry exported="true" kind="lib" path="lib/bcprov-jdk15on-164.jar"/>
<classpathentry exported="true" kind="lib" path="lib/gnu-crypto.jar"/>
<classpathentry exported="true" kind="lib" path="lib/jacksum.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View File

@@ -1,42 +1,42 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.core.brys; import gplx.*; import gplx.core.*;
import org.junit.*;
public class Bit__tst {
@Before public void init() {fxt.Clear();} private Bit__fxt fxt = new Bit__fxt();
@Test public void XtoBitStr() {
@Test public void XtoBitStr() {
tst_XtoBitStr( 0, "00000000");
tst_XtoBitStr( 1, "00000001");
tst_XtoBitStr( 2, "00000010");
tst_XtoBitStr( 3, "00000011");
tst_XtoBitStr(255, "11111111");
} void tst_XtoBitStr(int val, String expd) {Tfds.Eq(expd, Bit_.ToBitStr(val));}
@Test public void Shift_lhs() {// simple: shift 1 bit
@Test public void Shift_lhs() {// simple: shift 1 bit
fxt.Test_shift_lhs(1, 1, 2);
fxt.Test_shift_lhs(2, 1, 4);
fxt.Test_shift_lhs(3, 1, 6);
fxt.Test_shift_lhs(4, 1, 8);
}
@Test public void Shift_rhs() {
@Test public void Shift_rhs() {
fxt.Test_shift_rhs(2, 1, 1);
fxt.Test_shift_rhs(4, 1, 2);
fxt.Test_shift_rhs(6, 1, 3);
fxt.Test_shift_rhs(8, 1, 4);
}
@Test public void Shift_lhs_to_int() {
@Test public void Shift_lhs_to_int() {
int[] shift_ary = Int_ary_.New(0, 3, 5);
fxt.Test_shift_lhs_to_int(shift_ary, Int_ary_.New(0, 0, 0), 0);
fxt.Test_shift_lhs_to_int(shift_ary, Int_ary_.New(7, 0, 0), 7); // 1st 3 bits
@@ -44,7 +44,7 @@ public class Bit__tst {
fxt.Test_shift_lhs_to_int(shift_ary, Int_ary_.New(0, 0, 1), 32); // 3rd 1 bit
fxt.Test_shift_lhs_to_int(shift_ary, Int_ary_.New(7, 3, 1), 63); // many bits
}
@Test public void Shift_rhs_to_ary() {
@Test public void Shift_rhs_to_ary() {
int[] shift_ary = Int_ary_.New(0, 3, 5);
fxt.Test_shift_rhs_to_ary(shift_ary, 0, Int_ary_.New(0, 0, 0));
fxt.Test_shift_rhs_to_ary(shift_ary, 7, Int_ary_.New(7, 0, 0)); // 1st 3 bits

View File

@@ -1,23 +1,23 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.core.brys; import gplx.*; import gplx.core.*;
import org.junit.*;
public class Bit_heap_rdr_tst {
private final Bit_heap_rdr_fxt fxt = new Bit_heap_rdr_fxt();
@Test public void Get_bool() {
@Test public void Get_bool() {
fxt.Load(255);
fxt.Test__get_bool(Bool_.Y).Test__cur(127, 1, 0);
fxt.Test__get_bool(Bool_.Y).Test__cur( 63, 2, 0);
@@ -34,7 +34,7 @@ public class Bit_heap_rdr_tst {
fxt.Test__get_bool(Bool_.Y).Test__cur( 1, 2, 0);
fxt.Test__get_bool(Bool_.Y).Test__cur( 0, 3, 0);
}
@Test public void Get_byte() {
@Test public void Get_byte() {
fxt.Load(255).Test__get_byte(2, 3).Test__cur(63, 2, 0);
fxt.Load(255, 3);
fxt.Test__get_byte(7, 127);
@@ -43,7 +43,7 @@ public class Bit_heap_rdr_tst {
fxt.Test__get_bool(false);
fxt.Test__get_byte(3, 5);
}
@Test public void Get_int_hzip() {
@Test public void Get_int_hzip() {
fxt.Load(100).Test__get_int_hzip(1, 100).Test__cur(0, 0, 1);
fxt.Load(253, 1, 44).Test__get_int_hzip(1, 300).Test__cur(0, 0, 3);
fxt.Load(0, 100).Test__get_int_hzip(2, 100).Test__cur(0, 0, 2);

View File

@@ -1,45 +1,45 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.core.brys; import gplx.*; import gplx.core.*;
import org.junit.*;
public class Bit_heap_wtr_tst {
private final Bit_heap_wtr_fxt fxt = new Bit_heap_wtr_fxt();
@Test public void Add_bool() {
@Test public void Add_bool() {
fxt.Clear().Add_bool(Bool_.Y).Test__vals(1, 1);
fxt.Clear().Add_bool(Bool_.N).Test__vals(1, 0);
fxt.Clear().Add_bool(Bool_.Y, Bool_.Y, Bool_.Y, Bool_.Y).Test__vals(4, 15);
fxt.Clear().Add_bool(Bool_.Y, Bool_.N, Bool_.N, Bool_.Y).Test__vals(4, 9);
fxt.Clear().Add_bool(8, Bool_.Y).Test__vals(0, 0, 255);
}
@Test public void Add_byte() {
@Test public void Add_byte() {
fxt.Clear().Add_byte(255).Test__vals(0, 0, 255);
}
@Test public void Add_bool_byte() {
@Test public void Add_bool_byte() {
fxt.Clear().Add_bool(Bool_.N).Add_byte(255).Test__vals(1, 127, 254);
fxt.Clear().Add_bool(Bool_.Y).Add_byte(255).Test__vals(1, 127, 255);
fxt.Clear().Add_bool(Bool_.Y, Bool_.Y, Bool_.Y, Bool_.Y).Add_byte(255).Test__vals(4, 15, 255);
}
@Test public void Add_byte_digits() {
@Test public void Add_byte_digits() {
fxt.Clear().Add_byte(4, 15).Test__vals(4, 15);
fxt.Clear().Add_byte(7, 127).Add_byte(2, 3).Test__vals(1, 1, 255);
fxt.Clear().Add_byte(3, 7).Add_byte(3, 7).Test__vals(6, 63);
fxt.Clear().Add_byte(6, 63).Add_byte(3, 7).Test__vals(1, 1, 255);
fxt.Clear().Add_byte(3, 6).Add_byte(3, 6).Test__vals(6, 54);
}
@Test public void Add_int_hzip() {
@Test public void Add_int_hzip() {
fxt.Clear().Add_int_hzip(1, 100).Test__vals(0, 0, 100);
fxt.Clear().Add_int_hzip(1, 300).Test__vals(0, 0, 253, 1, 44);
fxt.Clear().Add_int_hzip(2, 100).Test__vals(0, 0, 0, 100);

View File

@@ -1,29 +1,29 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.core.brys; import gplx.*; import gplx.core.*;
import org.junit.*;
public class Bry_diff_tst {
@Before public void init() {} private final Bry_diff_fxt fxt = new Bry_diff_fxt();
@Test public void Diff_1st() {
@Test public void Diff_1st() {
fxt.Test__diff_1st("a|b|c" , "a|b|c" , null , null);
fxt.Test__diff_1st("a|b|c" , "a|b1|c" , "b" , "b1");
fxt.Test__diff_1st("a|b|" , "a|b|c" , "<<EOS>>" , "c");
fxt.Test__diff_1st("a|b|c" , "a|b|" , "c" , "<<EOS>>");
}
@Test public void Diff_1st_show() {
@Test public void Diff_1st_show() {
fxt.Test__diff_1st("a|b<c>d|e" , "a|b<c>e|e" , "<c>d", "<c>e");
}
}

View File

@@ -1,27 +1,27 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.core.brys; import gplx.*; import gplx.core.*;
import org.junit.*;
public class Int_flag_bldr__tst {
private final Int_flag_bldr__fxt fxt = new Int_flag_bldr__fxt();
@Test public void Bld_pow_ary() {
@Test public void Bld_pow_ary() {
fxt.Test__bld_pow_ary(fxt.Make__ary(1, 1, 1, 1), fxt.Make__ary(8, 4, 2, 1));
fxt.Test__bld_pow_ary(fxt.Make__ary(3, 2) , fxt.Make__ary(4, 1));
}
@Test public void To_int__1_1_1() {
@Test public void To_int__1_1_1() {
int[] seg_ary = fxt.Make__ary(1, 1, 1);
fxt.Test__to_int(seg_ary , fxt.Make__ary(0, 0, 0), 0);
fxt.Test__to_int(seg_ary , fxt.Make__ary(1, 1, 1), 7);
@@ -29,22 +29,22 @@ public class Int_flag_bldr__tst {
fxt.Test__to_int(seg_ary , fxt.Make__ary(1, 1, 0), 6);
fxt.Test__to_int(seg_ary , fxt.Make__ary(0, 1, 1), 3);
}
@Test public void To_int__2_3() {
@Test public void To_int__2_3() {
fxt.Test__to_int(fxt.Make__ary(2, 3) , fxt.Make__ary(3, 7) , 31);
fxt.Test__to_int(fxt.Make__ary(1, 2, 3) , fxt.Make__ary(1, 3, 7) , 63);
}
@Test public void To_int__11_4_5_5_6() {
@Test public void To_int__11_4_5_5_6() {
fxt.Test__to_int(fxt.Make__ary(11, 4, 5, 5, 6), fxt.Make__ary(2012, 6, 3, 23, 17), 2110135761);
fxt.Test__to_int(fxt.Make__ary(11, 4, 5, 5, 6), fxt.Make__ary(2012, 6, 3, 23, 18), 2110135762);
}
@Test public void To_int_ary() {
@Test public void To_int_ary() {
fxt.Test__to_int_ary(fxt.Make__ary(1, 1, 1, 1) , 15, fxt.Make__ary(1, 1, 1, 1));
fxt.Test__to_int_ary(fxt.Make__ary(3, 2) , 31, fxt.Make__ary(7, 3));
fxt.Test__to_int_ary(fxt.Make__ary(3, 2, 1) , 63, fxt.Make__ary(7, 3, 1));
fxt.Test__to_int_ary(fxt.Make__ary(12, 4, 5, 5, 6), 2110135761, fxt.Make__ary(2012, 6, 3, 23, 17));
fxt.Test__to_int_ary(fxt.Make__ary(12, 4, 5, 5, 6), 2110135762, fxt.Make__ary(2012, 6, 3, 23, 18));
}
@Test public void To_int_date_short() {
@Test public void To_int_date_short() {
fxt.Test__to_int_date_short("20120604 2359", 117843451);
fxt.Test__to_int_date_short("20120604 2358", 117843450);
fxt.Test__to_int_date_short("20120605 0000", 117843968);

View File

@@ -1,24 +1,24 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.core.btries; import gplx.*; import gplx.core.*;
import org.junit.*;
import gplx.xowa.langs.cases.*;
public class Btrie_u8_mgr_tst {
@Before public void init() {fxt.Clear();} private Btrie_u8_mgr_fxt fxt = new Btrie_u8_mgr_fxt();
@Test public void Ascii() {
@Test public void Ascii() {
fxt.Init_add(Bry_.new_a7("a") , "1");
fxt.Init_add(Bry_.new_a7("abc") , "123");
fxt.Test_match("a" , "1"); // single.exact
@@ -28,7 +28,7 @@ public class Btrie_u8_mgr_tst {
fxt.Test_match(" a" , null); // no_match
fxt.Test_match("aBC" , "123"); // upper
}
@Test public void Uft8() {
@Test public void Uft8() {
fxt.Init_add(Bry_.new_u8("aéi") , "1");
fxt.Test_match("aéi" , "1"); // exact
fxt.Test_match("aÉi" , "1"); // upper.utf8
@@ -36,12 +36,12 @@ public class Btrie_u8_mgr_tst {
fxt.Test_match("AÉIo" , "1"); // trailing-char
fxt.Test_match("aei" , null); // no_match
}
@Test public void Uft8_match_pos() {
@Test public void Uft8_match_pos() {
fxt.Init_add(Bry_.new_u8("aéi") , "1");
fxt.Test_match_pos("aAÉI" , 1, "1"); // match at 1
fxt.Test_match_pos("aAÉI" , 0, null); // no_match at 0
}
@Test public void Uft8_asymmetric() {
@Test public void Uft8_asymmetric() {
fxt.Init_add(Bry_.new_u8("İ") , "1");
fxt.Test_match("İ" , "1"); // exact=y; İ = Bry_.New_by_ints(196,176)
fxt.Test_match("i" , "1"); // lower=y; i = Bry_.New_by_ints(105)
@@ -53,21 +53,21 @@ public class Btrie_u8_mgr_tst {
fxt.Test_match("I" , "1"); // upper=y
fxt.Test_match("İ" , "1"); // utf_8=y; note that "i" matches "İ" b/c hash is case-insensitive and "İ" lower-cases to "i"; DATE:2015-09-07
}
@Test public void Utf8_asymmetric_multiple() { // PURPOSE: problems in original implementation of Hash_adp_bry and uneven source / target counts;
@Test public void Utf8_asymmetric_multiple() { // PURPOSE: problems in original implementation of Hash_adp_bry and uneven source / target counts;
fxt.Init_add(Bry_.new_u8("İİ") , "1");
fxt.Test_match("İİ" , "1"); // exact
fxt.Test_match("ii" , "1"); // lower
fxt.Test_match("İi" , "1"); // mixed
fxt.Test_match("" , "1"); // mixed
}
@Test public void Utf8_asymmetric_upper() { // PURPOSE: "İ" and "I" should co-exist; see Btrie_u8_itm and called_by_match
@Test public void Utf8_asymmetric_upper() { // PURPOSE: "İ" and "I" should co-exist; see Btrie_u8_itm and called_by_match
fxt.Init_add(Bry_.new_u8("İ") , "1");
fxt.Init_add(Bry_.new_u8("I") , "1");
fxt.Test_match("İ" , "1"); // exact
fxt.Test_match("I" , "1"); // exact
fxt.Test_match("i" , "1"); // lower
}
@Test public void Utf8_asymmetric_symbols() { // PURPOSE: test Hash_adp_bry and multi-byte syms (chars that will never be cased)
@Test public void Utf8_asymmetric_symbols() { // PURPOSE: test Hash_adp_bry and multi-byte syms (chars that will never be cased)
fxt.Init_add(Bry_.new_u8("a_b") , "1");
fxt.Test_match("a_b" , "1"); // exact: len=3
fxt.Test_match("a†b" , null); // diff : len=3

View File

@@ -1,33 +1,33 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.core.caches; import gplx.*; import gplx.core.*;
import org.junit.*; import gplx.core.tests.*; import gplx.core.envs.*;
public class Gfo_cache_mgr_tst {
@Before public void init() {fxt.Clear();} private final Gfo_cache_mgr_fxt fxt = new Gfo_cache_mgr_fxt();
@Test public void Basic() {
@Test public void Basic() {
fxt.Exec__add("a");
fxt.Test__cur_size(1);
fxt.Test__itms("a");
}
@Test public void Reduce() {
@Test public void Reduce() {
fxt.Exec__add("a", "b", "c", "d", "e");
fxt.Test__cur_size(2);
fxt.Test__itms("a", "b");
}
@Test public void Reduce_after_get() {
@Test public void Reduce_after_get() {
fxt.Exec__add("a", "b", "c", "d");
fxt.Exec__get("a", "c");
fxt.Exec__add("e");

View File

@@ -1,65 +1,65 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.core.consoles; import gplx.*; import gplx.core.*;
import org.junit.*; import gplx.core.tests.*; import gplx.core.envs.*;
public class Gfo_cmd_arg_mgr_tst {
@Before public void init() {fxt.Clear();} private final Gfo_cmd_arg_mgr_fxt fxt = new Gfo_cmd_arg_mgr_fxt();
@Test public void Val__many() {
@Test public void Val__many() {
fxt.Init_args(fxt.Make_arg("a"), fxt.Make_arg("b"));
fxt.Exec_process("--a", "0", "--b", "1");
fxt.Test_errs_none();
fxt.Test_actl(fxt.Make_chkr("a", "0"), fxt.Make_chkr("b", "1"));
}
@Test public void Val__yn() {
@Test public void Val__yn() {
fxt.Init_args(fxt.Make_arg("a", Gfo_cmd_arg_itm_.Val_tid_yn), fxt.Make_arg("b", Gfo_cmd_arg_itm_.Val_tid_yn));
fxt.Exec_process("--a", "y", "--b", "n");
fxt.Test_errs_none();
fxt.Test_actl(fxt.Make_chkr("a", Bool_.Y), fxt.Make_chkr("b", Bool_.N));
}
@Test public void Dflt() {
@Test public void Dflt() {
fxt.Init_args(fxt.Make_arg("a", Gfo_cmd_arg_itm_.Val_tid_yn).Dflt_(Bool_.Y));
fxt.Exec_process("--a", "n").Test_actl(fxt.Make_chkr("a", Bool_.N)); // if val, use it
fxt.Exec_process() .Test_actl(fxt.Make_chkr("a", Bool_.Y)); // if no val, use default
}
@Test public void Err__key__unknown() {
@Test public void Err__key__unknown() {
fxt.Init_args(fxt.Make_arg("a"));
fxt.Exec_process("--b");
fxt.Test_errs(Gfo_cmd_arg_mgr_.Err__key__unknown);
}
@Test public void Err__key__missing() {
@Test public void Err__key__missing() {
fxt.Init_args(fxt.Make_arg("a"));
fxt.Exec_process("a");
fxt.Test_errs(Gfo_cmd_arg_mgr_.Err__key__missing);
}
@Test public void Err__key__dupe() {
@Test public void Err__key__dupe() {
fxt.Init_args(fxt.Make_arg("a"));
fxt.Exec_process("--a", "0", "--a", "0");
fxt.Test_errs(Gfo_cmd_arg_mgr_.Err__key__duplicate);
}
@Test public void Err__val__reqd() {
@Test public void Err__val__reqd() {
fxt.Init_args(fxt.Make_arg("a", Bool_.Y), fxt.Make_arg("b", Bool_.N));
fxt.Exec_process("--b", "1");
fxt.Test_errs(Gfo_cmd_arg_mgr_.Err__val__required);
}
@Test public void Err__val__parse__yn() {
@Test public void Err__val__parse__yn() {
fxt.Init_args(fxt.Make_arg("a", Gfo_cmd_arg_itm_.Val_tid_yn));
fxt.Exec_process("--a", "x");
fxt.Test_errs(Gfo_cmd_arg_mgr_.Err__val__invalid__yn);
}
@Test public void Val_as_url_rel_dir_or() { // PURPOSE: "/xowa" -> "/xowa/"
@Test public void Val_as_url_rel_dir_or() { // PURPOSE: "/xowa" -> "/xowa/"
String root_dir = Op_sys.Cur().Tid_is_wnt() ? "C:\\" : "/", dir_spr = Op_sys.Cur().Fsys_dir_spr_str();
fxt.Test_val_as_url_rel_dir_or(root_dir, dir_spr, root_dir + "sub" , root_dir + "sub" + dir_spr); // /sub -> /sub/
fxt.Test_val_as_url_rel_dir_or(root_dir, dir_spr, root_dir + "sub" + dir_spr , root_dir + "sub" + dir_spr); // /sub/ -> /sub/

View File

@@ -1,39 +1,39 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.core.flds; import gplx.*; import gplx.core.*;
import org.junit.*;
import gplx.core.ios.*;
public class Gfo_fld_rdr_tst {
Gfo_fld_rdr_fxt fxt = new Gfo_fld_rdr_fxt();
@Test public void Read_int() {fxt.ini_xdat().Raw_("123|") .tst_Read_int(123);}
@Test public void Read_double() {fxt.ini_xdat().Raw_("1.23|") .tst_Read_double(1.23);}
@Test public void Read_str_simple() {fxt.ini_xdat().Raw_("ab|") .tst_Read_str_simple("ab");}
@Test public void Read_str_escape_pipe() {fxt.ini_xdat().Raw_("a~pb|") .tst_Read_str_escape("a|b");}
@Test public void Read_str_escape_tilde() {fxt.ini_xdat().Raw_("a~~b|") .tst_Read_str_escape("a~b");}
@Test public void Read_str_escape_nl() {fxt.ini_xdat().Raw_("a~nb|") .tst_Read_str_escape("a\nb");}
@Test public void Read_str_escape_tab() {fxt.ini_xdat().Raw_("a~tb|") .tst_Read_str_escape("a\tb");}
@Test public void Write_str_escape_pipe() {fxt.ini_xdat().tst_Write_str_escape("a|b", "a~pb|");}
@Test public void Read_str_quoted_comma() {fxt.ini_sql ().Raw_("'a,b',") .tst_Read_str_escape("a,b");}
@Test public void Read_str_quoted_apos() {fxt.ini_sql ().Raw_("'a\\'b',") .tst_Read_str_escape("a'b");}
@Test public void Read_multiple() {
@Test public void Read_int() {fxt.ini_xdat().Raw_("123|") .tst_Read_int(123);}
@Test public void Read_double() {fxt.ini_xdat().Raw_("1.23|") .tst_Read_double(1.23);}
@Test public void Read_str_simple() {fxt.ini_xdat().Raw_("ab|") .tst_Read_str_simple("ab");}
@Test public void Read_str_escape_pipe() {fxt.ini_xdat().Raw_("a~pb|") .tst_Read_str_escape("a|b");}
@Test public void Read_str_escape_tilde() {fxt.ini_xdat().Raw_("a~~b|") .tst_Read_str_escape("a~b");}
@Test public void Read_str_escape_nl() {fxt.ini_xdat().Raw_("a~nb|") .tst_Read_str_escape("a\nb");}
@Test public void Read_str_escape_tab() {fxt.ini_xdat().Raw_("a~tb|") .tst_Read_str_escape("a\tb");}
@Test public void Write_str_escape_pipe() {fxt.ini_xdat().tst_Write_str_escape("a|b", "a~pb|");}
@Test public void Read_str_quoted_comma() {fxt.ini_sql ().Raw_("'a,b',") .tst_Read_str_escape("a,b");}
@Test public void Read_str_quoted_apos() {fxt.ini_sql ().Raw_("'a\\'b',") .tst_Read_str_escape("a'b");}
@Test public void Read_multiple() {
fxt.ini_xdat().Raw_("ab|1|.9|\n")
.tst_Read_str_escape("ab").tst_Read_int(1).tst_Read_double(.9)
;
}
@Test public void Read_dlm_nl() {fxt.ini_xdat().Raw_("123\n") .tst_Read_int(123);}
@Test public void Read_dlm_nl() {fxt.ini_xdat().Raw_("123\n") .tst_Read_int(123);}
}
class Gfo_fld_rdr_fxt {
Gfo_fld_rdr rdr = new Gfo_fld_rdr(); Gfo_fld_wtr wtr = Gfo_fld_wtr.xowa_();

View File

@@ -1,18 +1,18 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.core.gfobjs; import gplx.*; import gplx.core.*;
import org.junit.*; import gplx.core.tests.*;
import gplx.langs.jsons.*;
@@ -37,7 +37,7 @@ public class Gfobj_rdr__json_tst {
, fxt.Make__fld_str ("k6", "abc")
));
}
@Test public void Nested() {
@Test public void Nested() {
fxt.Test__parse(String_.Concat_lines_nl_skip_last
( "{ 'a1':'1a'"
, ", 'a2':"
@@ -59,7 +59,7 @@ public class Gfobj_rdr__json_tst {
, fxt.Make__fld_ary ("a3", 1, 2, 3)
));
}
@Test public void Array() {
@Test public void Array() {
fxt.Test__parse(String_.Concat_lines_nl_skip_last
( "["
, " [1, 2, 3]"

View File

@@ -1,29 +1,29 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.core.ios; import gplx.*; import gplx.core.*;
import org.junit.*;
public class BinaryHeap_Io_line_rdr_tst {
public class BinaryHeap_Io_line_rdr_tst {
BinaryHeap_Io_line_rdr_fxt fxt = new BinaryHeap_Io_line_rdr_fxt();
@Test public void Add() {
@Test public void Add() {
fxt.Add("c", "a", "b").tst("a", "b", "c");
fxt.Add("b", "a", "a").tst("a", "a", "b");
fxt.Add("f", "b", "d", "c", "e", "a").tst("a", "b", "c", "d", "e", "f");
}
}
class BinaryHeap_Io_line_rdr_fxt {
class BinaryHeap_Io_line_rdr_fxt {
BinaryHeap_Io_line_rdr heap = new BinaryHeap_Io_line_rdr(Io_sort_split_itm_sorter.Instance); int file_total;
public BinaryHeap_Io_line_rdr_fxt Add(String... ary) {
file_total = ary.length;

View File

@@ -1,21 +1,21 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.core.ios; import gplx.*; import gplx.core.*;
import org.junit.*; import gplx.core.ios.*; import gplx.core.ios.streams.*;
public class Io_buffer_rdr_tst {
public class Io_buffer_rdr_tst {
@Before public void init() {
Io_mgr.Instance.InitEngine_mem();
fil = Io_url_.mem_fil_("mem/byteStreamRdr.txt");
@@ -23,7 +23,7 @@ public class Io_buffer_rdr_tst {
rdr = Io_buffer_rdr.new_(Io_stream_rdr_.New__raw(fil), 4);
} Io_buffer_rdr rdr; Io_url fil;
@After public void teardown() {rdr.Rls();}
@Test public void Bfr_load_all() {
@Test public void Bfr_load_all() {
tst_Bfr("0", "1", "2", "3").tst_ReadDone(false);
rdr.Bfr_load_all();
@@ -34,7 +34,7 @@ public class Io_buffer_rdr_tst {
rdr.Bfr_load_all(); // NOTE: change to zip_rdrs make eof detection difficult; force another load to ensure that file_pos goes past file_len
tst_ReadDone(true); // NOTE: bfr truncated from 4 to 2
}
@Test public void Bfr_load_from() {
@Test public void Bfr_load_from() {
tst_Bfr("0", "1", "2", "3").tst_ReadDone(false);
rdr.Bfr_load_from(3); // read from pos 3

View File

@@ -1,41 +1,41 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.core.ios; import gplx.*; import gplx.core.*;
import org.junit.*; import gplx.core.envs.*;
public class Io_line_rdr_tst {
public class Io_line_rdr_tst {
Io_line_rdr_fxt fxt;
@Before public void init() {
fxt = new Io_line_rdr_fxt(Io_url_.new_fil_("mem/test.txt"));
fxt.Clear();
}
@Test public void Basic() {
@Test public void Basic() {
fxt.File_lines_(3).tst_Read_til_lines(3, "00", "01", "02");
fxt.tst_Read_til_lines(1); // make sure nothing more is read
}
@Test public void Load_3x() {
@Test public void Load_3x() {
fxt.File_lines_(9).Load_len_lines_(3).tst_Read_til_lines(9, "00", "01", "02", "03", "04", "05", "06", "07", "08");
}
@Test public void Load_irregular() {
@Test public void Load_irregular() {
fxt.File_lines_(9).Load_len_(4).tst_Read_til_lines(9, "00", "01", "02", "03", "04", "05", "06", "07", "08");
}
@Test public void Load_multiple_files() {
@Test public void Load_multiple_files() {
fxt = new Io_line_rdr_fxt(Io_url_.new_fil_("mem/test0.txt"), Io_url_.new_fil_("mem/test1.txt"), Io_url_.new_fil_("mem/test2.txt"));
fxt.File_lines_(0, 0, 3).File_lines_(1, 3, 5).File_lines_(2, 5, 9).Load_len_(4).tst_Read_til_lines(9, "00", "01", "02", "03", "04", "05", "06", "07", "08");
}
@Test public void Match() {
@Test public void Match() {
fxt.File_lines_pipe_(9).Load_len_(6);
fxt.tst_Match("00", "00");
fxt.tst_Match("01", "01");
@@ -44,7 +44,7 @@ public class Io_line_rdr_tst {
fxt.tst_Match("12", "");
}
}
class Io_line_rdr_fxt {
class Io_line_rdr_fxt {
Io_line_rdr rdr;
List_adp lines = List_adp_.New(); Bry_bfr tmp = Bry_bfr_.New();
public Io_line_rdr_fxt(Io_url... urls) {rdr = new Io_line_rdr(Gfo_usr_dlg_.Test(), urls);}

View File

@@ -1,24 +1,24 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.core.ios; import gplx.*; import gplx.core.*;
import org.junit.*;
public class Io_sort_misc_tst {
@Before public void init() {
}
@Test public void Io_url_gen_dir() {
@Test public void Io_url_gen_dir() {
tst_Io_url_gen_dir("mem/dir/", "{0}.xdat", 4, 3, "0000.xdat", "0001.xdat", "0002.xdat");
}
private void tst_Io_url_gen_dir(String dir_str, String fmt, int digits, int calls, String... expd) {
@@ -32,7 +32,7 @@ public class Io_sort_misc_tst {
expd[i] = dir_str + expd[i];
Tfds.Eq_ary_str(expd, actl);
}
@Test public void Io_line_rdr_comparer_all() {
@Test public void Io_line_rdr_comparer_all() {
tst_Io_line_rdr_fld_comparer(-1, "a", "b");
tst_Io_line_rdr_fld_comparer( 0, "a", "a");
tst_Io_line_rdr_fld_comparer( 1, "b", "a");
@@ -50,7 +50,7 @@ public class Io_sort_misc_tst {
rv.Read_next();
return rv;
}
@Test public void ExternalSort() {
@Test public void ExternalSort() {
// fxt("c", "a", "b")
}
}

View File

@@ -1,23 +1,23 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.core.ios; import gplx.*; import gplx.core.*;
import org.junit.*; import gplx.core.strings.*;
public class Io_sort_tst {
Io_sort_fxt fxt = new Io_sort_fxt();
@Test public void ExternalSort() {
@Test public void ExternalSort() {
fxt.Clear().Memory_max_(12).Src_(fxt.GenRandom(6, 4)).Sorted_(fxt.GenOrdered(6, 4)).tst();
fxt.Clear().Memory_max_(64).Src_(fxt.GenRandom(50, 4)).Sorted_(fxt.GenOrdered(50, 4)).tst();
}

View File

@@ -1,29 +1,29 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.core.lists; import gplx.*; import gplx.core.*;
import org.junit.*; import gplx.core.tests.*;
import gplx.core.primitives.*;
public class Binary_heap_tst {
private final Binary_heap_fxt fxt = new Binary_heap_fxt();
@Test public void Max() {
@Test public void Max() {
fxt.Init(Bool_.Y);
fxt.Exec__add(4, 3, 5, 7, 1, 6, 9, 8, 2);
fxt.Test__pop(9, 8, 7, 6, 5, 4, 3, 2, 1);
}
@Test public void Min() {
@Test public void Min() {
fxt.Init(Bool_.N);
fxt.Exec__add(4, 3, 5, 7, 1, 6, 9, 8, 2);
fxt.Test__pop(1, 2, 3, 4, 5, 6, 7, 8, 9);

View File

@@ -1,23 +1,23 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.core.lists; import gplx.*; import gplx.core.*;
import org.junit.*; import gplx.core.tests.*;
public class Queue_adp_tst {
private final Queue_adp_fxt fxt = new Queue_adp_fxt();
@Test public void Empty() {
@Test public void Empty() {
boolean pass = true;
try {
fxt.Test__dequeue(null, -1);
@@ -28,11 +28,11 @@ public class Queue_adp_tst {
}
if (pass) throw Err_.new_wo_type("empty should have failed");
}
@Test public void Add_1() {
@Test public void Add_1() {
fxt.Exec__enqueue("a");
fxt.Test__dequeue("a", 0);
}
@Test public void Add_n() {
@Test public void Add_n() {
fxt.Exec__enqueue("a");
fxt.Exec__enqueue("b");
fxt.Exec__enqueue("c");
@@ -40,7 +40,7 @@ public class Queue_adp_tst {
fxt.Test__dequeue("b", 1);
fxt.Test__dequeue("c", 0);
}
@Test public void Mix() {
@Test public void Mix() {
fxt.Exec__enqueue("a");
fxt.Exec__enqueue("b");
fxt.Test__dequeue("a", 1);

View File

@@ -1,24 +1,24 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.core.lists; import gplx.*; import gplx.core.*;
import org.junit.*;
public class StatRng_tst {
// Mwl_parser_fxt fx = new Mwl_parser_fxt(); Pf_func_lang_rsc rsc = Pf_func_lang_rsc.Instance;
StatRng_fxt fx = new StatRng_fxt();
@Test public void Empty() {
@Test public void Empty() {
fx.ini_(1, 1, 5);
fx.Count_(7).Lo_(2).Hi_(8).Avg_(5)
.Lo_ary_(2)
@@ -26,9 +26,9 @@ public class StatRng_tst {
.Slots_(3, 4);
fx.tst_(5,7,2,8,3,4,6);
}
//@Test public void Basic() {fx.Test_parse_tmpl_str_test("{{#switch:{{{1}}}|a=1|b=2|3}}", "{{test|a}}", "1");}
//@Test public void Basic() {fx.Test_parse_tmpl_str_test("{{#switch:{{{1}}}|b=2|#default=3|a=1}}", "{{test|a}}", "1");}
//@Test public void Basic() {fx.Test_parse_tmpl_str_test("{{#switch:{{{1}}}|a|b|c=1|d=2}}", "{{test|a}}", "1");}
//@Test public void Basic() {fx.Test_parse_tmpl_str_test("{{#switch:{{{1}}}|a=1|b=2|3}}", "{{test|a}}", "1");}
//@Test public void Basic() {fx.Test_parse_tmpl_str_test("{{#switch:{{{1}}}|b=2|#default=3|a=1}}", "{{test|a}}", "1");}
//@Test public void Basic() {fx.Test_parse_tmpl_str_test("{{#switch:{{{1}}}|a|b|c=1|d=2}}", "{{test|a}}", "1");}
}
/*
public class Pf_func_switch_tst {

View File

@@ -1,23 +1,23 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.core.lists.binary_searches; import gplx.*; import gplx.core.*; import gplx.core.lists.*;
import org.junit.*; import gplx.core.primitives.*;
public class Binary_search__tst {
private final Binary_search__fxt fxt = new Binary_search__fxt();
@Test public void Basic() {
@Test public void Basic() {
fxt.Init__ary("", "e", "j", "o", "t", "y");
fxt.Test__binary_search("a", 0);
fxt.Test__binary_search("f", 1);
@@ -26,11 +26,11 @@ public class Binary_search__tst {
fxt.Test__binary_search("u", 4);
fxt.Test__binary_search("z", 5);
}
@Test public void One() {
@Test public void One() {
fxt.Init__ary("");
fxt.Test__binary_search("a", 0);
}
@Test public void Catpage() {
@Test public void Catpage() {
String[] ary = new String[25];
for (int i = 0; i < 25; ++i)
ary[i] = Int_.To_str_pad_bgn_zero(i, 2);

View File

@@ -1,18 +1,18 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.core.lists.caches; import gplx.*; import gplx.core.*; import gplx.core.lists.*;
import org.junit.*; import gplx.core.tests.*;
public class Mru_cache_mgr_tst {
@@ -20,30 +20,30 @@ public class Mru_cache_mgr_tst {
@Before public void init() {
fxt.Init__New_cache_mgr(3, 3, 2);
}
@Test public void Basic() {
@Test public void Basic() {
fxt.Exec__Add("a", "b", "c", "d");
fxt.Test__Print("b", "c", "d"); // adding "d" pushes out "a"
}
@Test public void Used() {
@Test public void Used() {
fxt.Exec__Add("a", "b", "c");
fxt.Exec__Get_and_compress("a");
fxt.Test__Print("b", "c", "a"); // getting "a" pushes to back
}
@Test public void Used__more_uses_at_back() {
@Test public void Used__more_uses_at_back() {
fxt.Exec__Add("a", "b", "c");
fxt.Exec__Get_and_compress("a", "a", "a");
fxt.Test__Print("b", "c", "a");
fxt.Exec__Get_and_compress("b");
fxt.Test__Print("c", "b", "a"); // getting "a" multiple time still keeps towards back
}
@Test public void Time() {
@Test public void Time() {
fxt.Exec__Add("a", "b", "c");
fxt.Exec__Get_and_compress("a", "a", "a");
fxt.Exec__Wait(10);
fxt.Exec__Get_and_compress("b");
fxt.Test__Print("c", "a", "b"); // long wait puts "b" at back
}
@Test public void Compress() {
@Test public void Compress() {
fxt.Init__New_cache_mgr(3, 2, 2);
fxt.Exec__Add("a", "b", "c", "d");
fxt.Test__Print("c", "d");

View File

@@ -1,129 +1,129 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.core.net; import gplx.*; import gplx.core.*;
import org.junit.*;
public class Gfo_url_parser_tst {
private final Gfo_url_parser_fxt tstr = new Gfo_url_parser_fxt();
@Test public void Protocol__relative() {
@Test public void Protocol__relative() {
tstr.Exec__parse("//en.wikipedia.org").Test__protocol_tid(Gfo_protocol_itm.Tid_relative_1).Test__protocol_bry("//").Test__site("en.wikipedia.org");
}
@Test public void Protocol__none() {
@Test public void Protocol__none() {
tstr.Exec__parse("en.wikipedia.org/wiki/A").Test__protocol_tid(Gfo_protocol_itm.Tid_unknown).Test__segs("en.wikipedia.org", "wiki", "A");
}
@Test public void Site__parts__3() {
@Test public void Site__parts__3() {
tstr.Exec__parse("https://en.wikipedia.org").Test__protocol_tid(Gfo_protocol_itm.Tid_https).Test__protocol_bry("https://").Test__segs("en.wikipedia.org");
}
@Test public void Site__parts__2() {
@Test public void Site__parts__2() {
tstr.Exec__parse("https://wikipedia.org").Test__protocol_tid(Gfo_protocol_itm.Tid_https).Test__segs("wikipedia.org");
}
@Test public void Site__parts__1() {
@Test public void Site__parts__1() {
tstr.Exec__parse("https://wikipedia").Test__protocol_tid(Gfo_protocol_itm.Tid_https).Test__segs("wikipedia");
}
@Test public void Site__slash__none() {
@Test public void Site__slash__none() {
tstr.Exec__parse("https:site").Test__protocol_tid(Gfo_protocol_itm.Tid_https).Test__site("site");
}
@Test public void Site__slash__eos() {
@Test public void Site__slash__eos() {
tstr.Exec__parse("https://en.wikipedia.org/").Test__protocol_tid(Gfo_protocol_itm.Tid_https).Test__site("en.wikipedia.org");
}
@Test public void Paths__1() {
@Test public void Paths__1() {
tstr.Exec__parse("https://site/A").Test__segs("site", "A");
}
@Test public void Paths__2() {
@Test public void Paths__2() {
tstr.Exec__parse("https://site/wiki/A").Test__segs("site", "wiki", "A");
}
@Test public void Paths__n() {
@Test public void Paths__n() {
tstr.Exec__parse("https://site/wiki/A/B/C/D").Test__segs("site", "wiki", "A", "B", "C", "D");
}
@Test public void Qargs__1() {
@Test public void Qargs__1() {
tstr.Exec__parse("https://site/A?B=C").Test__page("A").Test__qargs("B", "C");
}
@Test public void Qargs__2() {
@Test public void Qargs__2() {
tstr.Exec__parse("https://site/A?B=C&D=E").Test__page("A").Test__qargs("B", "C", "D", "E");
}
@Test public void Qargs__3() {
@Test public void Qargs__3() {
tstr.Exec__parse("https://site/A?B=C&D=E&F=G").Test__page("A").Test__qargs("B", "C", "D", "E", "F", "G");
}
@Test public void Qargs__ques__dupe__ques() {
@Test public void Qargs__ques__dupe__ques() {
tstr.Exec__parse("https://site/A?B?Y=Z").Test__page("A?B").Test__qargs("Y", "Z");
}
@Test public void Qargs__ques__dupe__amp() {
@Test public void Qargs__ques__dupe__amp() {
tstr.Exec__parse("https://site/A?B=C&D?Y=Z").Test__page("A?B=C&D").Test__qargs("Y", "Z");
}
@Test public void Qargs__ques__dupe__eq() {
@Test public void Qargs__ques__dupe__eq() {
tstr.Exec__parse("https://site/A?B=C?Y=Z").Test__page("A?B=C").Test__qargs("Y", "Z");
}
@Test public void Qargs__amp__dupe__ques() {
@Test public void Qargs__amp__dupe__ques() {
tstr.Exec__parse("https://site/A?B&Y=Z").Test__page("A").Test__qargs("B", null, "Y", "Z");
}
@Test public void Qargs__amp__dupe__amp() {
@Test public void Qargs__amp__dupe__amp() {
tstr.Exec__parse("https://site/A?B=C&D&Y=Z").Test__page("A").Test__qargs("B", "C", "D", null, "Y", "Z");
}
@Test public void Qargs__missing_val__0() {
@Test public void Qargs__missing_val__0() {
tstr.Exec__parse("https://site/A?").Test__page("A?").Test__qargs();
}
@Test public void Qargs__missing_val__2() {
@Test public void Qargs__missing_val__2() {
tstr.Exec__parse("https://site/A?B=C&D&F=G").Test__page("A").Test__qargs("B", "C", "D", null, "F", "G");
}
@Test public void Qargs__missing_val__n() {
@Test public void Qargs__missing_val__n() {
tstr.Exec__parse("https://site/A?B=C&D=E&F").Test__page("A").Test__qargs("B", "C", "D", "E", "F", null);
}
@Test public void Qargs__site_less__missing__0() {
@Test public void Qargs__site_less__missing__0() {
tstr.Exec__parse("A?B").Test__segs("A?B").Test__qargs();
}
@Test public void Qargs__site_less() {
@Test public void Qargs__site_less() {
tstr.Exec__parse("A?B=C&D=E").Test__site("A").Test__qargs("B", "C", "D", "E");
}
@Test public void Anch__basic() {
@Test public void Anch__basic() {
tstr.Exec__parse("https://site/A#B").Test__page("A").Test__anch("B");
}
@Test public void Anch__repeat__2() {
@Test public void Anch__repeat__2() {
tstr.Exec__parse("https://site/A#B#C").Test__page("A").Test__anch("B#C");
}
@Test public void Anch__repeat__3() {
@Test public void Anch__repeat__3() {
tstr.Exec__parse("https://site/A#B#C#D").Test__page("A").Test__anch("B#C#D");
}
@Test public void Anch__missing() {
@Test public void Anch__missing() {
tstr.Exec__parse("https://site/A#").Test__page("A#").Test__anch(null);
}
@Test public void Anch__missing__eos() {
@Test public void Anch__missing__eos() {
tstr.Exec__parse("https://site/A#B#").Test__page("A").Test__anch("B#");
}
@Test public void Anch__qargs__basic() {
@Test public void Anch__qargs__basic() {
tstr.Exec__parse("https://site/A?B=C&D=E#F").Test__page("A").Test__qargs("B", "C", "D", "E").Test__anch("F");
}
@Test public void Anch__site_less() {
@Test public void Anch__site_less() {
tstr.Exec__parse("A#B").Test__site("A").Test__anch("B");
}
@Test public void Encode__page() {
@Test public void Encode__page() {
tstr.Exec__parse("http://site/A%27s").Test__site("site").Test__page("A's");
}
@Test public void Protocol_less__qargs() {
@Test public void Protocol_less__qargs() {
tstr.Exec__parse("Special:Search/Earth?fulltext=yes").Test__segs("Special:Search", "Earth").Test__page("Earth").Test__qargs("fulltext", "yes");
}
@Test public void Http_server() {
@Test public void Http_server() {
tstr.Exec__parse("/wiki/Page?A=B").Test__segs("wiki", "Page").Test__page("Page").Test__qargs("A", "B");
}
@Test public void Parse_site_fast() {
@Test public void Parse_site_fast() {
tstr.Test_Parse_site_fast("http://a.org/B" , "a.org");
tstr.Test_Parse_site_fast("http://a.org" , "a.org");
tstr.Test_Parse_site_fast("//a.org/B" , "a.org");
tstr.Test_Parse_site_fast("//a.org/B:C" , "a.org");
}
// DELETED: logic isn't right; anch is first # not last; EX: https://en.wikipedia.org/w/index.php?title=Category:2001_albums&pagefrom=Beautiful+#View#mw-pages; DATE:2016-10-10
// @Test public void Anch__qargs__repeat() {
// @Test public void Anch__qargs__repeat() {
// tstr.Exec__parse("https://site/A?B=C#&D=E#F").Test__page("A").Test__qargs("B", "C#", "D", "E").Test__anch("F");
// }
}

View File

@@ -1,32 +1,32 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.core.net; import gplx.*; import gplx.core.*;
import org.junit.*; import gplx.core.tests.*;
public class Http_request_parser_tst {
@Before public void init() {fxt.Clear();} private final Http_request_parser_fxt fxt = new Http_request_parser_fxt();
@Test public void Type_post() {
@Test public void Type_post() {
fxt.Test_type_post("POST /url HTTP/1.1", Http_request_itm.Type_post, "/url", "HTTP/1.1");
}
@Test public void Type_content_type() {
@Test public void Type_content_type() {
fxt.Test_content_type("Content-Type: multipart/form-data; boundary=---------------------------72432484930026", "multipart/form-data", "-----------------------------72432484930026");
}
@Test public void Type_content_type__x_www_form_url_encoded() { // PURPOSE: ignore content-type for GET calls like by Mathematica server; DATE:2015-08-04
@Test public void Type_content_type__x_www_form_url_encoded() { // PURPOSE: ignore content-type for GET calls like by Mathematica server; DATE:2015-08-04
fxt.Test_content_type("Content-Type: application/x-www-form-urlencoded", null, null);
}
@Test public void Type_form_data() {
@Test public void Type_form_data() {
fxt.Test_form_data(String_.Ary
( "POST /url HTTP/1.1"
, "Content-Type: multipart/form-data; boundary=---------------------------12345678901234"
@@ -45,10 +45,10 @@ public class Http_request_parser_tst {
, fxt.Make_post_data_itm("key1", "val1")
);
}
@Test public void Type_accept_charset() {
@Test public void Type_accept_charset() {
fxt.Test_ignore("Accept-Charset: ISO-8859-1,utf-8;q=0.7");
}
@Test public void Nginx() {// PURPOSE: support http headers from nginx; ISSUE#:255
@Test public void Nginx() {// PURPOSE: support http headers from nginx; ISSUE#:255
fxt.Test_ignore("Upgrade-Insecure-Requests: test1; X-Host: test2; X-Real-IP: test3;");
}
}

View File

@@ -1,193 +0,0 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2020 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.core.primitives;
import gplx.Byte_ascii;
import gplx.Decimal_adp;
import gplx.Decimal_adp_;
import gplx.Int_;
import gplx.Math_;
public class Gfo_number_parser {
public int Rv_as_int() {return (int)num_val;} private long num_val = 0;
public long Rv_as_long() {return num_val;}
public Decimal_adp Rv_as_dec() {return dec_val == null ? Decimal_adp_.long_(num_val) : dec_val;} private Decimal_adp dec_val = null;
public boolean Is_int() {return dec_val == null && (num_val >= Int_.Min_value && num_val <= Int_.Max_value);}
public boolean Has_err() {return has_err;} private boolean has_err;
public boolean Has_frac() {return has_frac;} private boolean has_frac;
public boolean Hex_enabled() {return hex_enabled;} public Gfo_number_parser Hex_enabled_(boolean v) {hex_enabled = v; return this;} private boolean hex_enabled;
public Gfo_number_parser Ignore_chars_(byte[] v) {this.ignore_chars = v; return this;} private byte[] ignore_chars;
public Gfo_number_parser Ignore_space_at_end_y_() {this.ignore_space_at_end = true; return this;} private boolean ignore_space_at_end;
public void Clear() {
ignore_chars = null;
}
public Gfo_number_parser Parse(byte[] src) {return Parse(src, 0, src.length);}
public Gfo_number_parser Parse(byte[] ary, int bgn, int end) {
int loop_bgn = end - 1, loop_end = bgn - 1, exp_multiplier = 1, factor = 10;
long multiplier = 1, frc_multiplier = 1;
num_val = 0; dec_val = null; boolean comma_nil = true;
long frc_int = 0;
has_err = false; has_frac = false; boolean has_exp = false, has_neg = false, exp_neg = false, has_plus = false, has_num = false;
boolean input_is_hex = false;
if (hex_enabled) {
if (loop_end + 2 < end) { // ArrayOutOfBounds check
byte b_2 = ary[loop_end + 2];
switch (b_2) {
case Byte_ascii.Ltr_x:
case Byte_ascii.Ltr_X: // is 2nd char x?
if (ary[loop_end + 1] == Byte_ascii.Num_0) { // is 1st char 0?
factor = 16;
input_is_hex = true;
}
break;
default:
break;
}
}
}
for (int i = loop_bgn; i > loop_end; i--) {
byte cur = ary[i];
switch (cur) {
case Byte_ascii.Num_0:
case Byte_ascii.Num_1:
case Byte_ascii.Num_2:
case Byte_ascii.Num_3:
case Byte_ascii.Num_4:
case Byte_ascii.Num_5:
case Byte_ascii.Num_6:
case Byte_ascii.Num_7:
case Byte_ascii.Num_8:
case Byte_ascii.Num_9:
num_val += (cur - Byte_ascii.Num_0) * multiplier;
multiplier *= factor;
has_num = true;
break;
case Byte_ascii.Dot:
if (has_frac) return Has_err_y_();
frc_int = num_val;
num_val = 0;
frc_multiplier = multiplier;
multiplier = 1;
has_frac = true;
break;
case Byte_ascii.Comma:
if (comma_nil)
comma_nil = false;
else
return Has_err_y_();
break;
case Byte_ascii.Dash:
if (has_neg) return Has_err_y_();
has_neg = true;
break;
case Byte_ascii.Space:
if (i == bgn) {} // space at bgn
else if (i == end - 1 && ignore_space_at_end) {} // ignore space at end; DATE:2015-04-29
else
return Has_err_y_();
break;
case Byte_ascii.Plus:
if (has_plus) return Has_err_y_();
has_plus = true;
break;
case Byte_ascii.Ltr_e:
case Byte_ascii.Ltr_E:
if (input_is_hex) {
num_val += 14 * multiplier; // NOTE: 14=value of e/E
multiplier *= factor;
has_num = true;
}
else {
if (has_exp) return Has_err_y_();
exp_neg = has_neg;
exp_multiplier = (int)Math_.Pow(10, num_val);
num_val = 0;
multiplier = 1;
has_exp = true;
has_neg = false;
has_plus = false; // allow +1E+2
has_num = false; // 2020-09-07|ISSUE#:795|scientific notation requires coefficient; set has_num to false which will fail below if no coefficient
}
break;
case Byte_ascii.Ltr_A:
case Byte_ascii.Ltr_B:
case Byte_ascii.Ltr_C:
case Byte_ascii.Ltr_D:
case Byte_ascii.Ltr_F:
if (input_is_hex) {
num_val += (cur - Byte_ascii.Ltr_A + 10) * multiplier;
multiplier *= factor;
has_num = true;
}
else
return Has_err_y_();
break;
case Byte_ascii.Ltr_a:
case Byte_ascii.Ltr_b:
case Byte_ascii.Ltr_c:
case Byte_ascii.Ltr_d:
case Byte_ascii.Ltr_f:
if (input_is_hex) {
num_val += (cur - Byte_ascii.Ltr_a + 10) * multiplier;
multiplier *= factor;
has_num = true;
}
else
return Has_err_y_();
break;
case Byte_ascii.Ltr_x:
case Byte_ascii.Ltr_X:
if (input_is_hex)
return (factor == 16) ? this : Has_err_y_(); // check for '0x'
else
return Has_err_y_();
default:
if (ignore_chars != null) {
int ignore_chars_len = ignore_chars.length;
boolean ignored = false;
for (int j = 0; j < ignore_chars_len; ++j) {
if (cur == ignore_chars[j]) {
ignored = true;
break;
}
}
if (ignored) continue;
}
return Has_err_y_();
}
}
if (!has_num) return Has_err_y_(); // handles situations wherein just symbols; EX: "+", ".", "-.", " , " etc.
if (has_frac) {
long full_val = (((num_val * frc_multiplier) + frc_int));
if (has_neg) full_val *= -1;
if (has_exp) {
if (exp_neg) frc_multiplier *= exp_multiplier; // divide, so apply to frc
else full_val *= exp_multiplier; // multiply, so apply to full_val
}
dec_val = Decimal_adp_.divide_(full_val, frc_multiplier);
}
else {
if (has_neg) num_val *= -1;
if (has_exp) {
num_val = exp_neg
? num_val / exp_multiplier
: num_val * exp_multiplier;
}
}
return this;
}
private Gfo_number_parser Has_err_y_() {has_err = true; return this;}
}

View File

@@ -13,16 +13,16 @@ The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.core.primitives; import gplx.*; import gplx.core.*;
import org.junit.*; import gplx.core.tests.*;
public class Int_ary_parser_tst {
private final Int_ary_parser_fxt fxt = new Int_ary_parser_fxt();
@Test public void Many() {fxt.Test__Parse_ary("1,2,3,4,5" , 0, 9, Int_ary_.New(1, 2, 3, 4, 5));}
@Test public void One() {fxt.Test__Parse_ary("1" , 0, 1, Int_ary_.New(1));}
@Test public void None() {fxt.Test__Parse_ary("" , 0, 0, Int_ary_.New());}
}
class Int_ary_parser_fxt {
public void Test__Parse_ary(String raw, int bgn, int end, int[] expd) {
Gftest.Eq__ary(expd, new Int_ary_parser().Parse_ary(Bry_.new_a7(raw), bgn, end, Byte_ascii.Comma), "parse_ary failed");
}
}
package gplx.core.primitives; import gplx.*; import gplx.core.*;
import org.junit.*; import gplx.core.tests.*;
public class Int_ary_parser_tst {
private final Int_ary_parser_fxt fxt = new Int_ary_parser_fxt();
@Test public void Many() {fxt.Test__Parse_ary("1,2,3,4,5" , 0, 9, Int_ary_.New(1, 2, 3, 4, 5));}
@Test public void One() {fxt.Test__Parse_ary("1" , 0, 1, Int_ary_.New(1));}
@Test public void None() {fxt.Test__Parse_ary("" , 0, 0, Int_ary_.New());}
}
class Int_ary_parser_fxt {
public void Test__Parse_ary(String raw, int bgn, int end, int[] expd) {
Gftest.Eq__ary(expd, new Int_ary_parser().Parse_ary(Bry_.new_a7(raw), bgn, end, Byte_ascii.Comma), "parse_ary failed");
}
}

View File

@@ -1,37 +1,37 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.core.primitives; import gplx.*; import gplx.core.*;
import org.junit.*;
public class Int_pool_tst {
private final Int_pool_tstr tstr = new Int_pool_tstr();
@Before public void init() {tstr.Clear();}
@Test public void Get__one() {
@Test public void Get__one() {
tstr.Test_get(0);
}
@Test public void Get__many() {
@Test public void Get__many() {
tstr.Test_get(0);
tstr.Test_get(1);
tstr.Test_get(2);
}
@Test public void Del__one() {
@Test public void Del__one() {
tstr.Test_get(0);
tstr.Exec_del(0);
tstr.Test_get(0);
}
@Test public void Del__sequential() {
@Test public void Del__sequential() {
tstr.Test_get(0);
tstr.Test_get(1);
tstr.Test_get(2);
@@ -40,7 +40,7 @@ public class Int_pool_tst {
tstr.Exec_del(1);
tstr.Exec_del(0).Test_get(0);
}
@Test public void Del__out_of_order() {
@Test public void Del__out_of_order() {
tstr.Test_get(0);
tstr.Test_get(1);
tstr.Test_get(2);
@@ -50,7 +50,7 @@ public class Int_pool_tst {
tstr.Exec_del(2);
tstr.Test_get(0);
}
@Test public void Del__out_of_order_2() {
@Test public void Del__out_of_order_2() {
tstr.Test_get(0);
tstr.Test_get(1);
tstr.Test_get(2);

View File

@@ -1,37 +1,41 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.core.threads; import gplx.*; import gplx.core.*;
import gplx.core.brys.fmtrs.*;
import gplx.gfui.*; import gplx.gfui.kits.core.*;
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.core.threads; import gplx.GfoMsg;
import gplx.Gfo_invk;
import gplx.Gfo_invk_;
import gplx.Gfo_usr_dlg;
import gplx.GfsCtx;
import gplx.core.brys.fmtrs.Bry_fmtr_eval_mgr;
import gplx.gfui.kits.core.Gfui_kit;
public class Gfo_thread_cmd_base implements Gfo_thread_cmd {
@gplx.Virtual public String Async_key() {return "undefined";}
public String Async_key() {return "undefined";}
public void Cmd_ctor() {}
public Gfo_thread_cmd_base Ctor(Gfo_usr_dlg usr_dlg, Gfui_kit kit) {this.usr_dlg = usr_dlg; this.kit = kit; return this;} protected Gfo_usr_dlg usr_dlg; protected Gfui_kit kit;
public Gfo_invk Owner() {return owner;} public Gfo_thread_cmd_base Owner_(Gfo_invk v) {owner = v; return this;} Gfo_invk owner;
public Bry_fmtr_eval_mgr Url_eval_mgr() {return url_eval_mgr;} public Gfo_thread_cmd_base Url_eval_mgr_(Bry_fmtr_eval_mgr v) {url_eval_mgr = v; return this;} Bry_fmtr_eval_mgr url_eval_mgr;
public Gfo_thread_cmd Async_next_cmd() {return next_cmd;} public void Async_next_cmd_(Gfo_thread_cmd v) {next_cmd = v;} Gfo_thread_cmd next_cmd;
@gplx.Virtual public int Async_sleep_interval() {return Gfo_thread_cmd_.Async_sleep_interval_1_second;}
@gplx.Virtual public boolean Async_prog_enabled() {return false;}
@gplx.Virtual public byte Async_init() {return Gfo_thread_cmd_.Init_ok;}
@gplx.Virtual public boolean Async_term() {return true;}
@gplx.Virtual public void Async_prog_run(int async_sleep_sum) {}
@gplx.Virtual public void Async_bgn() {}
@gplx.Virtual public boolean Async_running() {return false;}
@gplx.Virtual public void Async_run() {}
@gplx.Virtual public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
public int Async_sleep_interval() {return Gfo_thread_cmd_.Async_sleep_interval_1_second;}
public boolean Async_prog_enabled() {return false;}
public byte Async_init() {return Gfo_thread_cmd_.Init_ok;}
public boolean Async_term() {return true;}
public void Async_prog_run(int async_sleep_sum) {}
public void Async_bgn() {}
public boolean Async_running() {return false;}
public void Async_run() {}
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_owner)) return owner;
else if (ctx.Match(k, Invk_async_bgn)) Async_bgn();
else return Gfo_invk_.Rv_unhandled;

View File

@@ -1,18 +1,18 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.core.threads; import gplx.*; import gplx.core.*;
import gplx.core.brys.fmtrs.*;
import gplx.gfui.*; import gplx.gfui.kits.core.*;
@@ -27,10 +27,10 @@ public class Gfo_thread_cmd_download implements Gfo_thread_cmd {
public Bry_fmtr_eval_mgr Url_eval_mgr() {return url_eval_mgr;} public Gfo_thread_cmd_download Url_eval_mgr_(Bry_fmtr_eval_mgr v) {url_eval_mgr = v; return this;} Bry_fmtr_eval_mgr url_eval_mgr;
public void Cmd_ctor() {}
public Gfo_thread_cmd Async_next_cmd() {return next_cmd;} public void Async_next_cmd_(Gfo_thread_cmd v) {next_cmd = v;} Gfo_thread_cmd next_cmd;
@gplx.Virtual public String Async_key() {return KEY;}
public String Async_key() {return KEY;}
public int Async_sleep_interval() {return Gfo_thread_cmd_.Async_sleep_interval_1_second;}
public boolean Async_prog_enabled() {return false;}
@gplx.Virtual public byte Async_init() {
public byte Async_init() {
if (Io_mgr.Instance.ExistsFil(trg)) {
int rslt = kit.Ask_yes_no_cancel(GRP_KEY, "target_exists", "Target file already exists: '~{0}'.\nDo you want to delete it?", trg.Raw());
switch (rslt) {

View File

@@ -1,18 +1,18 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.core.threads; import gplx.*; import gplx.core.*;
import gplx.core.brys.fmtrs.*;
import gplx.gfui.*; import gplx.gfui.kits.core.*;
@@ -28,14 +28,14 @@ public class Gfo_thread_cmd_replace implements Gfo_thread_cmd {
public Gfo_thread_cmd Async_next_cmd() {return next_cmd;} public void Async_next_cmd_(Gfo_thread_cmd v) {next_cmd = v;} Gfo_thread_cmd next_cmd;
public int Async_sleep_interval() {return Gfo_thread_cmd_.Async_sleep_interval_1_second;}
public boolean Async_prog_enabled() {return false;}
@gplx.Virtual public byte Async_init() {
public byte Async_init() {
if (!Io_mgr.Instance.ExistsFil(fil)) {kit.Ask_ok(GRP_KEY, "file_missing", "File does not exist: '~{0}'", fil.Raw()); return Gfo_thread_cmd_.Init_cancel_step;}
return Gfo_thread_cmd_.Init_ok;
}
public boolean Async_term() {return true;}
public void Async_prog_run(int async_sleep_sum) {}
public boolean Async_running() {return false;}
@gplx.Virtual public void Async_run() {Exec_find_replace();} // NOTE: do not run async; if multiple commands for same file then they will not always work
public void Async_run() {Exec_find_replace();} // NOTE: do not run async; if multiple commands for same file then they will not always work
public void Exec_find_replace() {
String raw = Io_mgr.Instance.LoadFilStr(fil);
int pairs_len = pairs.Count();
@@ -47,7 +47,7 @@ public class Gfo_thread_cmd_replace implements Gfo_thread_cmd {
usr_dlg.Prog_many(GRP_KEY, "done", "replace completed: ~{0} ~{1}", fil.Raw(), pairs_len);
}
public List_adp pairs = List_adp_.New();
@gplx.Virtual public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_async_bgn)) Exec_find_replace();
else if (ctx.Match(k, Invk_owner)) return owner;
else if (ctx.Match(k, Invk_fil_)) fil = Bry_fmtr_eval_mgr_.Eval_url(url_eval_mgr, m.ReadBry("v"));

View File

@@ -1,18 +1,18 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.core.threads; import gplx.*; import gplx.core.*;
import gplx.core.brys.fmtrs.*; import gplx.core.envs.*;
import gplx.gfui.*; import gplx.gfui.kits.core.*; import gplx.xowa.bldrs.cmds.utils.*;
@@ -24,7 +24,7 @@ public class Gfo_thread_cmd_unzip implements Gfo_thread_cmd {
} private Io_url src, trg; private Gfui_kit kit; private Gfo_usr_dlg usr_dlg; private Xob_unzip_wkr unzip_wkr;
public Gfo_invk Owner() {return owner;} public Gfo_thread_cmd_unzip Owner_(Gfo_invk v) {owner = v; return this;} Gfo_invk owner;
public void Cmd_ctor() {}
@gplx.Virtual public String Async_key() {return KEY;}
public String Async_key() {return KEY;}
public Gfo_thread_cmd Async_next_cmd() {return next_cmd;} public void Async_next_cmd_(Gfo_thread_cmd v) {next_cmd = v;} Gfo_thread_cmd next_cmd;
public Bry_fmtr_eval_mgr Url_eval_mgr() {return url_eval_mgr;} public Gfo_thread_cmd_unzip Url_eval_mgr_(Bry_fmtr_eval_mgr v) {url_eval_mgr = v; return this;} Bry_fmtr_eval_mgr url_eval_mgr;
public int Async_sleep_interval() {return Gfo_thread_cmd_.Async_sleep_interval_1_second;}
@@ -34,7 +34,7 @@ public class Gfo_thread_cmd_unzip implements Gfo_thread_cmd {
if (trg.Type_fil()) size_str = gplx.core.ios.Io_size_.To_str(Io_mgr.Instance.QueryFil(trg).Size());
usr_dlg.Prog_many(GRP_KEY, "unzip", "unzipping: ~{0}", size_str);
}
@gplx.Virtual public byte Async_init() {
public byte Async_init() {
if (!Io_mgr.Instance.ExistsFil(src)) {
kit.Ask_ok(GRP_KEY, "source_missing", "Source file does not exist: '~{0}'", src.Raw());
return Gfo_thread_cmd_.Init_cancel_step;

View File

@@ -1,23 +1,23 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.dbs.bulks; import gplx.*; import gplx.dbs.*;
import org.junit.*; import gplx.core.tests.*; import gplx.dbs.metas.*;
public class Db_tbl_copy_tst {
private final Db_tbl_copy_fxt fxt = new Db_tbl_copy_fxt();
@Test public void Basic() {
@Test public void Basic() {
fxt.Test__bld_sql(fxt.Make_tbl("tbl_1", Dbmeta_fld_itm.new_int("fld_1"), Dbmeta_fld_itm.new_int("fld_2")),
String_.Concat_lines_nl_skip_last
( "INSERT INTO trg"

View File

@@ -1,26 +1,26 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.dbs.metas.updates; import gplx.*; import gplx.dbs.*; import gplx.dbs.metas.*;
import org.junit.*; import gplx.dbs.*;
public class Schema_update_mgr_tst {
@Before public void init() {fxt.Clear();} private Schema_update_mgr_fxt fxt = new Schema_update_mgr_fxt();
@Test public void Create() {
@Test public void Create() {
fxt.Test_exec_y(new Schema_update_cmd__mock());
}
@Test public void Delete() {
@Test public void Delete() {
fxt.Init_itm(Dbmeta_itm_tid.Tid_table, Schema_update_cmd__mock.Tbl_name);
fxt.Test_exec_n(new Schema_update_cmd__mock());
}

View File

@@ -1,36 +1,36 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.dbs.percentiles; import gplx.*; import gplx.dbs.*;
import org.junit.*;
public class Percentile_rng_tst {
private final Percentile_rng_fxt fxt = new Percentile_rng_fxt();
@Before public void init() {fxt.Clear();}
@Test public void Found__000() {
@Test public void Found__000() {
fxt.Test__rng(999994, 1000001);
fxt.Exec__update( 0).Test__rng(999966, 999994);
fxt.Exec__update( 0).Test__rng(999854, 999966);
}
@Test public void Found__025() {
@Test public void Found__025() {
fxt.Test__rng(999994, 1000001);
fxt.Exec__update( 25).Test__rng(999973, 999994);
fxt.Exec__update( 25).Test__rng(999931, 999973);
fxt.Exec__update( 25).Test__rng(999889, 999931);
fxt.Exec__update( 25).Test__rng(999847, 999889);
}
@Test public void Calc_score_unit() {
@Test public void Calc_score_unit() {
fxt.Test__calc_score_unit(50, 16000000, 1000000, 4); // to fill 50 -> 16 pages per point -> read every 4 points to get 64 pages
fxt.Test__calc_score_unit(50, 1000, 1000000, 50000); // to fill 50 -> 1000 points per page -> read every 50k points to get 50 pages
fxt.Test__calc_score_unit(50, 25, 1000000, 1000000); // range bounds check; to fill 50, always read full amount

View File

@@ -1,18 +1,18 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.dbs.percentiles; import gplx.*; import gplx.dbs.*;
public abstract class Percentile_select_base { // SELECT * FROM x ORDER BY y LIMIT 10;
protected Cancelable cxl;
@@ -53,13 +53,13 @@ public abstract class Percentile_select_base { // SELECT * FROM x ORDER BY y LIM
}
}
protected abstract Db_rdr Rdr__init();
@gplx.Virtual protected void Rdr__done(boolean found_enough, boolean none_left) {}
@gplx.Virtual protected Db_rdr Rdr__term(Db_rdr rdr) {
protected void Rdr__done(boolean found_enough, boolean none_left) {}
protected Db_rdr Rdr__term(Db_rdr rdr) {
if (rdr != null) rdr.Rls();
return null;
}
@gplx.Virtual protected void Rng__update(int rdr_found) {rng.Update(rdr_found);}
@gplx.Virtual protected boolean Row__read(Db_rdr rdr) {return true;}
@gplx.Virtual protected boolean Row__eval() {return true;} // NOTE: return true by default; DEPENDENCY: Srch_word_count_wkr
@gplx.Virtual protected boolean Found_enough() {return false;}
protected void Rng__update(int rdr_found) {rng.Update(rdr_found);}
protected boolean Row__read(Db_rdr rdr) {return true;}
protected boolean Row__eval() {return true;} // NOTE: return true by default; DEPENDENCY: Srch_word_count_wkr
protected boolean Found_enough() {return false;}
}

View File

@@ -1,23 +1,24 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.fsdb.data; import gplx.*; import gplx.fsdb.*;
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.fsdb.data; import gplx.*;
import gplx.core.primitives.*; import gplx.core.envs.*;
import gplx.dbs.*; import gplx.core.ios.*; import gplx.core.ios.streams.*;
import gplx.dbs.engines.sqlite.*;
public class Fsd_bin_tbl implements Rls_able {
import gplx.dbs.*;
import gplx.core.ios.streams.*;
public class Fsd_bin_tbl implements Rls_able {
public final String fld__owner_id, fld__owner_tid, fld__part_id, fld__data_url, fld__data;
private Db_conn conn; private Db_stmt stmt_insert, stmt_select, stmt_select_itm; private Bry_bfr tmp_bfr;
private final Bool_obj_ref saved_in_parts = Bool_obj_ref.n_();
@@ -26,7 +27,7 @@ public class Fsd_bin_tbl implements Rls_able {
fld__owner_id = flds.Add_int_pkey ("bin_owner_id");
fld__owner_tid = flds.Add_byte ("bin_owner_tid");
fld__part_id = flds.Add_int ("bin_part_id");
fld__data_url = flds.Add_str ("bin_data_url", 255);
fld__data_url = flds.Add_str ("bin_data_url", 255); // for items which are > 2 GB, just store it on disc, with a path to it; EX: 120 GB file
fld__data = flds.Add_bry ("bin_data"); // mediumblob
conn.Rls_reg(this);
}

View File

@@ -1,23 +1,23 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.fsdb.data; import gplx.*; import gplx.fsdb.*;
import org.junit.*;
public class Fsd_thm_tbl_tst {
@Before public void init() {fxt.Clear();} private Fsd_thm_tbl_fxt fxt = new Fsd_thm_tbl_fxt();
@Test public void Basic() {
@Test public void Basic() {
fxt.Init_list(fxt.Make(100), fxt.Make(200), fxt.Make(400));
fxt.Test_match_nearest_itm(fxt.Make(400), fxt.Make(400));
fxt.Test_match_nearest_itm(fxt.Make(200), fxt.Make(200));
@@ -26,7 +26,7 @@ public class Fsd_thm_tbl_tst {
fxt.Test_match_nearest_itm(fxt.Make(150), fxt.Make(200));
fxt.Test_match_nearest_itm(fxt.Make(999), fxt.Make(400));
}
@Test public void Empty() {
@Test public void Empty() {
fxt.Init_list(); // no items
fxt.Test_match_nearest_itm(fxt.Make(100), Fsd_thm_itm.Null);
}

View File

@@ -1,49 +1,49 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.gfui; import gplx.*;
import org.junit.*;
public class Gfui_bnd_parser_tst {
@Before public void init() {fxt.Clear();} private Gfui_bnd_parser_fxt fxt = new Gfui_bnd_parser_fxt();
@Test public void Norm_one() {
@Test public void Norm_one() {
fxt.Test__to_norm("mod.c" , "Ctrl");
fxt.Test__to_norm("key.ctrl" , "Ctrl");
fxt.Test__to_norm("key.a" , "A");
fxt.Test__to_norm("key.left" , "Left");
}
@Test public void Norm_add() {
@Test public void Norm_add() {
fxt.Test__to_norm("mod.c+key.a" , "Ctrl + A");
fxt.Test__to_norm("mod.ca+key.a" , "Ctrl + Alt + A");
fxt.Test__to_norm("mod.cas+key.a" , "Ctrl + Alt + Shift + A");
}
@Test public void Norm_chord() {
@Test public void Norm_chord() {
fxt.Test__to_norm("key.a,key.b" , "A, B");
}
@Test public void Norm_add_and_chord() {
@Test public void Norm_add_and_chord() {
fxt.Test__to_norm("mod.c+key.a,mod.a+key.b" , "Ctrl + A, Alt + B");
}
@Test public void Gfui_add() {
@Test public void Gfui_add() {
fxt.Test__to_gfui("Ctrl + A" , "mod.c+key.a");
fxt.Test__to_gfui("Ctrl + Shift + A" , "mod.cs+key.a");
fxt.Test__to_gfui("Ctrl + Alt + Shift + A" , "mod.cas+key.a");
}
@Test public void Keypad_enter() {
@Test public void Keypad_enter() {
fxt.Test__to_norm("key.numpad_enter" , "Numpad Enter");
fxt.Test__to_norm("mod.c+key.numpad_enter" , "Ctrl + Numpad Enter");
}
@Test public void None() {
@Test public void None() {
fxt.Test__to_gfui("None" , "key.none");
fxt.Test__to_norm("key.none" , "None");
}

View File

@@ -1,23 +1,23 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.langs.dsvs; import gplx.*; import gplx.langs.*;
import org.junit.*;
public class Dsv_tbl_parser_int_tst {
private Dsv_mok_fxt fxt = new Dsv_mok_fxt();
@Test public void Basic() {
@Test public void Basic() {
fxt .Test_load(String_.Concat_lines_nl_skip_last
( "a|1|3"
, "b|2|4"

View File

@@ -1,23 +1,23 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.langs.dsvs; import gplx.*; import gplx.langs.*;
import org.junit.*;
public class Dsv_tbl_parser_str_tst {
private Dsv_mok_fxt fxt = new Dsv_mok_fxt();
@Test public void Basic() {
@Test public void Basic() {
fxt .Test_load(String_.Concat_lines_nl_skip_last
( "a|A"
, "b|B"
@@ -27,7 +27,7 @@ public class Dsv_tbl_parser_str_tst {
, fxt.itm_str_("b", "B")
);
}
@Test public void Blank_lines() {
@Test public void Blank_lines() {
fxt .Test_load(String_.Concat_lines_nl_skip_last
( ""
, "a|A"
@@ -40,7 +40,7 @@ public class Dsv_tbl_parser_str_tst {
, fxt.itm_str_("b", "B")
);
}
@Test public void Incomplete_row() {
@Test public void Incomplete_row() {
fxt .Test_load(String_.Concat_lines_nl_skip_last
( "a"
, "b"
@@ -51,7 +51,7 @@ public class Dsv_tbl_parser_str_tst {
, fxt.itm_str_("b")
);
}
@Test public void Incomplete_row_2() { // PURPOSE: handle multiple incomplete cells
@Test public void Incomplete_row_2() { // PURPOSE: handle multiple incomplete cells
fxt .Test_load(String_.Concat_lines_nl_skip_last
( "a|")
, fxt.mgr_str_(3)

View File

@@ -1,25 +1,25 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.langs.dsvs; import gplx.*; import gplx.langs.*;
public abstract class Dsv_wkr_base implements Gfo_invk {
public abstract Dsv_fld_parser[] Fld_parsers();
public byte[] Src() {return src;} private byte[] src;
public abstract void Commit_itm(Dsv_tbl_parser parser, int pos);
@gplx.Virtual public boolean Write_bry(Dsv_tbl_parser parser, int fld_idx, byte[] src, int bgn, int end) {return false;}
@gplx.Virtual public boolean Write_int(Dsv_tbl_parser parser, int fld_idx, int pos, int val_int) {return false;}
public boolean Write_bry(Dsv_tbl_parser parser, int fld_idx, byte[] src, int bgn, int end) {return false;}
public boolean Write_int(Dsv_tbl_parser parser, int fld_idx, int pos, int val_int) {return false;}
public void Load_by_bry(byte[] src) {
this.src = src;
Dsv_tbl_parser tbl_parser = new Dsv_tbl_parser(); // NOTE: this proc should only be called once, so don't bother caching tbl_parser
@@ -29,8 +29,8 @@ public abstract class Dsv_wkr_base implements Gfo_invk {
tbl_parser.Rls();
Load_by_bry_end();
}
@gplx.Virtual public void Load_by_bry_bgn() {}
@gplx.Virtual public void Load_by_bry_end() {}
public void Load_by_bry_bgn() {}
public void Load_by_bry_end() {}
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_load_by_str)) Load_by_bry(m.ReadBry("v"));
else return Gfo_invk_.Rv_unhandled;

View File

@@ -1,42 +1,42 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.langs.gfs; import gplx.*; import gplx.langs.*;
import org.junit.*; import gplx.core.strings.*;
public class Gfs_msg_bldr_tst {
@Before public void init() {fxt.Clear();} Gfs_msg_bldr_fxt fxt = new Gfs_msg_bldr_fxt();
@Test public void Basic() {
@Test public void Basic() {
fxt.Test_build("a;", fxt.msg_("a"));
}
@Test public void Dot() {
@Test public void Dot() {
fxt.Test_build("a.b.c;"
, fxt.msg_("a").Subs_
( fxt.msg_("b").Subs_
( fxt.msg_("c")
)));
}
@Test public void Args() {
@Test public void Args() {
fxt.Test_build("a('b', 'c');", fxt.msg_("a", fxt.kv_("", "b"), fxt.kv_("", "c")));
}
@Test public void Args_num() {
@Test public void Args_num() {
fxt.Test_build("a(1);", fxt.msg_("a", fxt.kv_("", "1")));
}
@Test public void Assign() {
@Test public void Assign() {
fxt.Test_build("a = 'b';", fxt.msg_("a_", fxt.kv_("", "b")));
}
@Test public void Assign_num() {
@Test public void Assign_num() {
fxt.Test_build("a = 1;", fxt.msg_("a_", fxt.kv_("", "1")));
}
}

View File

@@ -1,66 +1,66 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.langs.gfs; import gplx.*; import gplx.langs.*;
import org.junit.*;
public class Gfs_parser_tst {
@Before public void init() {fxt.Clear();} Gfs_parser_fxt fxt = new Gfs_parser_fxt();
@Test public void Semicolon() {
@Test public void Semicolon() {
fxt .Test_parse("a;", fxt.nde_("a"));
fxt .Test_parse("a;b;c;", fxt.nde_("a"), fxt.nde_("b"), fxt.nde_("c"));
fxt .Test_parse("a_0;", fxt.nde_("a_0"));
}
@Test public void Dot() {
@Test public void Dot() {
fxt .Test_parse("a.b;", fxt.nde_("a").Subs_add(fxt.nde_("b")));
fxt .Test_parse("a.b;c.d;", fxt.nde_("a").Subs_add(fxt.nde_("b")), fxt.nde_("c").Subs_add(fxt.nde_("d")));
}
@Test public void Parens() {
@Test public void Parens() {
fxt .Test_parse("a();b();", fxt.nde_("a"), fxt.nde_("b"));
fxt .Test_parse("a().b();c().d();", fxt.nde_("a").Subs_add(fxt.nde_("b")), fxt.nde_("c").Subs_add(fxt.nde_("d")));
}
@Test public void Num() {
@Test public void Num() {
fxt .Test_parse("a(1,2);", fxt.nde_("a").Atrs_add_many(fxt.val_("1"), fxt.val_("2")));
}
@Test public void Quote() {
@Test public void Quote() {
fxt .Test_parse("a('b');", fxt.nde_("a").Atrs_add(fxt.val_("b")));
}
@Test public void Quote_escaped() {
@Test public void Quote_escaped() {
fxt .Test_parse("a('b''c''d');", fxt.nde_("a").Atrs_add(fxt.val_("b'c'd")));
}
@Test public void Quote_escaped_2() {
@Test public void Quote_escaped_2() {
fxt .Test_parse("a('a''''b');", fxt.nde_("a").Atrs_add(fxt.val_("a''b")));
}
@Test public void Quote_mixed() {
@Test public void Quote_mixed() {
fxt .Test_parse("a('b\"c');", fxt.nde_("a").Atrs_add(fxt.val_("b\"c")));
}
@Test public void Comma() {
@Test public void Comma() {
fxt .Test_parse("a('b','c','d');", fxt.nde_("a").Atrs_add_many(fxt.val_("b"), fxt.val_("c"), fxt.val_("d")));
}
@Test public void Ws() {
@Test public void Ws() {
fxt .Test_parse(" a ( 'b' , 'c' ) ; ", fxt.nde_("a").Atrs_add_many(fxt.val_("b"), fxt.val_("c")));
}
@Test public void Comment_slash_slash() {
@Test public void Comment_slash_slash() {
fxt .Test_parse("//z\na;//y\n", fxt.nde_("a"));
}
@Test public void Comment_slash_star() {
@Test public void Comment_slash_star() {
fxt .Test_parse("/*z*/a;/*y*/", fxt.nde_("a"));
}
@Test public void Curly() {
@Test public void Curly() {
fxt .Test_parse("a{b;}", fxt.nde_("a").Subs_add(fxt.nde_("b")));
}
@Test public void Curly_nest() {
@Test public void Curly_nest() {
fxt .Test_parse("a{b{c{d;}}}"
, fxt.nde_("a").Subs_add
( fxt.nde_("b").Subs_add
@@ -68,7 +68,7 @@ public class Gfs_parser_tst {
( fxt.nde_("d")
))));
}
@Test public void Curly_nest_peers() {
@Test public void Curly_nest_peers() {
fxt .Test_parse(String_.Concat_lines_nl
( "a{"
, " a0{"
@@ -90,14 +90,14 @@ public class Gfs_parser_tst {
, fxt.nde_("a1")
));
}
@Test public void Curly_dot() {
@Test public void Curly_dot() {
fxt .Test_parse("a{a0.a00;a1.a10;}"
, fxt.nde_("a").Subs_add_many
( fxt.nde_("a0").Subs_add_many(fxt.nde_("a00"))
, fxt.nde_("a1").Subs_add_many(fxt.nde_("a10"))
));
}
@Test public void Eq() {
@Test public void Eq() {
fxt .Test_parse("a='b';", fxt.nde_("a").Atrs_add(fxt.val_("b")));
fxt .Test_parse("a.b.c='d';"
, fxt.nde_("a").Subs_add
@@ -111,7 +111,7 @@ public class Gfs_parser_tst {
, fxt.nde_("e").Atrs_add(fxt.val_("f"))
)));
}
@Test public void Curly_nest_peers2() {
@Test public void Curly_nest_peers2() {
fxt .Test_parse(String_.Concat_lines_nl
( "a() {"
, " k1 = 'v1';"
@@ -122,7 +122,7 @@ public class Gfs_parser_tst {
)
);
}
@Test public void Fail() {
@Test public void Fail() {
fxt .Test_parse_fail("a(.);", Gfs_err_mgr.Fail_msg_invalid_lxr); // (.)
fxt .Test_parse_fail("a..b;", Gfs_err_mgr.Fail_msg_invalid_lxr); // ..
fxt .Test_parse_fail("a.;", Gfs_err_mgr.Fail_msg_invalid_lxr); // .;

View File

@@ -1,28 +1,28 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.langs.htmls; import gplx.*; import gplx.langs.*;
import org.junit.*;
public class Gfh_parser_tst {
@Before public void init() {fxt.Clear();} private Gfh_parser_fxt fxt = new Gfh_parser_fxt();
@Test public void One() {fxt.Test_parse_find_all("<a id='id0'></a>", "id0");}
@Test public void Many() {fxt.Test_parse_find_all("<a id='id0'></a><a id='id1'></a><a id='id2'></a>", "id0", "id1", "id2");}
@Test public void Inline() {fxt.Test_parse_find_all("<a id='id0'/>", "id0");}
@Test public void Mix() {fxt.Test_parse_find_all("012<a id='id0'></a>id=id2<a id='id1'/>345<a id='id2'></a>abc", "id0", "id1", "id2");}
@Test public void Quote_double() {fxt.Test_parse_find_all("<a id='id''0'/>", "id'0");}
@Test public void Quote_escape() {fxt.Test_parse_find_all("<a id='id\\'0'/>", "id'0");}
@Test public void One() {fxt.Test_parse_find_all("<a id='id0'></a>", "id0");}
@Test public void Many() {fxt.Test_parse_find_all("<a id='id0'></a><a id='id1'></a><a id='id2'></a>", "id0", "id1", "id2");}
@Test public void Inline() {fxt.Test_parse_find_all("<a id='id0'/>", "id0");}
@Test public void Mix() {fxt.Test_parse_find_all("012<a id='id0'></a>id=id2<a id='id1'/>345<a id='id2'></a>abc", "id0", "id1", "id2");}
@Test public void Quote_double() {fxt.Test_parse_find_all("<a id='id''0'/>", "id'0");}
@Test public void Quote_escape() {fxt.Test_parse_find_all("<a id='id\\'0'/>", "id'0");}
}
class Gfh_parser_fxt {
public void Clear() {

View File

@@ -1,33 +1,33 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.langs.htmls; import gplx.*; import gplx.langs.*;
import org.junit.*;
public class Gfh_utl__basic__tst {
@Before public void init() {fxt.Clear();} private Gfh_class_fxt fxt = new Gfh_class_fxt();
@Test public void Escape() {
@Test public void Escape() {
fxt.Test_escape_html(Bool_.Y, Bool_.Y, Bool_.Y, Bool_.Y, Bool_.Y, "a<b" , "a&lt;b"); // basic
fxt.Test_escape_html(Bool_.Y, Bool_.Y, Bool_.N, Bool_.Y, Bool_.Y, "a<&b" , "a&lt;&b"); // fix: & not escaped when <> present
fxt.Test_escape_html(Bool_.Y, Bool_.Y, Bool_.Y, Bool_.Y, Bool_.Y, "a<>'&\"b" , "a&lt;&gt;&#39;&amp;&quot;b");
}
@Test public void Escape_for_atr_val() {
@Test public void Escape_for_atr_val() {
fxt.Test_escape_for_atr("abc" , Bool_.N, "abc"); // basic
fxt.Test_escape_for_atr("a'\"b" , Bool_.Y, "a&#39;\"b"); // quote is '
fxt.Test_escape_for_atr("a'\"b" , Bool_.N, "a'&quot;b"); // quote is "
}
@Test public void Unescape() {
@Test public void Unescape() {
fxt.Test_unescape_html(Bool_.Y, Bool_.Y, Bool_.Y, Bool_.Y, Bool_.Y, "a&lt;&gt;&#39;&amp;&quot;b" , "a<>'&\"b"); // basic
}
}

View File

@@ -13,12 +13,12 @@ The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.langs.htmls; import gplx.*; import gplx.langs.*;
import org.junit.*;
public class Gfh_utl__comments__tst {
@Before public void init() {fxt.Clear();} private final Gfh_class_fxt fxt = new Gfh_class_fxt();
@Test public void Basic() {fxt.Test_del_comments("a<!-- b -->c" , "ac");}
@Test public void Bgn_missing() {fxt.Test_del_comments("a b c" , "a b c");}
@Test public void End_missing() {fxt.Test_del_comments("a<!-- b c" , "a");}
@Test public void Multiple() {fxt.Test_del_comments("a<!--b-->c<!--d-->e" , "ace");}
}
package gplx.langs.htmls; import gplx.*; import gplx.langs.*;
import org.junit.*;
public class Gfh_utl__comments__tst {
@Before public void init() {fxt.Clear();} private final Gfh_class_fxt fxt = new Gfh_class_fxt();
@Test public void Basic() {fxt.Test_del_comments("a<!-- b -->c" , "ac");}
@Test public void Bgn_missing() {fxt.Test_del_comments("a b c" , "a b c");}
@Test public void End_missing() {fxt.Test_del_comments("a<!-- b c" , "a");}
@Test public void Multiple() {fxt.Test_del_comments("a<!--b-->c<!--d-->e" , "ace");}
}

View File

@@ -1,28 +1,28 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.langs.htmls.clses; import gplx.*; import gplx.langs.*; import gplx.langs.htmls.*;
import org.junit.*;
public class Gfh_class__tst {
private final Gfh_class__fxt fxt = new Gfh_class__fxt();
@Test public void Has() {
@Test public void Has() {
fxt.Test__has__y("a b c", "a", "b", "c");
fxt.Test__has__n("a b c", "d");
fxt.Test__has__n("ab", "a");
}
@Test public void Cls__has__hash() {
@Test public void Cls__has__hash() {
Hash_adp_bry hash = fxt.Make_hash("x", "y", "z");
fxt.Test__find_1st(hash, 0, "x");
fxt.Test__find_1st(hash, 2, "z");

View File

@@ -1,24 +1,24 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.langs.htmls.clses; import gplx.*; import gplx.langs.*; import gplx.langs.htmls.*;
import org.junit.*;
public class Gfh_class_parser__tst {
private final Gfh_class_parser__fxt fxt = new Gfh_class_parser__fxt();
@Test public void Basic() {fxt.Test__parse("v1" , "v1");}
@Test public void Many() {fxt.Test__parse("v1 v2" , "v1", "v2");}
@Test public void Basic() {fxt.Test__parse("v1" , "v1");}
@Test public void Many() {fxt.Test__parse("v1 v2" , "v1", "v2");}
}
class Gfh_class_parser__fxt {
private final Gfh_class_wkr__list wkr = new Gfh_class_wkr__list();

View File

@@ -1,48 +1,48 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.langs.htmls.docs; import gplx.*; import gplx.langs.*; import gplx.langs.htmls.*;
import org.junit.*;
public class Gfh_tag_rdr_tst {
private final Gfh_tag_rdr_fxt fxt = new Gfh_tag_rdr_fxt();
@Test public void Basic() {
@Test public void Basic() {
fxt.Init("1<div id='1'>2</div>3<div id='2'>4</div>5<div id='3'>6</div>7");
fxt.Test__move_fwd_head("<div id='1'>"); fxt.Test__pos("2");
fxt.Test__peek_fwd_head("<div id='2'>"); fxt.Test__pos("2");
fxt.Test__move_fwd_head("<div id='2'>"); fxt.Test__pos("4");
fxt.Test__peek_bwd_tail("</div>3") ; fxt.Test__pos("4");
}
@Test public void Comment() {
@Test public void Comment() {
fxt.Init("1<!--2-->3<!--4-->5<div id='1'>6</div>");
fxt.Test__move_fwd_head(Gfh_tag_.Id__any , "<div id='1'>") ; fxt.Test__pos("6");
}
@Test public void Meta() {
@Test public void Meta() {
fxt.Init("<!DOCTYPE html>1<div id='1'>2</div>3");
fxt.Test__move_fwd_head(Gfh_tag_.Id__div , "<div id='1'>") ; fxt.Test__pos("2");
}
@Test public void Recursive__same_tags() {
@Test public void Recursive__same_tags() {
fxt.Init("1<a>2<a>3</a>4</a>5");
fxt.Test__move_fwd_head(Gfh_tag_.Id__a , "<a>") ; fxt.Test__pos("2");
fxt.Test__move_fwd_tail(Gfh_tag_.Id__a , "</a>") ; fxt.Test__pos("5");
}
@Test public void Recursive__diff_tags() {
@Test public void Recursive__diff_tags() {
fxt.Init("1<div>2<a>3<img/>4</a>5</div>6");
fxt.Test__move_fwd_head(Gfh_tag_.Id__div , "<div>") ; fxt.Test__pos("2");
fxt.Test__move_fwd_tail(Gfh_tag_.Id__div , "</div>") ; fxt.Test__pos("6");
}
@Test public void Inline() {
@Test public void Inline() {
fxt.Init("1<br/>2");
fxt.Test__move_fwd_head(Gfh_tag_.Id__br , "<br/>") ; fxt.Test__pos("2");
}

View File

@@ -1,67 +1,67 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.langs.htmls.encoders; import gplx.*; import gplx.langs.*; import gplx.langs.htmls.*;
import org.junit.*;
public class Gfo_url_encoder_tst {
private final Gfo_url_encoder_fxt fxt = new Gfo_url_encoder_fxt();
@Test public void Id__nums() {fxt.Encoder_id().Test__bicode("0123456789");}
@Test public void Id__ltrs_lower() {fxt.Encoder_id().Test__bicode("abcdefghijklmnopqrstuvwxyz");}
@Test public void Id__ltrs_upper() {fxt.Encoder_id().Test__bicode("ABCDEFGHIJKLMNOPQRSTUVWXYZ");}
@Test public void Id__syms_0() {fxt.Encoder_id().Test__bicode("!\"#$%&'()*+,-./");} // ISSUE#:462; DATE:2019-05-12
@Test public void Id__syms_1() {fxt.Encoder_id().Test__bicode(":;=?@");} // ISSUE#:462; DATE:2019-05-12
@Test public void Id__syms_2() {fxt.Encoder_id().Test__bicode("[\\]^`");} // ISSUE#:462; DATE:2019-05-12
@Test public void Id__syms_3() {fxt.Encoder_id().Test__bicode("{|}~");}// ISSUE#:462; DATE:2019-05-12
@Test public void Id__foreign() {fxt.Encoder_id().Test__bicode("aéb");}
@Test public void Id__space() {fxt.Encoder_id().Test__bicode("a b", "a_b");}
@Test public void Id__syms_1_angles() { // NOTE:should not be encoded, but will break existings tests; EX:{{#tag:pre|a|id='<br/>'}}; DATE:2019-05-12;
@Test public void Id__nums() {fxt.Encoder_id().Test__bicode("0123456789");}
@Test public void Id__ltrs_lower() {fxt.Encoder_id().Test__bicode("abcdefghijklmnopqrstuvwxyz");}
@Test public void Id__ltrs_upper() {fxt.Encoder_id().Test__bicode("ABCDEFGHIJKLMNOPQRSTUVWXYZ");}
@Test public void Id__syms_0() {fxt.Encoder_id().Test__bicode("!\"#$%&'()*+,-./");} // ISSUE#:462; DATE:2019-05-12
@Test public void Id__syms_1() {fxt.Encoder_id().Test__bicode(":;=?@");} // ISSUE#:462; DATE:2019-05-12
@Test public void Id__syms_2() {fxt.Encoder_id().Test__bicode("[\\]^`");} // ISSUE#:462; DATE:2019-05-12
@Test public void Id__syms_3() {fxt.Encoder_id().Test__bicode("{|}~");}// ISSUE#:462; DATE:2019-05-12
@Test public void Id__foreign() {fxt.Encoder_id().Test__bicode("aéb");}
@Test public void Id__space() {fxt.Encoder_id().Test__bicode("a b", "a_b");}
@Test public void Id__syms_1_angles() { // NOTE:should not be encoded, but will break existings tests; EX:{{#tag:pre|a|id='<br/>'}}; DATE:2019-05-12;
fxt.Encoder_id().Test__encode("<", ".3C");
fxt.Encoder_id().Test__decode(".3C", "<");
fxt.Encoder_id().Test__encode(">", ".3E");
fxt.Encoder_id().Test__decode(".3E", ">");
}
@Test public void Id__syms_2_lodash() { // ISSUE#:462; DATE:2019-05-12
@Test public void Id__syms_2_lodash() { // ISSUE#:462; DATE:2019-05-12
fxt.Encoder_id().Test__encode("_", "_");
fxt.Encoder_id().Test__decode("_", " ");
}
@Test public void Id__nbsp() {
@Test public void Id__nbsp() {
fxt.Encoder_id().Test__encode("a&nbsp;b", "a.C2.A0b"); // NOTE: not just .A0 (160) but utf8-encoded .C2.A0
fxt.Encoder_id().Test__decode("a.C2.A0b", "a b"); // WS is nbsp
}
@Test public void Id__err() {
@Test public void Id__err() {
byte[] raw = Bry_.new_a7("0%.jpg");
Bry_bfr tmp_bfr = Bry_bfr_.New();
fxt.Encoder_id().Encoder().Decode(tmp_bfr, Bool_.N, raw, 0, raw.length);
Tfds.Eq("0%.jpg", tmp_bfr.To_str_and_clear());
}
@Test public void Ttl__syms__diff() {fxt.Encoder_ttl().Test__encode(" &'=+", "_%26%27%3D%2B");}
@Test public void Ttl__syms__same() {fxt.Encoder_ttl().Test__encode("!\"#$%()*,-./:;<>?@[\\]^_`{|}~", "!\"#$%()*,-./:;<>?@[\\]^_`{|}~");}
@Test public void Url__syms() {fxt.Encoder_url().Test__bicode("!?^~", "%21%3F%5E%7E");}
@Test public void Url__foreign() {fxt.Encoder_url().Test__bicode("aéb", "a%C3%A9b");}
@Test public void Url__space() {fxt.Encoder_url().Test__bicode("a b", "a+b");}
@Test public void Href__space() {
@Test public void Ttl__syms__diff() {fxt.Encoder_ttl().Test__encode(" &'=+", "_%26%27%3D%2B");}
@Test public void Ttl__syms__same() {fxt.Encoder_ttl().Test__encode("!\"#$%()*,-./:;<>?@[\\]^_`{|}~", "!\"#$%()*,-./:;<>?@[\\]^_`{|}~");}
@Test public void Url__syms() {fxt.Encoder_url().Test__bicode("!?^~", "%21%3F%5E%7E");}
@Test public void Url__foreign() {fxt.Encoder_url().Test__bicode("aéb", "a%C3%A9b");}
@Test public void Url__space() {fxt.Encoder_url().Test__bicode("a b", "a+b");}
@Test public void Href__space() {
fxt.Encoder_href().Test__encode("a b", "a_b");
}
@Test public void Href__special_and_anchor() { // PURPOSE: MediaWiki encodes with % for ttls, but . for anchors; REF:Title.php!(before-anchor)getLocalUrl;wfUrlencode (after-anchor)escapeFragmentForURL
@Test public void Href__special_and_anchor() { // PURPOSE: MediaWiki encodes with % for ttls, but . for anchors; REF:Title.php!(before-anchor)getLocalUrl;wfUrlencode (after-anchor)escapeFragmentForURL
fxt.Encoder_href().Test__bicode("^#^", "%5E#^");
fxt.Encoder_href().Test__encode("A#", "A#");
}
@Test public void Href__invalid() { // PURPOSE: check that invalid url decodings are rendered literally; DATE:2014-04-10
@Test public void Href__invalid() { // PURPOSE: check that invalid url decodings are rendered literally; DATE:2014-04-10
fxt.Encoder_href().Test__encode("%GC", "%25GC");
}
@Test public void Fsys__wnt() {
@Test public void Fsys__wnt() {
fxt.Encoder_fsys_safe().Test__encode("Options/HTML", "Options%2FHTML");
}
}

View File

@@ -1,40 +1,40 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.langs.htmls.styles; import gplx.*; import gplx.langs.*; import gplx.langs.htmls.*;
import org.junit.*;
public class Gfh_style_parser__tst {
private final Gfh_style_parser__fxt fxt = new Gfh_style_parser__fxt();
@Test public void Basic() {
@Test public void Basic() {
fxt.Test__parse("k_0:v_0" , fxt.Make("k_0", "v_0"));
fxt.Test__parse("k_0:v_0;" , fxt.Make("k_0", "v_0"));
fxt.Test__parse("k_0:v_0;k_1:v_1" , fxt.Make("k_0", "v_0"), fxt.Make("k_1", "v_1"));
}
@Test public void Ws() {
@Test public void Ws() {
fxt.Test__parse(" k_0 : v_0 ;" , fxt.Make("k_0", "v_0"));
fxt.Test__parse(" k_0 : v_0 ; k_1 : v_1 " , fxt.Make("k_0", "v_0"), fxt.Make("k_1", "v_1"));
fxt.Test__parse(" k_0 : v 0 ;" , fxt.Make("k_0", "v 0"));
}
@Test public void Empty() {
@Test public void Empty() {
fxt.Test__parse("k_0:v_0;;" , fxt.Make("k_0", "v_0"));
fxt.Test__parse("k_0:v_0; ; " , fxt.Make("k_0", "v_0"));
}
@Test public void Invalid__no_semic() {
@Test public void Invalid__no_semic() {
fxt.Test__parse("k_0" , fxt.Make("k_0", ""));
}
@Test public void Invalid__dupe_colon() {
@Test public void Invalid__dupe_colon() {
fxt.Test__parse("a:b:c:d;" , fxt.Make("a", "b:c:d"));
}
}

View File

@@ -1,23 +1,23 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.langs.jsons; import gplx.*; import gplx.langs.*;
import org.junit.*;
public class Json_doc_tst {
private final Json_qry_mgr_fxt fxt = new Json_qry_mgr_fxt();
@Test public void Select() {
@Test public void Select() {
Json_doc doc = fxt.Make_json
( "{'0':"
, " {'0_0':"

View File

@@ -1,23 +1,23 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.langs.jsons; import gplx.*; import gplx.langs.*;
import org.junit.*; import gplx.core.tests.*;
public class Json_doc_wtr_tst {
private final Json_doc_wtr_fxt fxt = new Json_doc_wtr_fxt();
@Test public void Basic() {
@Test public void Basic() {
fxt.Test__Bld_as_str
( fxt.Exec__Kv_simple("k1", "v\"1")
, fxt.Exec__Concat_apos
@@ -25,7 +25,7 @@ public class Json_doc_wtr_tst {
, " 'k1':'v\\\"1'"
, "}"));
}
@Test public void Quotes() {
@Test public void Quotes() {
fxt.Test__string__quotes("a\"z" , "a\\\"z");
fxt.Test__string__quotes("a\u0008z" , "a\\bz");
fxt.Test__string__quotes("a\fz" , "a\\fz");

View File

@@ -28,5 +28,5 @@ public abstract class Json_itm_base implements Json_itm {
return bfr.To_str_and_clear();
}
public abstract void Print_as_json(Bry_bfr bfr, int depth);
@gplx.Virtual public boolean Data_eq(byte[] comp) {return false;}
public boolean Data_eq(byte[] comp) {return false;}
}

View File

@@ -68,6 +68,6 @@ public class Json_parser__list_nde__base extends Json_parser__itm__base {
list.Add(key, Keyval_.new_(String_.new_u8(key), String_.new_u8(val)));
}
}
@gplx.Virtual protected byte[] Parse_to_list_as_kv__get_val(Json_kv sub, byte[] key) {return sub.Val_as_bry();}
protected byte[] Parse_to_list_as_kv__get_val(Json_kv sub, byte[] key) {return sub.Val_as_bry();}
@Override protected void Parse_hook_nde(Json_nde sub, Json_kv[] atrs) {}
}

View File

@@ -1,30 +1,30 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.langs.jsons; import gplx.*; import gplx.langs.*;
import org.junit.*;
public class Json_printer_tst {
private final Json_printer_fxt fxt = new Json_printer_fxt();
@Test public void Root_nde() {
@Test public void Root_nde() {
fxt.Test_print(Json_doc.Make_str_by_apos("{'k1':'v1','k2':'v2'}"), String_.Concat_lines_nl
( "{ 'k1':'v1'"
, ", 'k2':'v2'"
, "}"
));
}
@Test public void Root_ary() {
@Test public void Root_ary() {
fxt.Test_print(Json_doc.Make_str_by_apos("[1,2,3]"), String_.Concat_lines_nl
( "[ 1"
, ", 2"
@@ -32,7 +32,7 @@ public class Json_printer_tst {
, "]"
));
}
@Test public void Ary_w_ary() {
@Test public void Ary_w_ary() {
fxt.Test_print(Json_doc.Make_str_by_apos("[[1,2],[3,4]]"), String_.Concat_lines_nl
( "[ "
, " [ 1"
@@ -45,7 +45,7 @@ public class Json_printer_tst {
, "]"
));
}
@Test public void Ary_w_nde() {
@Test public void Ary_w_nde() {
fxt.Test_print(Json_doc.Make_str_by_apos("[{'k1':'v1','k2':'v2'},{'k3':'v3','k4':'v4'}]"), String_.Concat_lines_nl
( "[ "
, " { 'k1':'v1'"
@@ -58,7 +58,7 @@ public class Json_printer_tst {
, "]"
));
}
@Test public void Nde_w_ary() {
@Test public void Nde_w_ary() {
fxt.Test_print(Json_doc.Make_str_by_apos("{'k1':[1,2],'k2':[3,4]}"), String_.Concat_lines_nl
( "{ 'k1':"
, " [ 1"
@@ -71,7 +71,7 @@ public class Json_printer_tst {
, "}"
));
}
// @Test public void Smoke() {
// @Test public void Smoke() {
// Json_printer printer = new Json_printer();
// String url = "C:\\temp.json";
// String s = printer.Pretty_print_as_str(Bry_.new_u8(Io_mgr.Instance.LoadFilStr(url)));

View File

@@ -1,30 +1,30 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.langs.jsons; import gplx.*; import gplx.langs.*;
import org.junit.*;
public class Json_wtr_tst {
@Before public void init() {fxt.Clear();} private final Json_wtr_fxt fxt = new Json_wtr_fxt();
@Test public void Root() {
@Test public void Root() {
fxt.Wtr().Doc_nde_bgn().Doc_nde_end();
fxt.Test
( "{"
, "}"
);
}
@Test public void Kv() {
@Test public void Kv() {
fxt.Wtr()
.Doc_nde_bgn()
.Kv_str("k0", "v0")
@@ -36,7 +36,7 @@ public class Json_wtr_tst {
, "}"
);
}
@Test public void Escaped() {
@Test public void Escaped() {
fxt.Wtr()
.Doc_nde_bgn()
.Kv_str("backslash", "\\")
@@ -56,7 +56,7 @@ public class Json_wtr_tst {
, "}"
);
}
@Test public void Nde() {
@Test public void Nde() {
fxt.Wtr()
.Doc_nde_bgn()
.Nde_bgn("s0")
@@ -82,7 +82,7 @@ public class Json_wtr_tst {
, "}"
);
}
@Test public void Ary() {
@Test public void Ary() {
fxt.Wtr()
.Doc_nde_bgn()
.Ary_bgn("a0")
@@ -98,7 +98,7 @@ public class Json_wtr_tst {
, "}"
);
}
@Test public void Nde__nested() {
@Test public void Nde__nested() {
fxt.Wtr()
.Doc_nde_bgn()
.Ary_bgn("a0")

View File

@@ -1,189 +1,189 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2020 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.langs.mustaches;
import gplx.Bry_;
import gplx.Hash_adp;
import gplx.Hash_adp_;
import gplx.Tfds;
import gplx.core.primitives.Bool_obj_ref;
import gplx.langs.jsons.Json_doc;
import gplx.langs.jsons.Json_nde;
import gplx.langs.jsons.Json_parser;
import org.junit.Test;
public class Mustache_itm_render_tst {
private final Mustache_itm_render_fxt fxt = new Mustache_itm_render_fxt();
@Test public void Text() {
fxt.Test__parse("a b c", "a b c");
}
@Test public void Variable() {
fxt.Init__root(fxt.Make_mock(0).Add_prop("prop1", "1").Add_prop("prop2", "2"));
fxt.Test__parse("{{prop1}}", "1");
fxt.Test__parse("a{{prop1}}b{{prop2}}c", "a1b2c");
}
@Test public void Escape() {
fxt.Init__root(fxt.Make_mock(0).Add_prop("prop1", "<"));
fxt.Test__parse("{{{prop1}}}", "<");
fxt.Test__parse("{{prop1}}", "&lt;");
}
@Test public void Section_bool() {
fxt.Init__root(fxt.Make_mock(0).Add_bool_y("bool_y").Add_bool_n("bool_n"));
fxt.Test__parse("a{{#bool_y}}b{{/bool_y}}c", "abc");
fxt.Test__parse("a{{#bool_n}}b{{/bool_n}}c", "ac");
fxt.Test__parse("a{{#bool_y}}b{{/bool_y}}c{{#bool_n}}d{{/bool_n}}e", "abce");
}
@Test public void Section_not() {
fxt.Init__root(fxt.Make_mock(0).Add_bool_y("bool_y").Add_bool_n("bool_n"));
fxt.Test__parse("a{{^bool_y}}b{{/bool_y}}c", "ac");
fxt.Test__parse("a{{^bool_n}}b{{/bool_n}}c", "abc");
fxt.Test__parse("a{{^bool_y}}b{{/bool_y}}c{{^bool_n}}d{{/bool_n}}e", "acde");
}
@Test public void Section_ws() {
fxt.Init__root(fxt.Make_mock(0).Add_bool_y("bool_y"));
fxt.Test__parse("a\n {{#bool_y}} \nb\n {{/bool_y}} \nc", "a\nb\nc");
}
@Test public void Section_subs_flat() {
fxt.Init__root(fxt.Make_mock(0).Add_subs("subs1"
, fxt.Make_mock(1).Add_prop("prop1", "1").Add_subs("subs2")
, fxt.Make_mock(2).Add_prop("prop1", "2").Add_subs("subs2")
));
fxt.Test__parse("a{{#subs1}}({{prop1}}){{/subs1}}d", "a(1)(2)d");
}
@Test public void Section_subs_nest_1() {
fxt.Init__root
( fxt.Make_mock(0).Add_subs("subs1"
, fxt.Make_mock(1).Add_prop("prop1", "a").Add_subs("subs2"
, fxt.Make_mock(11).Add_prop("prop2", "1")
, fxt.Make_mock(12).Add_prop("prop2", "2"))
));
fxt.Test__parse
( "{{#subs1}}{{prop1}}{{#subs2}}{{prop2}}{{/subs2}}{{/subs1}}"
, "a12"
);
}
@Test public void Section_subs_nest_2() {
fxt.Init__root
( fxt.Make_mock(0).Add_subs("subs1"
, fxt.Make_mock(1).Add_prop("prop1", "a").Add_subs("subs2"
, fxt.Make_mock(11).Add_prop("prop2", "1")
, fxt.Make_mock(12).Add_prop("prop2", "2")
)
, fxt.Make_mock(2).Add_prop("prop1", "b")
)
);
fxt.Test__parse
( "{{#subs1}}{{prop1}}{{#subs2}}{{prop2}}{{/subs2}}{{/subs1}}"
, "a12b"
);
}
@Test public void Section_subs_nest_3() {
fxt.Init__root
( fxt.Make_mock(0).Add_subs("subs1"
, fxt.Make_mock(1).Add_prop("prop1", "a").Add_subs("subs2"
, fxt.Make_mock(11).Add_prop("prop2", "1")
, fxt.Make_mock(12).Add_prop("prop2", "2")
)
, fxt.Make_mock(2).Add_prop("prop1", "b").Add_subs("subs2"
, fxt.Make_mock(21).Add_prop("prop2", "3")
, fxt.Make_mock(22).Add_prop("prop2", "4")
)
)
);
fxt.Test__parse
( "{{#subs1}}{{prop1}}{{#subs2}}{{prop2}}{{/subs2}}{{prop1}}{{/subs1}}"
, "a12ab34b"
);
}
@Test public void Section_bool_subs() { // handle prop written after boolean; should not pick up inner prop
fxt.Init__root
( fxt.Make_mock(0).Add_bool_y("bool1").Add_prop("prop2", "2").Add_subs("subs1"
, fxt.Make_mock(1).Add_prop("prop1", "11")
, fxt.Make_mock(2).Add_prop("prop1", "12")
));
fxt.Test__parse
( "a{{#bool1}}b{{#subs1}}c{{prop1}}d{{/subs1}}e{{/bool1}}f{{prop2}}g"
, "abc11dc12def2g"
);
}
@Test public void Section_owner() {
fxt.Init__root
( fxt.Make_mock(0).Add_subs("subs1"
, fxt.Make_mock(1).Add_prop("prop1", "a").Add_subs("subs2"
, fxt.Make_mock(11).Add_prop("prop2", "1")
)
));
fxt.Test__parse
( "{{#subs1}}{{#subs2}}{{prop1}}{{prop2}}{{/subs2}}{{/subs1}}" // prop1 is cited in subs2, but value belongs to subs1
, "a1"
);
}
@Test public void Dot() {
fxt.Test__parse
( "{'subs':['a', 'b', 'c', 'd']}"
, "{{#subs}}{{.}},{{/subs}}"
, "a,b,c,d,"
);
}
}
class Mustache_itm_render_fxt {
private final Mustache_tkn_parser parser = new Mustache_tkn_parser();
private final Mustache_render_ctx ctx = new Mustache_render_ctx();
private final Mustache_bfr bfr = Mustache_bfr.New();
private Mustache_doc_itm__mock root;
public Mustache_doc_itm__mock Make_mock(int id) {return new Mustache_doc_itm__mock(id);}
public void Init__root(Mustache_doc_itm__mock v) {this.root = v;}
public void Test__parse(String src_str, String expd) {
byte[] src_bry = Bry_.new_a7(src_str);
Mustache_tkn_itm actl_itm = parser.Parse(src_bry, 0, src_bry.length);
ctx.Init(root);
actl_itm.Render(bfr, ctx);
Tfds.Eq_str_lines(expd, bfr.To_str_and_clear());
}
public void Test__parse(String jdoc, String src_str, String expd) {
Json_nde jnde = Json_parser.ParseToJdoc(Json_doc.Make_str_by_apos(jdoc)).Root_nde();
JsonMustacheNde nde = new JsonMustacheNde(jnde);
byte[] src_bry = Bry_.new_a7(src_str);
Mustache_tkn_itm actl_itm = parser.Parse(src_bry, 0, src_bry.length);
ctx.Init(nde);
actl_itm.Render(bfr, ctx);
Tfds.Eq_str_lines(expd, bfr.To_str_and_clear());
}
}
class Mustache_doc_itm__mock implements Mustache_doc_itm {
private final Hash_adp hash_prop = Hash_adp_.New(), hash_bool = Hash_adp_.New(), hash_subs = Hash_adp_.New();
public Mustache_doc_itm__mock(int id) {this.id = id;}
public int id;
public Mustache_doc_itm__mock Add_prop(String key, String val) {hash_prop.Add(key, Bry_.new_u8(val)); return this;}
public Mustache_doc_itm__mock Add_bool_y(String key) {hash_bool.Add(key, Bool_obj_ref.y_()); return this;}
public Mustache_doc_itm__mock Add_bool_n(String key) {hash_bool.Add(key, Bool_obj_ref.n_()); return this;}
public Mustache_doc_itm__mock Add_subs(String key, Mustache_doc_itm__mock... ary) {hash_subs.Add(key, ary); return this;}
public boolean Mustache__write(String key, Mustache_bfr bfr) {
byte[] rv = (byte[])hash_prop.Get_by(key);
if (rv == null) return false;
bfr.Add_bry(rv);
return true;
}
public Mustache_doc_itm[] Mustache__subs(String key) {
Object rv = hash_bool.Get_by(key);
if (rv != null) {
boolean bool_val = ((Bool_obj_ref)rv).Val();
return bool_val ? Mustache_doc_itm_.Ary__bool__y : Mustache_doc_itm_.Ary__bool__n;
}
return (Mustache_doc_itm__mock[])hash_subs.Get_by(key);
}
}
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2020 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.langs.mustaches;
import gplx.Bry_;
import gplx.Hash_adp;
import gplx.Hash_adp_;
import gplx.Tfds;
import gplx.core.primitives.Bool_obj_ref;
import gplx.langs.jsons.Json_doc;
import gplx.langs.jsons.Json_nde;
import gplx.langs.jsons.Json_parser;
import org.junit.Test;
public class Mustache_itm_render_tst {
private final Mustache_itm_render_fxt fxt = new Mustache_itm_render_fxt();
@Test public void Text() {
fxt.Test__parse("a b c", "a b c");
}
@Test public void Variable() {
fxt.Init__root(fxt.Make_mock(0).Add_prop("prop1", "1").Add_prop("prop2", "2"));
fxt.Test__parse("{{prop1}}", "1");
fxt.Test__parse("a{{prop1}}b{{prop2}}c", "a1b2c");
}
@Test public void Escape() {
fxt.Init__root(fxt.Make_mock(0).Add_prop("prop1", "<"));
fxt.Test__parse("{{{prop1}}}", "<");
fxt.Test__parse("{{prop1}}", "&lt;");
}
@Test public void Section_bool() {
fxt.Init__root(fxt.Make_mock(0).Add_bool_y("bool_y").Add_bool_n("bool_n"));
fxt.Test__parse("a{{#bool_y}}b{{/bool_y}}c", "abc");
fxt.Test__parse("a{{#bool_n}}b{{/bool_n}}c", "ac");
fxt.Test__parse("a{{#bool_y}}b{{/bool_y}}c{{#bool_n}}d{{/bool_n}}e", "abce");
}
@Test public void Section_not() {
fxt.Init__root(fxt.Make_mock(0).Add_bool_y("bool_y").Add_bool_n("bool_n"));
fxt.Test__parse("a{{^bool_y}}b{{/bool_y}}c", "ac");
fxt.Test__parse("a{{^bool_n}}b{{/bool_n}}c", "abc");
fxt.Test__parse("a{{^bool_y}}b{{/bool_y}}c{{^bool_n}}d{{/bool_n}}e", "acde");
}
@Test public void Section_ws() {
fxt.Init__root(fxt.Make_mock(0).Add_bool_y("bool_y"));
fxt.Test__parse("a\n {{#bool_y}} \nb\n {{/bool_y}} \nc", "a\nb\nc");
}
@Test public void Section_subs_flat() {
fxt.Init__root(fxt.Make_mock(0).Add_subs("subs1"
, fxt.Make_mock(1).Add_prop("prop1", "1").Add_subs("subs2")
, fxt.Make_mock(2).Add_prop("prop1", "2").Add_subs("subs2")
));
fxt.Test__parse("a{{#subs1}}({{prop1}}){{/subs1}}d", "a(1)(2)d");
}
@Test public void Section_subs_nest_1() {
fxt.Init__root
( fxt.Make_mock(0).Add_subs("subs1"
, fxt.Make_mock(1).Add_prop("prop1", "a").Add_subs("subs2"
, fxt.Make_mock(11).Add_prop("prop2", "1")
, fxt.Make_mock(12).Add_prop("prop2", "2"))
));
fxt.Test__parse
( "{{#subs1}}{{prop1}}{{#subs2}}{{prop2}}{{/subs2}}{{/subs1}}"
, "a12"
);
}
@Test public void Section_subs_nest_2() {
fxt.Init__root
( fxt.Make_mock(0).Add_subs("subs1"
, fxt.Make_mock(1).Add_prop("prop1", "a").Add_subs("subs2"
, fxt.Make_mock(11).Add_prop("prop2", "1")
, fxt.Make_mock(12).Add_prop("prop2", "2")
)
, fxt.Make_mock(2).Add_prop("prop1", "b")
)
);
fxt.Test__parse
( "{{#subs1}}{{prop1}}{{#subs2}}{{prop2}}{{/subs2}}{{/subs1}}"
, "a12b"
);
}
@Test public void Section_subs_nest_3() {
fxt.Init__root
( fxt.Make_mock(0).Add_subs("subs1"
, fxt.Make_mock(1).Add_prop("prop1", "a").Add_subs("subs2"
, fxt.Make_mock(11).Add_prop("prop2", "1")
, fxt.Make_mock(12).Add_prop("prop2", "2")
)
, fxt.Make_mock(2).Add_prop("prop1", "b").Add_subs("subs2"
, fxt.Make_mock(21).Add_prop("prop2", "3")
, fxt.Make_mock(22).Add_prop("prop2", "4")
)
)
);
fxt.Test__parse
( "{{#subs1}}{{prop1}}{{#subs2}}{{prop2}}{{/subs2}}{{prop1}}{{/subs1}}"
, "a12ab34b"
);
}
@Test public void Section_bool_subs() { // handle prop written after boolean; should not pick up inner prop
fxt.Init__root
( fxt.Make_mock(0).Add_bool_y("bool1").Add_prop("prop2", "2").Add_subs("subs1"
, fxt.Make_mock(1).Add_prop("prop1", "11")
, fxt.Make_mock(2).Add_prop("prop1", "12")
));
fxt.Test__parse
( "a{{#bool1}}b{{#subs1}}c{{prop1}}d{{/subs1}}e{{/bool1}}f{{prop2}}g"
, "abc11dc12def2g"
);
}
@Test public void Section_owner() {
fxt.Init__root
( fxt.Make_mock(0).Add_subs("subs1"
, fxt.Make_mock(1).Add_prop("prop1", "a").Add_subs("subs2"
, fxt.Make_mock(11).Add_prop("prop2", "1")
)
));
fxt.Test__parse
( "{{#subs1}}{{#subs2}}{{prop1}}{{prop2}}{{/subs2}}{{/subs1}}" // prop1 is cited in subs2, but value belongs to subs1
, "a1"
);
}
@Test public void Dot() {
fxt.Test__parse
( "{'subs':['a', 'b', 'c', 'd']}"
, "{{#subs}}{{.}},{{/subs}}"
, "a,b,c,d,"
);
}
}
class Mustache_itm_render_fxt {
private final Mustache_tkn_parser parser = new Mustache_tkn_parser();
private final Mustache_render_ctx ctx = new Mustache_render_ctx();
private final Mustache_bfr bfr = Mustache_bfr.New();
private Mustache_doc_itm__mock root;
public Mustache_doc_itm__mock Make_mock(int id) {return new Mustache_doc_itm__mock(id);}
public void Init__root(Mustache_doc_itm__mock v) {this.root = v;}
public void Test__parse(String src_str, String expd) {
byte[] src_bry = Bry_.new_a7(src_str);
Mustache_tkn_itm actl_itm = parser.Parse(src_bry, 0, src_bry.length);
ctx.Init(root);
actl_itm.Render(bfr, ctx);
Tfds.Eq_str_lines(expd, bfr.To_str_and_clear());
}
public void Test__parse(String jdoc, String src_str, String expd) {
Json_nde jnde = Json_parser.ParseToJdoc(Json_doc.Make_str_by_apos(jdoc)).Root_nde();
JsonMustacheNde nde = new JsonMustacheNde(jnde);
byte[] src_bry = Bry_.new_a7(src_str);
Mustache_tkn_itm actl_itm = parser.Parse(src_bry, 0, src_bry.length);
ctx.Init(nde);
actl_itm.Render(bfr, ctx);
Tfds.Eq_str_lines(expd, bfr.To_str_and_clear());
}
}
class Mustache_doc_itm__mock implements Mustache_doc_itm {
private final Hash_adp hash_prop = Hash_adp_.New(), hash_bool = Hash_adp_.New(), hash_subs = Hash_adp_.New();
public Mustache_doc_itm__mock(int id) {this.id = id;}
public int id;
public Mustache_doc_itm__mock Add_prop(String key, String val) {hash_prop.Add(key, Bry_.new_u8(val)); return this;}
public Mustache_doc_itm__mock Add_bool_y(String key) {hash_bool.Add(key, Bool_obj_ref.y_()); return this;}
public Mustache_doc_itm__mock Add_bool_n(String key) {hash_bool.Add(key, Bool_obj_ref.n_()); return this;}
public Mustache_doc_itm__mock Add_subs(String key, Mustache_doc_itm__mock... ary) {hash_subs.Add(key, ary); return this;}
public boolean Mustache__write(String key, Mustache_bfr bfr) {
byte[] rv = (byte[])hash_prop.Get_by(key);
if (rv == null) return false;
bfr.Add_bry(rv);
return true;
}
public Mustache_doc_itm[] Mustache__subs(String key) {
Object rv = hash_bool.Get_by(key);
if (rv != null) {
boolean bool_val = ((Bool_obj_ref)rv).Val();
return bool_val ? Mustache_doc_itm_.Ary__bool__y : Mustache_doc_itm_.Ary__bool__n;
}
return (Mustache_doc_itm__mock[])hash_subs.Get_by(key);
}
}

View File

@@ -1,126 +1,126 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2020 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.langs.mustaches;
import gplx.Bool_;
import gplx.Bry_;
import gplx.Byte_ascii;
import gplx.Err_;
import gplx.Io_url;
import gplx.String_;
public interface Mustache_tkn_itm {
int Tid();
String Key();
Mustache_tkn_itm[] Subs_ary();
void Subs_ary_(Mustache_tkn_itm[] v);
void Render(Mustache_bfr bfr, Mustache_render_ctx ctx);
}
class Mustache_tkn_itm_ {// for types, see http://mustache.github.io/mustache.5.html
public static final int Tid__root = 0, Tid__text = 1, Tid__variable = 2, Tid__escape = 3, Tid__section = 4, Tid__inverted = 5, Tid__comment = 6, Tid__partial = 7, Tid__delimiter = 8;
public static final Mustache_tkn_itm[] Ary_empty = new Mustache_tkn_itm[0];
}
abstract class Mustache_tkn_base implements Mustache_tkn_itm {
public Mustache_tkn_base(int tid, byte[] key_bry) {this.tid = tid; this.key = String_.new_u8(key_bry);}
public int Tid() {return tid;} private final int tid;
public String Key() {return key;} private final String key;
@gplx.Virtual public Mustache_tkn_itm[] Subs_ary() {return Mustache_tkn_itm_.Ary_empty;}
@gplx.Virtual public void Subs_ary_(Mustache_tkn_itm[] v) {throw Err_.new_unsupported();} // fail if trying to set and not overridden
@gplx.Virtual public void Render(Mustache_bfr bfr, Mustache_render_ctx ctx) {throw Err_.new_unsupported();} // should be abstract
}
class Mustache_tkn_root extends Mustache_tkn_base { // EX: {{variable}} -> &lt;a&gt;
private Mustache_tkn_itm[] subs_ary;
public Mustache_tkn_root() {super(Mustache_tkn_itm_.Tid__root, Bry_.Empty);}
@Override public Mustache_tkn_itm[] Subs_ary() {return subs_ary;}
@Override public void Subs_ary_(Mustache_tkn_itm[] v) {subs_ary = v;}
@Override public void Render(Mustache_bfr bfr, Mustache_render_ctx ctx) {
int subs_len = subs_ary.length;
for (int i = 0; i < subs_len; ++i) {
Mustache_tkn_itm sub = subs_ary[i];
sub.Render(bfr, ctx);
}
}
}
class Mustache_tkn_text extends Mustache_tkn_base { // EX: text -> text
private final byte[] src; private final int src_bgn, src_end;
public Mustache_tkn_text(byte[] src, int src_bgn, int src_end) {super(Mustache_tkn_itm_.Tid__text, Bry_.Empty);
this.src = src;
this.src_bgn = src_bgn;
this.src_end = src_end;
}
@Override public void Render(Mustache_bfr bfr, Mustache_render_ctx ctx) {
bfr.Add_mid(src, src_bgn, src_end);
}
}
class Mustache_tkn_comment extends Mustache_tkn_base { // EX: {{!section}}comment{{/section}} ->
public Mustache_tkn_comment() {super(Mustache_tkn_itm_.Tid__comment, Bry_.Empty);}
@Override public void Render(Mustache_bfr bfr, Mustache_render_ctx ctx) {}
}
class Mustache_tkn_variable extends Mustache_tkn_base { // EX: {{variable}} -> &lt;a&gt;
public Mustache_tkn_variable(byte[] key) {super(Mustache_tkn_itm_.Tid__variable, key);}
@Override public void Render(Mustache_bfr bfr, Mustache_render_ctx ctx) {
String key = this.Key();
ctx.Render_variable(bfr.Escape_(Bool_.Y), key);
}
}
class Mustache_tkn_escape extends Mustache_tkn_base { // EX: {{{variable}}} -> <a>
public Mustache_tkn_escape(byte[] key) {super(Mustache_tkn_itm_.Tid__escape, key);}
@Override public void Render(Mustache_bfr bfr, Mustache_render_ctx ctx) {
String key = this.Key();
ctx.Render_variable(bfr.Escape_(Bool_.N), key);
}
}
class Mustache_tkn_section extends Mustache_tkn_base { // EX: {{#section}}val{{/section}} -> val (if boolean) or valvalval (if list)
private Mustache_tkn_itm[] subs_ary;
public Mustache_tkn_section(byte[] key) {super(Mustache_tkn_itm_.Tid__section, key);}
@Override public Mustache_tkn_itm[] Subs_ary() {return subs_ary;}
@Override public void Subs_ary_(Mustache_tkn_itm[] v) {subs_ary = v;}
@Override public void Render(Mustache_bfr bfr, Mustache_render_ctx ctx) {Render_static(Bool_.N, this, bfr, ctx);}
public static void Render_static(boolean inverted, Mustache_tkn_base tkn, Mustache_bfr bfr, Mustache_render_ctx ctx) {
String key = tkn.Key();
Mustache_tkn_itm[] subs_ary = tkn.Subs_ary();
ctx.Section_bgn(key);
while (ctx.Section_do(inverted)) {
int subs_len = subs_ary.length;
for (int i = 0; i < subs_len; ++i) {
Mustache_tkn_itm sub = subs_ary[i];
sub.Render(bfr, ctx);
}
}
ctx.Section_end();
}
}
class Mustache_tkn_inverted extends Mustache_tkn_base { // EX: {{^section}}missing{{/section}} -> missing
private Mustache_tkn_itm[] subs_ary;
public Mustache_tkn_inverted(byte[] key) {super(Mustache_tkn_itm_.Tid__inverted, key);}
@Override public Mustache_tkn_itm[] Subs_ary() {return subs_ary;}
@Override public void Subs_ary_(Mustache_tkn_itm[] v) {subs_ary = v;}
@Override public void Render(Mustache_bfr bfr, Mustache_render_ctx ctx) {Mustache_tkn_section.Render_static(Bool_.Y, this, bfr, ctx);}
}
class Mustache_tkn_partial extends Mustache_tkn_base { // EX: {{>a}} -> abc (deferred eval)
private Mustache_tkn_itm template_root;
public Mustache_tkn_partial(byte[] key, Io_url dir) {
super(Mustache_tkn_itm_.Tid__partial, key);
Mustache_tkn_parser parser = new Mustache_tkn_parser(dir);
template_root = parser.Parse(String_.new_a7(Bry_.Trim_bgn(key, Byte_ascii.Space, 0)));
}
@Override public void Render(Mustache_bfr bfr, Mustache_render_ctx ctx) {
template_root.Render(bfr, ctx);
}
}
class Mustache_tkn_delimiter extends Mustache_tkn_base { // EX: {{=<% %>=}} -> <% variable %>
public Mustache_tkn_delimiter(byte[] key) {super(Mustache_tkn_itm_.Tid__delimiter, key);}
}
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2020 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.langs.mustaches;
import gplx.Bool_;
import gplx.Bry_;
import gplx.Byte_ascii;
import gplx.Err_;
import gplx.Io_url;
import gplx.String_;
public interface Mustache_tkn_itm {
int Tid();
String Key();
Mustache_tkn_itm[] Subs_ary();
void Subs_ary_(Mustache_tkn_itm[] v);
void Render(Mustache_bfr bfr, Mustache_render_ctx ctx);
}
class Mustache_tkn_itm_ {// for types, see http://mustache.github.io/mustache.5.html
public static final int Tid__root = 0, Tid__text = 1, Tid__variable = 2, Tid__escape = 3, Tid__section = 4, Tid__inverted = 5, Tid__comment = 6, Tid__partial = 7, Tid__delimiter = 8;
public static final Mustache_tkn_itm[] Ary_empty = new Mustache_tkn_itm[0];
}
abstract class Mustache_tkn_base implements Mustache_tkn_itm {
public Mustache_tkn_base(int tid, byte[] key_bry) {this.tid = tid; this.key = String_.new_u8(key_bry);}
public int Tid() {return tid;} private final int tid;
public String Key() {return key;} private final String key;
public Mustache_tkn_itm[] Subs_ary() {return Mustache_tkn_itm_.Ary_empty;}
public void Subs_ary_(Mustache_tkn_itm[] v) {throw Err_.new_unsupported();} // fail if trying to set and not overridden
public void Render(Mustache_bfr bfr, Mustache_render_ctx ctx) {throw Err_.new_unsupported();} // should be abstract
}
class Mustache_tkn_root extends Mustache_tkn_base { // EX: {{variable}} -> &lt;a&gt;
private Mustache_tkn_itm[] subs_ary;
public Mustache_tkn_root() {super(Mustache_tkn_itm_.Tid__root, Bry_.Empty);}
@Override public Mustache_tkn_itm[] Subs_ary() {return subs_ary;}
@Override public void Subs_ary_(Mustache_tkn_itm[] v) {subs_ary = v;}
@Override public void Render(Mustache_bfr bfr, Mustache_render_ctx ctx) {
int subs_len = subs_ary.length;
for (int i = 0; i < subs_len; ++i) {
Mustache_tkn_itm sub = subs_ary[i];
sub.Render(bfr, ctx);
}
}
}
class Mustache_tkn_text extends Mustache_tkn_base { // EX: text -> text
private final byte[] src; private final int src_bgn, src_end;
public Mustache_tkn_text(byte[] src, int src_bgn, int src_end) {super(Mustache_tkn_itm_.Tid__text, Bry_.Empty);
this.src = src;
this.src_bgn = src_bgn;
this.src_end = src_end;
}
@Override public void Render(Mustache_bfr bfr, Mustache_render_ctx ctx) {
bfr.Add_mid(src, src_bgn, src_end);
}
}
class Mustache_tkn_comment extends Mustache_tkn_base { // EX: {{!section}}comment{{/section}} ->
public Mustache_tkn_comment() {super(Mustache_tkn_itm_.Tid__comment, Bry_.Empty);}
@Override public void Render(Mustache_bfr bfr, Mustache_render_ctx ctx) {}
}
class Mustache_tkn_variable extends Mustache_tkn_base { // EX: {{variable}} -> &lt;a&gt;
public Mustache_tkn_variable(byte[] key) {super(Mustache_tkn_itm_.Tid__variable, key);}
@Override public void Render(Mustache_bfr bfr, Mustache_render_ctx ctx) {
String key = this.Key();
ctx.Render_variable(bfr.Escape_(Bool_.Y), key);
}
}
class Mustache_tkn_escape extends Mustache_tkn_base { // EX: {{{variable}}} -> <a>
public Mustache_tkn_escape(byte[] key) {super(Mustache_tkn_itm_.Tid__escape, key);}
@Override public void Render(Mustache_bfr bfr, Mustache_render_ctx ctx) {
String key = this.Key();
ctx.Render_variable(bfr.Escape_(Bool_.N), key);
}
}
class Mustache_tkn_section extends Mustache_tkn_base { // EX: {{#section}}val{{/section}} -> val (if boolean) or valvalval (if list)
private Mustache_tkn_itm[] subs_ary;
public Mustache_tkn_section(byte[] key) {super(Mustache_tkn_itm_.Tid__section, key);}
@Override public Mustache_tkn_itm[] Subs_ary() {return subs_ary;}
@Override public void Subs_ary_(Mustache_tkn_itm[] v) {subs_ary = v;}
@Override public void Render(Mustache_bfr bfr, Mustache_render_ctx ctx) {Render_static(Bool_.N, this, bfr, ctx);}
public static void Render_static(boolean inverted, Mustache_tkn_base tkn, Mustache_bfr bfr, Mustache_render_ctx ctx) {
String key = tkn.Key();
Mustache_tkn_itm[] subs_ary = tkn.Subs_ary();
ctx.Section_bgn(key);
while (ctx.Section_do(inverted)) {
int subs_len = subs_ary.length;
for (int i = 0; i < subs_len; ++i) {
Mustache_tkn_itm sub = subs_ary[i];
sub.Render(bfr, ctx);
}
}
ctx.Section_end();
}
}
class Mustache_tkn_inverted extends Mustache_tkn_base { // EX: {{^section}}missing{{/section}} -> missing
private Mustache_tkn_itm[] subs_ary;
public Mustache_tkn_inverted(byte[] key) {super(Mustache_tkn_itm_.Tid__inverted, key);}
@Override public Mustache_tkn_itm[] Subs_ary() {return subs_ary;}
@Override public void Subs_ary_(Mustache_tkn_itm[] v) {subs_ary = v;}
@Override public void Render(Mustache_bfr bfr, Mustache_render_ctx ctx) {Mustache_tkn_section.Render_static(Bool_.Y, this, bfr, ctx);}
}
class Mustache_tkn_partial extends Mustache_tkn_base { // EX: {{>a}} -> abc (deferred eval)
private Mustache_tkn_itm template_root;
public Mustache_tkn_partial(byte[] key, Io_url dir) {
super(Mustache_tkn_itm_.Tid__partial, key);
Mustache_tkn_parser parser = new Mustache_tkn_parser(dir);
template_root = parser.Parse(String_.new_a7(Bry_.Trim_bgn(key, Byte_ascii.Space, 0)));
}
@Override public void Render(Mustache_bfr bfr, Mustache_render_ctx ctx) {
template_root.Render(bfr, ctx);
}
}
class Mustache_tkn_delimiter extends Mustache_tkn_base { // EX: {{=<% %>=}} -> <% variable %>
public Mustache_tkn_delimiter(byte[] key) {super(Mustache_tkn_itm_.Tid__delimiter, key);}
}

View File

@@ -1,26 +1,26 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.langs.mustaches; import gplx.*; import gplx.langs.*;
import org.junit.*;
public class Mustache_tkn_parser_tst {
private final Mustache_tkn_parser_fxt fxt = new Mustache_tkn_parser_fxt();
@Test public void Basic() {
@Test public void Basic() {
fxt.Test_parse("a{{b}}c", "ac");
}
@Test public void Comment() {
@Test public void Comment() {
fxt.Test_parse("a{{!b}}c", "ac");
}
}

View File

@@ -1,18 +1,18 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.langs.phps; import gplx.*; import gplx.langs.*;
import gplx.core.tests.*; import gplx.core.log_msgs.*;
class Php_parser_fxt {
@@ -92,7 +92,7 @@ abstract class Php_tkn_chkr_base implements Tst_chkr {
rv += Chk_tkn(mgr, path, actl);
return rv;
}
@gplx.Virtual public int Chk_tkn(Tst_mgr mgr, String path, Php_tkn actl_obj) {return 0;}
public int Chk_tkn(Tst_mgr mgr, String path, Php_tkn actl_obj) {return 0;}
}
class Php_tkn_declaration_chkr extends Php_tkn_chkr_base {
@Override public Class<?> TypeOf() {return Php_tkn_declaration.class;}
@@ -194,7 +194,7 @@ abstract class Php_itm_chkr_base implements Tst_chkr {
rv += Chk_itm(mgr, path, actl);
return rv;
}
@gplx.Virtual public int Chk_itm(Tst_mgr mgr, String path, Php_itm actl_obj) {return 0;}
public int Chk_itm(Tst_mgr mgr, String path, Php_itm actl_obj) {return 0;}
public static final Php_itm_chkr_base[] Ary_empty = new Php_itm_chkr_base[0];
}
class Php_itm_generic_chkr extends Php_itm_chkr_base {

View File

@@ -1,65 +1,65 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.langs.phps; import gplx.*; import gplx.langs.*;
import org.junit.*;
public class Php_parser_tst {
@Before public void init() {fxt.Clear();} private final Php_parser_fxt fxt = new Php_parser_fxt();
@Test public void Text() {fxt.tst_tkns("text", fxt.tkn_txt(0, 4)); }
@Test public void Declaration_pass() {fxt.tst_tkns("<?php", fxt.tkn_declaration());}
@Test public void Declaration_fail() {fxt.tst_tkns("<?phpx", fxt.tkn_txt(0, 6));}
@Test public void Ws_basic() {fxt.tst_tkns(" ", fxt.tkn_ws(0, 1));}
@Test public void Ws_mix() {fxt.tst_tkns(" a\n", fxt.tkn_ws(0, 1), fxt.tkn_txt(1, 2), fxt.tkn_ws(2, 3));}
@Test public void Comment_mult() {fxt.tst_tkns("/*a*/", fxt.tkn_comment_mult(0, 5));}
@Test public void Comment_slash() {fxt.tst_tkns("//a\n", fxt.tkn_comment_slash(0, 4));}
@Test public void Comment_hash() {fxt.tst_tkns("#a\n", fxt.tkn_comment_hash(0, 3));}
@Test public void Comment_mult_fail() {fxt.Msg(Php_lxr_comment.Dangling_comment, 0, 2).tst_tkns("/*a", fxt.tkn_comment_mult(0, 3));}
@Test public void Var() {fxt.tst_tkns("$abc", fxt.tkn_var(0, 4, "abc"));}
@Test public void Sym() {fxt.tst_tkns(";==>,()", fxt.tkn_generic(0, 1, Php_tkn_.Tid_semic), fxt.tkn_generic(1, 2, Php_tkn_.Tid_eq), fxt.tkn_generic(2, 4, Php_tkn_.Tid_eq_kv), fxt.tkn_generic(4, 5, Php_tkn_.Tid_comma), fxt.tkn_generic(5, 6, Php_tkn_.Tid_paren_bgn), fxt.tkn_generic(6, 7, Php_tkn_.Tid_paren_end));}
@Test public void Keyword() {fxt.tst_tkns("null=nulla", fxt.tkn_generic(0, 4, Php_tkn_.Tid_null), fxt.tkn_generic(4, 5, Php_tkn_.Tid_eq), fxt.tkn_txt(5, 10));}
@Test public void Num() {fxt.tst_tkns("0=123", fxt.tkn_num(0, 1, 0), fxt.tkn_generic(1, 2, Php_tkn_.Tid_eq), fxt.tkn_num(2, 5, 123));}
@Test public void Quote_apos() {fxt.tst_tkns("'a\"b'", fxt.tkn_quote_apos(0, 5));}
@Test public void Quote_quote() {fxt.tst_tkns("\"a'b\"", fxt.tkn_quote_quote(0, 5));}
@Test public void Quote_escape() {fxt.tst_tkns("'a\\'b'", fxt.tkn_quote_apos(0, 6));}
@Test public void Brack() {fxt.tst_tkns("['a']", fxt.tkn_generic(0, 1, Php_tkn_.Tid_brack_bgn), fxt.tkn_quote_apos(1, 4), fxt.tkn_generic(4, 5, Php_tkn_.Tid_brack_end));}
@Test public void Line_ws() {fxt.tst_lines("\r\n$a = false;", fxt.line_assign("a", fxt.itm_bool_false()));}
@Test public void Line_brack() {fxt.tst_lines("$a['b'] = 'c';", fxt.line_assign_subs("a", String_.Ary("b"), fxt.itm_quote("c")));}
@Test public void Line_assign_false() {fxt.tst_lines("$a = false;", fxt.line_assign("a", fxt.itm_bool_false()));}
@Test public void Line_assign_quote_charcode() {fxt.tst_lines("$a = 'bc';", fxt.line_assign("a", fxt.itm_quote("bc")));}
@Test public void Line_assign_mult() {fxt.tst_lines("$a = 'b';\n$c='d';", fxt.line_assign("a", fxt.itm_quote("b")), fxt.line_assign("c", fxt.itm_quote("d")));}
@Test public void Empty_usr_array() {
@Test public void Text() {fxt.tst_tkns("text", fxt.tkn_txt(0, 4)); }
@Test public void Declaration_pass() {fxt.tst_tkns("<?php", fxt.tkn_declaration());}
@Test public void Declaration_fail() {fxt.tst_tkns("<?phpx", fxt.tkn_txt(0, 6));}
@Test public void Ws_basic() {fxt.tst_tkns(" ", fxt.tkn_ws(0, 1));}
@Test public void Ws_mix() {fxt.tst_tkns(" a\n", fxt.tkn_ws(0, 1), fxt.tkn_txt(1, 2), fxt.tkn_ws(2, 3));}
@Test public void Comment_mult() {fxt.tst_tkns("/*a*/", fxt.tkn_comment_mult(0, 5));}
@Test public void Comment_slash() {fxt.tst_tkns("//a\n", fxt.tkn_comment_slash(0, 4));}
@Test public void Comment_hash() {fxt.tst_tkns("#a\n", fxt.tkn_comment_hash(0, 3));}
@Test public void Comment_mult_fail() {fxt.Msg(Php_lxr_comment.Dangling_comment, 0, 2).tst_tkns("/*a", fxt.tkn_comment_mult(0, 3));}
@Test public void Var() {fxt.tst_tkns("$abc", fxt.tkn_var(0, 4, "abc"));}
@Test public void Sym() {fxt.tst_tkns(";==>,()", fxt.tkn_generic(0, 1, Php_tkn_.Tid_semic), fxt.tkn_generic(1, 2, Php_tkn_.Tid_eq), fxt.tkn_generic(2, 4, Php_tkn_.Tid_eq_kv), fxt.tkn_generic(4, 5, Php_tkn_.Tid_comma), fxt.tkn_generic(5, 6, Php_tkn_.Tid_paren_bgn), fxt.tkn_generic(6, 7, Php_tkn_.Tid_paren_end));}
@Test public void Keyword() {fxt.tst_tkns("null=nulla", fxt.tkn_generic(0, 4, Php_tkn_.Tid_null), fxt.tkn_generic(4, 5, Php_tkn_.Tid_eq), fxt.tkn_txt(5, 10));}
@Test public void Num() {fxt.tst_tkns("0=123", fxt.tkn_num(0, 1, 0), fxt.tkn_generic(1, 2, Php_tkn_.Tid_eq), fxt.tkn_num(2, 5, 123));}
@Test public void Quote_apos() {fxt.tst_tkns("'a\"b'", fxt.tkn_quote_apos(0, 5));}
@Test public void Quote_quote() {fxt.tst_tkns("\"a'b\"", fxt.tkn_quote_quote(0, 5));}
@Test public void Quote_escape() {fxt.tst_tkns("'a\\'b'", fxt.tkn_quote_apos(0, 6));}
@Test public void Brack() {fxt.tst_tkns("['a']", fxt.tkn_generic(0, 1, Php_tkn_.Tid_brack_bgn), fxt.tkn_quote_apos(1, 4), fxt.tkn_generic(4, 5, Php_tkn_.Tid_brack_end));}
@Test public void Line_ws() {fxt.tst_lines("\r\n$a = false;", fxt.line_assign("a", fxt.itm_bool_false()));}
@Test public void Line_brack() {fxt.tst_lines("$a['b'] = 'c';", fxt.line_assign_subs("a", String_.Ary("b"), fxt.itm_quote("c")));}
@Test public void Line_assign_false() {fxt.tst_lines("$a = false;", fxt.line_assign("a", fxt.itm_bool_false()));}
@Test public void Line_assign_quote_charcode() {fxt.tst_lines("$a = 'bc';", fxt.line_assign("a", fxt.itm_quote("bc")));}
@Test public void Line_assign_mult() {fxt.tst_lines("$a = 'b';\n$c='d';", fxt.line_assign("a", fxt.itm_quote("b")), fxt.line_assign("c", fxt.itm_quote("d")));}
@Test public void Empty_usr_array() {
fxt.tst_lines("$a = array();\n$b = array();"
, fxt.line_assign("a", fxt.itm_ary())
, fxt.line_assign("b", fxt.itm_ary())
);
}
@Test public void Ary_flat() {fxt.tst_lines("$a = array('b', 'c', 'd');" , fxt.line_assign("a", fxt.itm_ary().Subs_(fxt.itm_quote("b"), fxt.itm_quote("c"), fxt.itm_quote("d"))));}
@Test public void Brack_flat() {fxt.tst_lines("$a = ['b', 'c', 'd'];" , fxt.line_assign("a", fxt.itm_ary().Subs_(fxt.itm_quote("b"), fxt.itm_quote("c"), fxt.itm_quote("d"))));}
@Test public void Ary_flat_escape() { // PURPOSE.fix: \\' was being interpreted incorrectly; \\ should escape \, but somehow \' was being escaped
@Test public void Ary_flat() {fxt.tst_lines("$a = array('b', 'c', 'd');" , fxt.line_assign("a", fxt.itm_ary().Subs_(fxt.itm_quote("b"), fxt.itm_quote("c"), fxt.itm_quote("d"))));}
@Test public void Brack_flat() {fxt.tst_lines("$a = ['b', 'c', 'd'];" , fxt.line_assign("a", fxt.itm_ary().Subs_(fxt.itm_quote("b"), fxt.itm_quote("c"), fxt.itm_quote("d"))));}
@Test public void Ary_flat_escape() { // PURPOSE.fix: \\' was being interpreted incorrectly; \\ should escape \, but somehow \' was being escaped
fxt.tst_lines("$a = array('b\\\\', 'c');", fxt.line_assign("a", fxt.itm_ary().Subs_(fxt.itm_quote("b\\"), fxt.itm_quote("c"))));
}
@Test public void Ary_flat_escape2() { // PURPOSE.fix: \\' was being interpreted incorrectly; \\ should escape \, but somehow \' was being escaped
@Test public void Ary_flat_escape2() { // PURPOSE.fix: \\' was being interpreted incorrectly; \\ should escape \, but somehow \' was being escaped
fxt.tst_lines("$a = array('b\\\\\\'c', 'd');", fxt.line_assign("a", fxt.itm_ary().Subs_(fxt.itm_quote("b\\'c"), fxt.itm_quote("d"))));
}
@Test public void Ary_kv() {fxt.tst_lines("$a = array(k0 => 'v0', k1 => 'v1', k2 => 'v2');", fxt.line_assign("a", fxt.itm_ary().Subs_(fxt.itm_kv_quote("k0", "v0"), fxt.itm_kv_quote("k1", "v1"), fxt.itm_kv_quote("k2", "v2"))));}
@Test public void Brack_kv() {fxt.tst_lines("$a = [k0 => 'v0', k1 => 'v1', k2 => 'v2'];" , fxt.line_assign("a", fxt.itm_ary().Subs_(fxt.itm_kv_quote("k0", "v0"), fxt.itm_kv_quote("k1", "v1"), fxt.itm_kv_quote("k2", "v2"))));}
@Test public void Ary_kv_num() {fxt.tst_lines("$a = array(k0 => 0, k1 => 1);", fxt.line_assign("a", fxt.itm_ary().Subs_(fxt.itm_kv_int("k0", 0), fxt.itm_kv_int("k1", 1))));}
@Test public void Ary_kv_txt() {fxt.tst_lines("$a = array('k0' => a, 'k1' => b);", fxt.line_assign("a", fxt.itm_ary().Subs_(fxt.itm_kv_txt("k0", "a"), fxt.itm_kv_txt("k1", "b"))));}
@Test public void Ary_nest() {fxt.tst_lines("$a = array('b', array('c', 'd'), 'e');" , fxt.line_assign("a", fxt.itm_ary().Subs_(fxt.itm_quote("b"), fxt.itm_ary().Subs_(fxt.itm_quote("c"), fxt.itm_quote("d")), fxt.itm_quote("e"))));}
@Test public void Brack_nest() {fxt.tst_lines("$a = ['b', ['c', 'd'], 'e'];" , fxt.line_assign("a", fxt.itm_ary().Subs_(fxt.itm_quote("b"), fxt.itm_ary().Subs_(fxt.itm_quote("c"), fxt.itm_quote("d")), fxt.itm_quote("e"))));}
@Test public void Ary_nest_kv() {
@Test public void Ary_kv() {fxt.tst_lines("$a = array(k0 => 'v0', k1 => 'v1', k2 => 'v2');", fxt.line_assign("a", fxt.itm_ary().Subs_(fxt.itm_kv_quote("k0", "v0"), fxt.itm_kv_quote("k1", "v1"), fxt.itm_kv_quote("k2", "v2"))));}
@Test public void Brack_kv() {fxt.tst_lines("$a = [k0 => 'v0', k1 => 'v1', k2 => 'v2'];" , fxt.line_assign("a", fxt.itm_ary().Subs_(fxt.itm_kv_quote("k0", "v0"), fxt.itm_kv_quote("k1", "v1"), fxt.itm_kv_quote("k2", "v2"))));}
@Test public void Ary_kv_num() {fxt.tst_lines("$a = array(k0 => 0, k1 => 1);", fxt.line_assign("a", fxt.itm_ary().Subs_(fxt.itm_kv_int("k0", 0), fxt.itm_kv_int("k1", 1))));}
@Test public void Ary_kv_txt() {fxt.tst_lines("$a = array('k0' => a, 'k1' => b);", fxt.line_assign("a", fxt.itm_ary().Subs_(fxt.itm_kv_txt("k0", "a"), fxt.itm_kv_txt("k1", "b"))));}
@Test public void Ary_nest() {fxt.tst_lines("$a = array('b', array('c', 'd'), 'e');" , fxt.line_assign("a", fxt.itm_ary().Subs_(fxt.itm_quote("b"), fxt.itm_ary().Subs_(fxt.itm_quote("c"), fxt.itm_quote("d")), fxt.itm_quote("e"))));}
@Test public void Brack_nest() {fxt.tst_lines("$a = ['b', ['c', 'd'], 'e'];" , fxt.line_assign("a", fxt.itm_ary().Subs_(fxt.itm_quote("b"), fxt.itm_ary().Subs_(fxt.itm_quote("c"), fxt.itm_quote("d")), fxt.itm_quote("e"))));}
@Test public void Ary_nest_kv() {
fxt.tst_lines("$a = array('i00' => array('01', '02'), 'i10' => array('11', '12'), 'i20' => array('21', '22'));"
, fxt.line_assign
( "a"
@@ -69,7 +69,7 @@ public class Php_parser_tst {
, fxt.itm_kv_itm("i20", fxt.itm_ary().Subs_(fxt.itm_quote("21"), fxt.itm_quote("22")))
)));
}
@Test public void Brack_nest_kv() {
@Test public void Brack_nest_kv() {
fxt.tst_lines("$a = ['i00' => ['01', '02'], 'i10' => ['11', '12'], 'i20' => ['21', '22']];"
, fxt.line_assign
( "a"
@@ -79,7 +79,7 @@ public class Php_parser_tst {
, fxt.itm_kv_itm("i20", fxt.itm_ary().Subs_(fxt.itm_quote("21"), fxt.itm_quote("22")))
)));
}
@Test public void Quoted() {
@Test public void Quoted() {
fxt.Test__string__quotes("a\\\"z" , "a\"z");
fxt.Test__string__quotes("a\\\\z" , "a\\z");
fxt.Test__string__quotes("a\\u0008z" , "a\bz");

View File

@@ -1,18 +1,18 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.langs.phps; import gplx.*; import gplx.langs.*;
interface Php_srl_itm {
byte Tid();
@@ -34,7 +34,7 @@ abstract class Php_srl_itm_base implements Php_srl_itm {
public int Src_bgn() {return src_bgn;} private int src_bgn;
public int Src_end() {return src_end;} private int src_end;
public Object Val() {return val;} Object val;
@gplx.Virtual public void Xto_bfr(Bry_bfr bfr, int depth) {
public void Xto_bfr(Bry_bfr bfr, int depth) {
Php_srl_wtr.Indent(bfr, depth);
bfr.Add(Php_srl_itm_.Names[this.Tid()]).Add_byte(Byte_ascii.Colon);
bfr.Add_str_u8(Object_.Xto_str_strict_or_null_mark(this.Val())).Add_byte(Byte_ascii.Semic).Add_byte_nl();

View File

@@ -1,38 +1,38 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.langs.phps; import gplx.*; import gplx.langs.*;
import org.junit.*;
public class Php_srl_parser_tst {
Php_srl_parser_fxt fxt = new Php_srl_parser_fxt();
@Before public void init() {fxt.Clear();}
@Test public void Nil() {fxt.Test_parse("N;", fxt.itm_nil_());}
@Test public void Bool_y() {fxt.Test_parse("b:1;", fxt.itm_bool_y_());}
@Test public void Bool_n() {fxt.Test_parse("b:0;", fxt.itm_bool_n_());}
@Test public void Num_int() {fxt.Test_parse("i:123;", fxt.itm_int_(123));}
@Test public void Num_int_neg() {fxt.Test_parse("i:-123;", fxt.itm_int_(-123));}
@Test public void Num_double() {fxt.Test_parse("d:1.23;", fxt.itm_double_(1.23d));}
@Test public void Num_double_inf_pos(){fxt.Test_parse("d:INF;", fxt.itm_double_(Double_.Inf_pos));}
@Test public void Num_double_exp() {fxt.Test_parse("d:1.2e+2;", fxt.itm_double_(120));}
@Test public void Num_double_nan() {fxt.Test_parse("d:NAN;", fxt.itm_double_(Double_.NaN));}
@Test public void Str_len_3() {fxt.Test_parse("s:3:\"abc\";", fxt.itm_str_("abc"));}
@Test public void Str_len_4() {fxt.Test_parse("s:4:\"abcd\";", fxt.itm_str_("abcd"));}
@Test public void Str_len_0() {fxt.Test_parse("s:0:\"\";", fxt.itm_str_(""));}
@Test public void Ary_empty() {fxt.Test_parse("a:0:{}", fxt.itm_ary_());}
@Test public void Ary_flat_one() {fxt.Test_parse("a:1:{i:1;i:9;}", fxt.itm_ary_().Subs_add(fxt.itm_kvi_(1, fxt.itm_int_(9))));}
@Test public void Ary_flat_many() {
@Test public void Nil() {fxt.Test_parse("N;", fxt.itm_nil_());}
@Test public void Bool_y() {fxt.Test_parse("b:1;", fxt.itm_bool_y_());}
@Test public void Bool_n() {fxt.Test_parse("b:0;", fxt.itm_bool_n_());}
@Test public void Num_int() {fxt.Test_parse("i:123;", fxt.itm_int_(123));}
@Test public void Num_int_neg() {fxt.Test_parse("i:-123;", fxt.itm_int_(-123));}
@Test public void Num_double() {fxt.Test_parse("d:1.23;", fxt.itm_double_(1.23d));}
@Test public void Num_double_inf_pos(){fxt.Test_parse("d:INF;", fxt.itm_double_(Double_.Inf_pos));}
@Test public void Num_double_exp() {fxt.Test_parse("d:1.2e+2;", fxt.itm_double_(120));}
@Test public void Num_double_nan() {fxt.Test_parse("d:NAN;", fxt.itm_double_(Double_.NaN));}
@Test public void Str_len_3() {fxt.Test_parse("s:3:\"abc\";", fxt.itm_str_("abc"));}
@Test public void Str_len_4() {fxt.Test_parse("s:4:\"abcd\";", fxt.itm_str_("abcd"));}
@Test public void Str_len_0() {fxt.Test_parse("s:0:\"\";", fxt.itm_str_(""));}
@Test public void Ary_empty() {fxt.Test_parse("a:0:{}", fxt.itm_ary_());}
@Test public void Ary_flat_one() {fxt.Test_parse("a:1:{i:1;i:9;}", fxt.itm_ary_().Subs_add(fxt.itm_kvi_(1, fxt.itm_int_(9))));}
@Test public void Ary_flat_many() {
fxt.Test_parse(String_.Concat
( "a:3:{"
, "i:1;i:9;"
@@ -44,7 +44,7 @@ public class Php_srl_parser_tst {
, fxt.itm_kvi_(3, fxt.itm_int_(7))
));
}
@Test public void Ary_nest_one() {
@Test public void Ary_nest_one() {
fxt.Test_parse(String_.Concat
( "a:1:{"
, "i:1;"
@@ -60,7 +60,7 @@ public class Php_srl_parser_tst {
, fxt.itm_kvi_(2, fxt.itm_int_(8))
))));
}
@Test public void Ary_key_str() {
@Test public void Ary_key_str() {
fxt.Test_parse(String_.Concat
( "a:1:{"
, "s:3:\"abc\";"
@@ -69,10 +69,10 @@ public class Php_srl_parser_tst {
( fxt.itm_kvs_("abc", fxt.itm_int_(987))
));
}
@Test public void Func() {
@Test public void Func() {
fxt.Test_parse("O:42:\"Scribunto_LuaStandaloneInterpreterFunction\":1:{s:2:\"id\";i:123;}", fxt.itm_func_(123));
}
@Test public void Smoke() {
@Test public void Smoke() {
// fxt.Test_parse("a:2:{s:6:\"values\";a:1:{i:1;a:9:{s:21:\"makeProt"+"ectedEnvFuncs\";O:42:\"Scribunto_LuaStandaloneInterpreterFunction\":1:{s:2:\"id\";i:2;}s:3:\"log\";O:42:\"Scribunto_LuaStandaloneInterpreterFunction\":1:{s:2:\"id\";i:3;}s:14:\"clearLogBuffer\";O:42:\"Scribunto_LuaStandaloneInterpreterFunction\":1:{s:2:\"id\";i:4;}s:5:\"setup\";O:42:\"Scribunto_LuaStandaloneInterpreterFunction\":1:{s:2:\"id\";i:5;}s:5:\"clone\";O:42:\"Scribunto_LuaStandaloneInterpreterFunction\":1:{s:2:\"id\";i:6;}s:15:\"getCurrentFrame\";O:42:\"Scribunto_LuaStandaloneInterpreterFunction\":1:{s:2:\"id\";i:7;}s:13:\"executeModule\";O:42:\"Scribunto_LuaStandaloneInterpreterFunction\":1:{s:2:\"id\";i:8;}s:15:\"executeFunction\";O:42:\"Scribunto_LuaStandaloneInterpreterFunction\":1:{s:2:\"id\";i:9;}s:12:\"getLogBuffer\";O:42:\"Scribunto_LuaStandaloneInterpreterFunction\":1:{s:2:\"id\";i:10;}}}s:2:\"op\";s:6:\"return\";}");
}
}

View File

@@ -1,35 +1,35 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.langs.phps; import gplx.*; import gplx.langs.*;
import org.junit.*;
public class Php_text_itm_tst {
@Before public void init() {fxt.Clear();} private Php_text_itm_fxt fxt = new Php_text_itm_fxt();
@Test public void Q1_basic() {fxt.Init_q1().Test_parse("abcde" , "abcde");}
@Test public void Q1_apos() {fxt.Init_q1().Test_parse("a\\'b" , "a'b");}
@Test public void Q1_backslash() {fxt.Init_q1().Test_parse("a\\\\b" , "a\\b");}
@Test public void Q1_backslash_eos() {fxt.Init_q1().Test_parse("a\\" , "a\\");} // PURPOSE: allow single trailing backslash; DATE:2014-08-06
@Test public void Q1_noop() {fxt.Init_q1().Test_parse("a\\$\\nb" , "a\\$\\nb");}
@Test public void Q2_basic() {fxt.Init_q2().Test_parse("abcde" , "abcde");}
@Test public void Q2_quote() {fxt.Init_q2().Test_parse("a\\\"b" , "a\"b");}
@Test public void Q2_backslash() {fxt.Init_q2().Test_parse("a\\\\b" , "a\\b");}
@Test public void Q2_noop() {fxt.Init_q2().Test_parse("a\\%\\cb" , "a\\%\\cb");}
@Test public void Q2_ws() {fxt.Init_q2().Test_parse("a\\tb\\nc" , "a\tb\nc");}
@Test public void Q2_fmt() {fxt.Init_q2().Test_parse("a$1b$2c" , "a~{0}b~{1}c");}
@Test public void Q2_utf_pipe() {fxt.Init_q2().Test_parse("a\\u007Cd" , "a|d");}
@Test public void Q2_hex_nbsp() {fxt.Init_q2().Test_parse("a\\xc2\\xa0d" , "a\\u00c2\\u00a0d");}
@Test public void Q1_basic() {fxt.Init_q1().Test_parse("abcde" , "abcde");}
@Test public void Q1_apos() {fxt.Init_q1().Test_parse("a\\'b" , "a'b");}
@Test public void Q1_backslash() {fxt.Init_q1().Test_parse("a\\\\b" , "a\\b");}
@Test public void Q1_backslash_eos() {fxt.Init_q1().Test_parse("a\\" , "a\\");} // PURPOSE: allow single trailing backslash; DATE:2014-08-06
@Test public void Q1_noop() {fxt.Init_q1().Test_parse("a\\$\\nb" , "a\\$\\nb");}
@Test public void Q2_basic() {fxt.Init_q2().Test_parse("abcde" , "abcde");}
@Test public void Q2_quote() {fxt.Init_q2().Test_parse("a\\\"b" , "a\"b");}
@Test public void Q2_backslash() {fxt.Init_q2().Test_parse("a\\\\b" , "a\\b");}
@Test public void Q2_noop() {fxt.Init_q2().Test_parse("a\\%\\cb" , "a\\%\\cb");}
@Test public void Q2_ws() {fxt.Init_q2().Test_parse("a\\tb\\nc" , "a\tb\nc");}
@Test public void Q2_fmt() {fxt.Init_q2().Test_parse("a$1b$2c" , "a~{0}b~{1}c");}
@Test public void Q2_utf_pipe() {fxt.Init_q2().Test_parse("a\\u007Cd" , "a|d");}
@Test public void Q2_hex_nbsp() {fxt.Init_q2().Test_parse("a\\xc2\\xa0d" , "a\\u00c2\\u00a0d");}
}
class Php_text_itm_fxt {
private Php_text_itm_parser parser;

View File

@@ -1,23 +1,23 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.langs.regxs; import gplx.*; import gplx.langs.*;
import org.junit.*; import gplx.core.strings.*;
public class Gfo_pattern_tst {
@Before public void init() {fxt.Clear();} private Gfo_pattern_itm_fxt fxt = new Gfo_pattern_itm_fxt();
@Test public void Compile() {
@Test public void Compile() {
fxt.Test_Compile("a" , fxt.itm_text_("a"));
fxt.Test_Compile("*" , fxt.itm_wild_());
fxt.Test_Compile("a*" , fxt.itm_text_("a"), fxt.itm_wild_());
@@ -25,31 +25,31 @@ public class Gfo_pattern_tst {
fxt.Test_Compile("*ab*" , fxt.itm_wild_(), fxt.itm_text_("ab"), fxt.itm_wild_());
fxt.Test_Compile("" );
}
@Test public void Match() {
@Test public void Match() {
Gfo_pattern pattern = fxt.pattern_("abc");
fxt.Test_Match_y(pattern, "abc");
fxt.Test_Match_n(pattern, "ab", "a", "bc", "Abc", "");
}
@Test public void Match_all() {
@Test public void Match_all() {
Gfo_pattern pattern = fxt.pattern_("*");
fxt.Test_Match_y(pattern, "a", "abc", "");
}
@Test public void Match_bgn() {
@Test public void Match_bgn() {
Gfo_pattern pattern = fxt.pattern_("abc*");
fxt.Test_Match_y(pattern, "abc", "abcdef");
fxt.Test_Match_n(pattern, "abd", "aabc", "");
}
@Test public void Match_end() {
@Test public void Match_end() {
Gfo_pattern pattern = fxt.pattern_("*abc");
fxt.Test_Match_y(pattern, "abc", "xyzabc");
fxt.Test_Match_n(pattern, "abcd", "");
}
@Test public void Match_mid() {
@Test public void Match_mid() {
Gfo_pattern pattern = fxt.pattern_("a*c*e");
fxt.Test_Match_y(pattern, "ace", "abcde");
fxt.Test_Match_n(pattern, "abc", "");
}
@Test public void Bug_ctx() { // PURPOSE.fix: cb was true b/c ctx was not reset correctly
@Test public void Bug_ctx() { // PURPOSE.fix: cb was true b/c ctx was not reset correctly
Gfo_pattern pattern = fxt.pattern_("b*");
fxt.Test_Match_y(pattern, "bc");
fxt.Test_Match_n(pattern, "cb");

View File

@@ -1,28 +1,28 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.langs.xmls; import gplx.*; import gplx.langs.*;
import org.junit.*;
public class Gfo_xml_wtr_tst {
private final Gfo_xml_wtr_fxt fxt = new Gfo_xml_wtr_fxt();
@Before public void init() {}
@Test public void Root() {
@Test public void Root() {
fxt.Wtr().Nde_lhs("a").Nde_rhs();
fxt.Test_bld("<a>", "</a>");
}
@Test public void Nest() {
@Test public void Nest() {
fxt.Wtr()
.Nde_lhs("a")
. Nde_lhs("a_a")
@@ -40,7 +40,7 @@ public class Gfo_xml_wtr_tst {
, "</a>"
);
}
@Test public void Atrs() {
@Test public void Atrs() {
fxt.Wtr()
.Nde_lhs_bgn_itm("a")
.Atr_kv_str_a7("b", "b1")
@@ -49,7 +49,7 @@ public class Gfo_xml_wtr_tst {
;
fxt.Test_bld("<a b='b1'></a>");
}
@Test public void Atrs_escape() {
@Test public void Atrs_escape() {
fxt.Wtr()
.Nde_lhs_bgn_itm("a")
.Atr_kv_str_a7("b", "'\"<>&")
@@ -58,13 +58,13 @@ public class Gfo_xml_wtr_tst {
;
fxt.Test_bld("<a b='&apos;\"<>&'></a>");
}
@Test public void Nde_txt() {
@Test public void Nde_txt() {
fxt.Wtr()
.Nde_txt_str("a", "a123")
;
fxt.Test_bld("<a>a123</a>");
}
@Test public void Nde_txt_escape() {
@Test public void Nde_txt_escape() {
fxt.Wtr()
.Nde_txt_str("a", "'\"<>&x")
;

View File

@@ -1,23 +1,23 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.xowa; import gplx.*;
import org.junit.*; import gplx.core.tests.*;
public class Xoae_page__tst {
private final Xoae_page__fxt fxt = new Xoae_page__fxt();
@Test public void Ttl() {
@Test public void Ttl() {
fxt.Init__page("Abc");
fxt.Exec__ttl("Заглавная_страница");
fxt.Test__url("en.wikipedia.org/wiki/Заглавная_страница"); // fails if "%D0%97%D0%B0%D0%B3%D0%BB%D0%B0%D0%B2%D0%BD%D0%B0%D1%8F_%D1%81%D1%82%D1%80%D0%B0%D0%BD%D0%B8%D1%86%D0%B0"; DATE:2016-11-25

View File

@@ -1,37 +1,37 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.xowa.addons.apps.cfgs.mgrs.caches; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.apps.*; import gplx.xowa.addons.apps.cfgs.*; import gplx.xowa.addons.apps.cfgs.mgrs.*;
import org.junit.*; import gplx.core.tests.*; import gplx.dbs.*;
import gplx.xowa.addons.apps.cfgs.dbs.*; import gplx.xowa.addons.apps.cfgs.specials.maints.services.*;
public class Xocfg_cache_mgr__tst {
private final Xocfg_cache_mgr__fxt fxt = new Xocfg_cache_mgr__fxt();
@Before public void init() {fxt.Clear();}
@Test public void Get__wiki() {
@Test public void Get__wiki() {
fxt.Init__db_add("en.w", "key_1", "val_1");
fxt.Test__get("en.w", "key_1", "val_1");
fxt.Test__get("en.d", "key_1", "dflt");
}
@Test public void Get__app() {
@Test public void Get__app() {
String ctx = Xocfg_mgr.Ctx__app;
fxt.Init__db_add(ctx, "key_1", "val_1");
fxt.Test__get(ctx, "key_1", "val_1");
fxt.Test__get("en.w", "key_1", "val_1");
fxt.Test__get("en.d", "key_1", "val_1");
}
@Test public void Set__app() {
@Test public void Set__app() {
String ctx = Xocfg_mgr.Ctx__app;
fxt.Init__db_add(ctx, "key_1", "123");
fxt.Init__sub(ctx, "key_1", "key_1");

View File

@@ -1,24 +1,24 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.xowa.addons.apps.cfgs.specials.edits.objs; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.apps.*; import gplx.xowa.addons.apps.cfgs.*; import gplx.xowa.addons.apps.cfgs.specials.*; import gplx.xowa.addons.apps.cfgs.specials.edits.*;
import org.junit.*; import gplx.core.tests.*;
import gplx.xowa.addons.apps.cfgs.mgrs.types.*;
public class Xoedit_itm_html_tst {
private final Xoedit_itm_html_fxt fxt = new Xoedit_itm_html_fxt();
@Test public void Build_html__memo() {
@Test public void Build_html__memo() {
fxt.Type_("memo").Key_("key1").Name_("name1").Html_cls_("html_cls1").Html_atrs_("key1=val1");
// normal

View File

@@ -1,28 +1,28 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.xowa.addons.apps.cfgs.specials.maints.services; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.apps.*; import gplx.xowa.addons.apps.cfgs.*; import gplx.xowa.addons.apps.cfgs.specials.*; import gplx.xowa.addons.apps.cfgs.specials.maints.*;
import org.junit.*; import gplx.core.tests.*;
public class Xocfg_maint_parser__tst {
private final Xocfg_maint_parser__fxt fxt = new Xocfg_maint_parser__fxt();
@Test public void Parse_grp() {
@Test public void Parse_grp() {
fxt.Exec__parse("grp {id='123'; key='key_1'; owner='owner_1'; name='name_1'; help='help_1'}"
, fxt.Make__grp("owner_1", 123, "key_1", "name_1", "help_1")
);
}
@Test public void Parse_itm() {
@Test public void Parse_itm() {
fxt.Exec__parse("itm {id='123'; key='key_1'; owner='owner_1'; name='name_1'; help='help_1'; scope='scope_1'; type='type_1'; dflt='dflt_1'; html_atrs='html_atrs_1'; html_cls='html_cls_1'}"
, fxt.Make__itm("owner_1", 123, "key_1", "name_1", "help_1", "scope_1", "type_1", "dflt_1", "html_atrs_1", "html_cls_1")
);

View File

@@ -1,48 +1,48 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.xowa.addons.apps.cfgs.upgrades; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.apps.*; import gplx.xowa.addons.apps.cfgs.*;
import org.junit.*; import gplx.core.tests.*;
public class Xocfg_upgrade_mgr__tst {
private final Xocfg_upgrade_mgr__fxt fxt = new Xocfg_upgrade_mgr__fxt();
@Test public void Parse__one() {
@Test public void Parse__one() {
fxt.Test__parse("app.cfgs.get('k_1', 'app').val = 'v_1';\n", Keyval_.new_("k_1", "v_1"));
}
@Test public void Parse__apos() {
@Test public void Parse__apos() {
fxt.Test__parse("app.cfgs.get('k_1(''k_1a'')', 'app').val = 'v_1';\n", Keyval_.new_("k_1('k_1a')", "v_1"));
}
@Test public void Parse__many() {
@Test public void Parse__many() {
fxt.Test__parse
( "app.cfgs.get('k_1', 'app').val = 'v_1';\n"
+ "app.cfgs.get('k_2', 'app').val = 'v_2';\n"
, Keyval_.new_("k_1", "v_1"), Keyval_.new_("k_2", "v_2"));
}
@Test public void Parse__multi_line() {
@Test public void Parse__multi_line() {
fxt.Test__parse
( "app.cfgs.get('k_1', 'app').val = '''v_1'';\n"
+ "v_2\n"
+ "v_3';\n"
, Keyval_.new_("k_1", "'v_1';\nv_2\nv_3"));
}
@Test public void Parse__io_cmd() {
@Test public void Parse__io_cmd() {
fxt.Test__parse
( "app.cfgs.get('a.cmd', 'app').val = 'cmd_1';\n"
+ "app.cfgs.get('a.args', 'app').val = 'args_1';\n"
, Keyval_.new_("a.cmd", "cmd_1|args_1"));
}
@Test public void Parse__gui_binding() {
@Test public void Parse__gui_binding() {
fxt.Test__parse
( "app.cfgs.get('app.cfg.get.gui.bnds.init(''xowa.app.exit-1'').src', 'app').val = 'box=''browser'';ipt=''key.none'';';\n"
, Keyval_.new_("xowa.gui.shortcuts.xowa.app.exit-1", "browser|key.none"));

View File

@@ -1,18 +1,18 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.xowa.addons.apps.scripts.apis; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.apps.*; import gplx.xowa.addons.apps.scripts.*;
import org.junit.*; import gplx.core.tests.*;
public class Xoscript_doc_head__tst {
@@ -23,22 +23,22 @@ public class Xoscript_doc_head__tst {
fxt.Exec__reg_marker("<!--bot-->", "bot");
fxt.Exec__doc__html("a<!--top-->b<!--bot-->c");
}
@Test public void Add_html() {
@Test public void Add_html() {
fxt.Exec__add_html("top", "<b>add_1</b>");
fxt.Exec__add_html("top", "<b>add_2</b>");
fxt.Test__html("a<b>add_1</b><b>add_2</b><!--top-->b<!--bot-->c");
}
@Test public void Add_html__default() {
@Test public void Add_html__default() {
fxt.Exec__add_html("<b>add_1</b>");
fxt.Test__html("a<b>add_1</b><!--top-->b<!--bot-->c");
}
@Test public void Add_tag() {
@Test public void Add_tag() {
fxt.Exec__add_tag("top", "div", "div_body", "k0", "v0", "k1", "v1");
fxt.Test__html
( "a<div k0=\"v0\" k1=\"v1\">div_body</div>"
, "<!--top-->b<!--bot-->c");
}
@Test public void Add_js_file() {
@Test public void Add_js_file() {
fxt.Exec__add_js_file("top", "./a.js");
fxt.Test__html
( "a<script src=\"file:///mem/wiki/test_wiki/bin/script/a.js\" type=\"text/javascript\"></script>"

View File

@@ -1,21 +1,34 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.xowa.addons.apps.updates.js; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.apps.*; import gplx.xowa.addons.apps.updates.*;
import gplx.core.gfobjs.*; import gplx.core.progs.*; import gplx.core.progs.rates.*;
import gplx.xowa.guis.cbks.*;
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.xowa.addons.apps.updates.js; import gplx.Err_;
import gplx.GfoMsg;
import gplx.GfoMsg_;
import gplx.Gfo_invk;
import gplx.Gfo_invk_;
import gplx.Gfo_invk_cmd;
import gplx.Gfo_usr_dlg_;
import gplx.GfsCtx;
import gplx.Math_;
import gplx.String_;
import gplx.core.gfobjs.Gfobj_nde;
import gplx.core.progs.Gfo_prog_ui;
import gplx.core.progs.Gfo_prog_ui_;
import gplx.core.progs.rates.Gfo_rate_list;
import gplx.xowa.guis.cbks.Xog_cbk_mgr;
import gplx.xowa.guis.cbks.Xog_cbk_trg;
public class Xojs_wkr__base implements Gfo_prog_ui, Gfo_invk {
private final Gfo_invk_cmd done_cbk;
private final Gfo_invk_cmd fail_cbk;
@@ -46,7 +59,7 @@ public class Xojs_wkr__base implements Gfo_prog_ui, Gfo_invk {
fail_cbk.Exec();
}
}
@gplx.Virtual protected void Exec_run() {}
protected void Exec_run() {}
public void Exec_async(String thread_name) {
gplx.core.threads.Thread_adp_.Start_by_key(thread_name + ".download", this, Invk__exec);
}

View File

@@ -1,18 +1,18 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.xowa.addons.apps.updates.specials; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.apps.*; import gplx.xowa.addons.apps.updates.*;
import gplx.langs.mustaches.*;
import gplx.xowa.addons.apps.updates.dbs.*;
@@ -27,7 +27,7 @@ class Xoa_update_itm__leaf implements Mustache_doc_itm {
this.details = details;
this.package_url = package_url;
}
@gplx.Virtual public boolean Mustache__write(String k, Mustache_bfr bfr) {
public boolean Mustache__write(String k, Mustache_bfr bfr) {
if (String_.Eq(k, "version")) bfr.Add_str_u8(version);
else if (String_.Eq(k, "date")) bfr.Add_str_u8(date);
else if (String_.Eq(k, "priority")) bfr.Add_str_u8(Xoa_app_version_itm.Priority__to_name(priority));
@@ -36,7 +36,7 @@ class Xoa_update_itm__leaf implements Mustache_doc_itm {
else if (String_.Eq(k, "package_url")) bfr.Add_str_u8(package_url);
return true;
}
@gplx.Virtual public Mustache_doc_itm[] Mustache__subs(String key) {
public Mustache_doc_itm[] Mustache__subs(String key) {
if (String_.Eq(key, "priority_is_major")) return Mustache_doc_itm_.Ary__bool(priority >= Xoa_app_version_itm.Priority__major);
return Mustache_doc_itm_.Ary__empty;
}

View File

@@ -1,24 +1,24 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.xowa.addons.bldrs.app_cfgs; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*;
import org.junit.*; import gplx.core.strings.*;
public class Xob_wiki_cfg_bldr_tst {
Xob_wiki_cfg_bldr_fxt fxt = new Xob_wiki_cfg_bldr_fxt();
@Before public void init() {fxt.Clear();}
@Test public void Exec() {
@Test public void Exec() {
fxt .Init_cmd("en.wikipedia.org", "key0", "en.val0")
.Init_cmd("en.wikipedia.org", "key1", "en.val1")
.Init_cmd("fr.wikipedia.org", "key0", "fr.val0")
@@ -55,7 +55,7 @@ public class Xob_wiki_cfg_bldr_tst {
, "// key2.end"
));
}
// @Test public void Lang_names_run() {
// @Test public void Lang_names_run() {
// Io_url dir = Io_url_.new_dir_("/var/www/mediawiki/languages/messages/");
// Io_url[] fils = Io_mgr.Instance.QueryDir_args(dir).ExecAsUrlAry();
// int fils_len = fils.length;
@@ -89,7 +89,7 @@ public class Xob_wiki_cfg_bldr_tst {
// }
// Tfds.Dbg(sb.To_str_and_clear());
// }
@Test public void Ns_aliases() {
@Test public void Ns_aliases() {
Io_mgr.Instance.InitEngine_mem();
Io_mgr.Instance.SaveFilStr("mem/en.wikipedia.org/w/api.php?action=query&format=xml&meta=siteinfo&siprop=namespacealiases", String_.Concat_lines_nl
( "<api>"

View File

@@ -1,23 +1,39 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.xowa.addons.bldrs.app_cfgs.wm_server_cfgs; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*; import gplx.xowa.addons.bldrs.app_cfgs.*;
import gplx.core.ios.*;
import gplx.xowa.bldrs.*; import gplx.xowa.bldrs.wkrs.*;
import gplx.langs.phps.*;
import gplx.xowa.wikis.domains.*;
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.xowa.addons.bldrs.app_cfgs.wm_server_cfgs; import gplx.Bry_;
import gplx.Bry_bfr;
import gplx.Bry_bfr_;
import gplx.Bry_find_;
import gplx.Byte_ascii;
import gplx.DateAdp;
import gplx.Datetime_now;
import gplx.Err_;
import gplx.Io_mgr;
import gplx.Io_url;
import gplx.core.ios.IoItmFil;
import gplx.langs.phps.Php_evaluator;
import gplx.langs.phps.Php_itm_ary;
import gplx.langs.phps.Php_itm_kv;
import gplx.langs.phps.Php_line;
import gplx.langs.phps.Php_line_assign;
import gplx.langs.phps.Php_parser;
import gplx.xowa.Xoa_app;
import gplx.xowa.wikis.domains.Xow_abrv_wm_;
import gplx.xowa.wikis.domains.Xow_domain_itm;
import gplx.xowa.wikis.domains.Xow_domain_itm_;
public class Xowm_server_cfg_mgr {
public void Exec(Xoa_app app) {
// get local file
@@ -63,7 +79,7 @@ public class Xowm_server_cfg_mgr {
bfr.Add_str_u8_fmt("app.bldr.wiki_cfg_bldr.get('{0}').new_cmd_('wiki.ctgs.collations', \"catpage_mgr.collation_('{1}');\");\n", itm.Domain_bry(), collation);
} catch (Exception e) {throw Err_.new_("failed to parse line", "wiki", wiki_abrv, "collation", collation, "err", Err_.Message_lang(e));}
}
Tfds.Write(bfr.To_str_and_clear());
// Tfds.Write(bfr.To_str_and_clear());
}
private static void Assert_recent_or_download(Io_url trg, String src, int min) {
// get file

View File

@@ -1,18 +1,18 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.xowa.addons.bldrs.centrals.cmds; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*; import gplx.xowa.addons.bldrs.centrals.*;
import gplx.core.gfobjs.*; import gplx.core.progs.*; import gplx.core.progs.rates.*;
import gplx.xowa.apps.apis.*;
@@ -40,10 +40,10 @@ public abstract class Xobc_cmd__base implements Xobc_cmd_itm {
public int Cmd_id() {return cmd_id;} private final int cmd_id;
public abstract String Cmd_type();
public abstract String Cmd_name();
@gplx.Virtual public boolean Cmd_suspendable() {return false;}
public boolean Cmd_suspendable() {return false;}
public String Cmd_uid() {return cmd_uid;} private final String cmd_uid;
@gplx.Virtual public String Cmd_fallback() {return this.Cmd_type();}
@gplx.Virtual public void Cmd_clear() {// called when restarting failed task
public String Cmd_fallback() {return this.Cmd_type();}
public void Cmd_clear() {// called when restarting failed task
this.status = Gfo_prog_ui_.Status__init;
this.cmd_exec_err = null; // reset error
this.data_cur = 0; // reset progress else bad progress updates; DATE:2016-06-29
@@ -79,13 +79,13 @@ public abstract class Xobc_cmd__base implements Xobc_cmd_itm {
}
}
protected abstract void Cmd_exec_hook(Xobc_cmd_ctx ctx);
@gplx.Virtual protected boolean Cmd_fail_resumes() {return false;}
protected boolean Cmd_fail_resumes() {return false;}
protected void Cmd_exec_err_(String v) {
Gfo_log_.Instance.Warn("xobc_cmd task err", "task_id", task_id, "step_id", step_id, "cmd_id", cmd_id, "err", v);
this.status = Gfo_prog_ui_.Status__fail;
this.cmd_exec_err = v;
} private String cmd_exec_err;
@gplx.Virtual public void Cmd_cleanup() {}
public void Cmd_cleanup() {}
public Gfobj_nde Save_to(Gfobj_nde nde) {
nde.Add_int ("task_id" , task_id);
@@ -106,7 +106,7 @@ public abstract class Xobc_cmd__base implements Xobc_cmd_itm {
if (data_cur > 0)
this.Prog_status_(Gfo_prog_ui_.Status__suspended); // set status to suspended, else js won't warn about accidental removal
}
@gplx.Virtual protected long Load_checkpoint_hook() {return 0;}
protected long Load_checkpoint_hook() {return 0;}
public boolean Prog_notify_and_chk_if_suspended(long new_data_cur, long new_data_end) {
if (status == Gfo_prog_ui_.Status__suspended) return true; // task paused by ui; exit now;

View File

@@ -1,26 +1,26 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.xowa.addons.bldrs.exports.packs.files; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*; import gplx.xowa.addons.bldrs.exports.*; import gplx.xowa.addons.bldrs.exports.packs.*;
import org.junit.*; import gplx.core.tests.*;
public class Pack_zip_name_bldr__tst {
private Pack_zip_name_bldr__fxt fxt = new Pack_zip_name_bldr__fxt();
@Test public void Basic() {
@Test public void Basic() {
fxt.Test__to_wiki_url("mem/wiki/en.wikipedia.org/", "mem/wiki/en.wikipedia.org/tmp/Xowa_enwiki_2016-09_file_deletion_2016.09/", "mem/wiki/en.wikipedia.org/en.wikipedia.org-file-deletion-2016.09.xowa");
}
@Test public void Bld_by_suffix() {
@Test public void Bld_by_suffix() {
Pack_zip_name_bldr bldr = fxt.Make__bldr("mem/wiki/en.wikipedia.org/tmp/pack/", "en.wikipedia.org", "enwiki", "2017-03", null);
fxt.Test__bld_by_suffix(bldr, "xtn.fulltext_search", 1, "mem/wiki/en.wikipedia.org/tmp/pack/Xowa_enwiki_2017-03_xtn.fulltext_search.002.zip");
}

View File

@@ -1,27 +1,27 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.xowa.addons.bldrs.files.cmds; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*; import gplx.xowa.addons.bldrs.files.*;
import org.junit.*; import gplx.core.ios.*; import gplx.xowa.files.*;
public class Xobldr__image__create_tst {
private Xobldr__image__create_fxt fxt = new Xobldr__image__create_fxt();
@Test public void Basic() {fxt.Init_("A.png" , Xof_media_type.Name_bitmap , Xof_ext_.Bry_png, 220, 110) .Test(Xof_ext_.Id_png);} // A.png -> png
@Test public void Ogg_VIDEO() {fxt.Init_("A.ogg" , Xof_media_type.Name_video , Xof_ext_.Bry_ogg, 220, 110) .Test(Xof_ext_.Id_ogv);} // A.ogg and VIDEO -> ogv
@Test public void Ogg_VIDEO_null_size() {fxt.Init_("A.ogg" , Xof_media_type.Name_video , Xof_ext_.Bry_ogg, 0, 0) .Test(Xof_ext_.Id_ogg);} // A.ogg but 0,0 -> ogg (not ogv)
@Test public void Png_is_jpg() {fxt.Init_("A.png" , Xof_media_type.Name_bitmap , Xof_ext_.Bry_jpg, 220, 110) .Test(Xof_ext_.Id_jpg);} // A.png and jpg -> jpg
@Test public void Jpeg_is_jpeg() {fxt.Init_("A.jpeg" , Xof_media_type.Name_bitmap , Xof_ext_.Bry_jpg, 220, 110) .Test(Xof_ext_.Id_jpeg);} // A.jpeg and jpg -> jpeg (unchanged)
@Test public void Basic() {fxt.Init_("A.png" , Xof_media_type.Name_bitmap , Xof_ext_.Bry_png, 220, 110) .Test(Xof_ext_.Id_png);} // A.png -> png
@Test public void Ogg_VIDEO() {fxt.Init_("A.ogg" , Xof_media_type.Name_video , Xof_ext_.Bry_ogg, 220, 110) .Test(Xof_ext_.Id_ogv);} // A.ogg and VIDEO -> ogv
@Test public void Ogg_VIDEO_null_size() {fxt.Init_("A.ogg" , Xof_media_type.Name_video , Xof_ext_.Bry_ogg, 0, 0) .Test(Xof_ext_.Id_ogg);} // A.ogg but 0,0 -> ogg (not ogv)
@Test public void Png_is_jpg() {fxt.Init_("A.png" , Xof_media_type.Name_bitmap , Xof_ext_.Bry_jpg, 220, 110) .Test(Xof_ext_.Id_jpg);} // A.png and jpg -> jpg
@Test public void Jpeg_is_jpeg() {fxt.Init_("A.jpeg" , Xof_media_type.Name_bitmap , Xof_ext_.Bry_jpg, 220, 110) .Test(Xof_ext_.Id_jpeg);} // A.jpeg and jpg -> jpeg (unchanged)
}
class Xobldr__image__create_fxt {
private byte[] name, media_type, minor_mime; int w, h;

View File

@@ -1,23 +1,23 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.xowa.addons.bldrs.files.cmds; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*; import gplx.xowa.addons.bldrs.files.*;
import org.junit.*;
public class Xobldr__lnki_temp__create__tst {
private Xobldr__lnki_temp__create__fxt fxt = new Xobldr__lnki_temp__create__fxt();
@Test public void Xto_commons() {
@Test public void Xto_commons() {
fxt.Init__to_commons(true);
fxt.Test__to_commons("a", "A");
fxt.Test__to_commons("A", null);

View File

@@ -1,30 +1,30 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.xowa.addons.bldrs.files.missing_origs.apis; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*; import gplx.xowa.addons.bldrs.files.*; import gplx.xowa.addons.bldrs.files.missing_origs.*;
import org.junit.*; import gplx.core.tests.*;
public class Xowmf_imageinfo_item__tst {
private final Xowmf_imageinfo_item__fxt fxt = new Xowmf_imageinfo_item__fxt();
@Test public void Normalize_ttl() {
@Test public void Normalize_ttl() {
fxt.Test__Normalize_ttl("File:A b.png", "A_b.png");
}
@Test public void Normalize_minor_mime() {
@Test public void Normalize_minor_mime() {
fxt.Test__Normalize_minor_mime("image/svg+xml", "svg+xml");
}
@Test public void Normalize_timestamp() {
@Test public void Normalize_timestamp() {
fxt.Test__Normalize_timestamp("2017-03-06T08:09:10Z", "20170306080910");
}
}

View File

@@ -1,18 +1,18 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.xowa.addons.bldrs.files.utls; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*; import gplx.xowa.addons.bldrs.files.*;
import org.junit.*;
import gplx.core.gfo_ndes.*;
@@ -22,27 +22,27 @@ import gplx.xowa.addons.bldrs.files.dbs.*;
public class Xob_xfer_temp_itm_tst {
private Xob_xfer_temp_itm_fxt fxt = new Xob_xfer_temp_itm_fxt();
@Before public void init() {fxt.Reset();}
@Test public void Pass() {fxt.Test_pass().Test_itm_chk_fail_id_none();}
@Test public void Missing_orig() {fxt.Test_fail(Xob_xfer_temp_itm.Chk_tid_orig_page_id_is_null , Keyval_.new_(Xob_orig_regy_tbl.Fld_orig_page_id, null));}
@Test public void File_is_audio() {fxt.Test_fail(Xob_xfer_temp_itm.Chk_tid_orig_media_type_is_audio , Keyval_.new_(Xob_orig_regy_tbl.Fld_orig_media_type, Xof_media_type.Name_audio));}
@Test public void File_is_mid() {
@Test public void Pass() {fxt.Test_pass().Test_itm_chk_fail_id_none();}
@Test public void Missing_orig() {fxt.Test_fail(Xob_xfer_temp_itm.Chk_tid_orig_page_id_is_null , Keyval_.new_(Xob_orig_regy_tbl.Fld_orig_page_id, null));}
@Test public void File_is_audio() {fxt.Test_fail(Xob_xfer_temp_itm.Chk_tid_orig_media_type_is_audio , Keyval_.new_(Xob_orig_regy_tbl.Fld_orig_media_type, Xof_media_type.Name_audio));}
@Test public void File_is_mid() {
fxt.Test_fail(Xob_xfer_temp_itm.Chk_tid_orig_media_type_is_audio , Keyval_.new_(Xob_orig_regy_tbl.Fld_orig_file_ext, Xof_ext_.Id_mid));
}
@Test public void Redirect_src_is_empty() { // orig_cmd sets all direct files to have "orig_join" == "lnki_ttl"
@Test public void Redirect_src_is_empty() { // orig_cmd sets all direct files to have "orig_join" == "lnki_ttl"
fxt.Test_bgn
( Keyval_.new_(Xob_orig_regy_tbl.Fld_orig_file_ttl , "A.png")
, Keyval_.new_(Xob_orig_regy_tbl.Fld_lnki_ttl , "A.png")
);
fxt.Test_lnki_redirect_src(""); // confirm redirect_src set to ""
}
@Test public void Redirect_src_has_val() { // orig_cmd sets all redirect files to have "orig_join" = redirect and "lnki_ttl" as orig; EX: A.png redirects to B.png; orig_join will be B.png (the actual image) and redirect_src will be A.png (the original lnki)
@Test public void Redirect_src_has_val() { // orig_cmd sets all redirect files to have "orig_join" = redirect and "lnki_ttl" as orig; EX: A.png redirects to B.png; orig_join will be B.png (the actual image) and redirect_src will be A.png (the original lnki)
fxt.Test_bgn
( Keyval_.new_(Xob_orig_regy_tbl.Fld_orig_file_ttl , "B.png")
, Keyval_.new_(Xob_orig_regy_tbl.Fld_lnki_ttl , "A.png")
);
fxt.Test_lnki_redirect_src("A.png"); // confirm redirect_src set to ""
}
@Test public void Redirect_should_take_trg_ext() {// if "A.png" redirects to "B.jpg", ext_id should be ".jpg" (the actual file) not ".png (lnki_ext_id)
@Test public void Redirect_should_take_trg_ext() {// if "A.png" redirects to "B.jpg", ext_id should be ".jpg" (the actual file) not ".png (lnki_ext_id)
fxt.Test_bgn
( Keyval_.new_(Xob_orig_regy_tbl.Fld_orig_file_ttl , "B.jpg")
, Keyval_.new_(Xob_orig_regy_tbl.Fld_lnki_ttl , "A.png")
@@ -50,7 +50,7 @@ public class Xob_xfer_temp_itm_tst {
);
fxt.Test_lnki_ext_id(Xof_ext_.Id_jpg); // confirm ext changed to .jpg
}
@Test public void Thumbtime_check() {// PURPOSE: one image actually had a thumbtime defined; EX: General_Dynamics_F-16_Fighting_Falcon; [[File:Crash.arp.600pix.jpg|thumb|thumbtime=2]]
@Test public void Thumbtime_check() {// PURPOSE: one image actually had a thumbtime defined; EX: General_Dynamics_F-16_Fighting_Falcon; [[File:Crash.arp.600pix.jpg|thumb|thumbtime=2]]
fxt.Test_bgn
( Keyval_.new_(Xob_orig_regy_tbl.Fld_orig_file_ext , Xof_ext_.Id_jpg)
, Keyval_.new_(Xob_lnki_regy_tbl.Fld_lnki_time , (double)3)
@@ -62,7 +62,7 @@ public class Xob_xfer_temp_itm_tst {
);
fxt.Test_lnki_thumbtime(3);
}
@Test public void Page_check() {
@Test public void Page_check() {
fxt.Test_bgn
( Keyval_.new_(Xob_orig_regy_tbl.Fld_orig_file_ext , Xof_ext_.Id_jpg)
, Keyval_.new_(Xob_lnki_regy_tbl.Fld_lnki_page , 3)
@@ -79,14 +79,14 @@ public class Xob_xfer_temp_itm_tst {
);
fxt.Test_lnki_page(3);
}
@Test public void Media_should_be_ignored() {// ignore [[Media:]] for xfer_thumb (needed for xfer_orig)
@Test public void Media_should_be_ignored() {// ignore [[Media:]] for xfer_thumb (needed for xfer_orig)
fxt.Test_bgn
( Keyval_.new_(Xob_orig_regy_tbl.Fld_lnki_ttl , "A.png")
, Keyval_.new_(Xob_lnki_regy_tbl.Fld_lnki_src_tid , Xop_file_logger_.Tid__media)
);
fxt.Test_itm_chk_fail_id(Xob_xfer_temp_itm.Chk_tid_ns_is_media);
}
@Test public void Orig_width_is_0() {// PURPOSE: ignore files with an orig width of 0; note that ogg files that are sometimes flagged as VIDEO; EX:2009_10_08_Marc_Randazza_interview.ogg; DATE:2014-08-20
@Test public void Orig_width_is_0() {// PURPOSE: ignore files with an orig width of 0; note that ogg files that are sometimes flagged as VIDEO; EX:2009_10_08_Marc_Randazza_interview.ogg; DATE:2014-08-20
fxt.Test_bgn
( Keyval_.new_(Xob_orig_regy_tbl.Fld_lnki_ttl , "A.ogg")
, Keyval_.new_(Xob_orig_regy_tbl.Fld_orig_media_type , Xof_media_type.Name_video) // VIDEO

View File

@@ -1,18 +1,18 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.xowa.addons.bldrs.mass_parses.makes; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*; import gplx.xowa.addons.bldrs.mass_parses.*;
import gplx.dbs.*; import gplx.xowa.bldrs.*;
import gplx.xowa.addons.bldrs.mass_parses.dbs.*;
@@ -45,7 +45,7 @@ abstract class Xomp_make_merger__base implements Xomp_make_merger, gplx.core.lis
}
protected abstract Db_tbl Init__trg_tbl(Xob_db_file trg_db);
protected abstract String Init__src_fld__page_id();
@gplx.Virtual protected void Init__trg_bgn() {}
protected void Init__trg_bgn() {}
public int Merger__load(Xomp_mgr_db src_mgr_db, Xomp_wkr_db src_wkr_db, int uid_bgn, int uid_end) {
// build sql

View File

@@ -1,23 +1,23 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.xowa.addons.htmls.tocs; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.htmls.*;
import org.junit.*; import gplx.core.tests.*;
public class Xoh_toc_htmlr__basic__tst {
@Before public void init() {fxt.Clear();} private final Xoh_toc_htmlr__basic__fxt fxt = new Xoh_toc_htmlr__basic__fxt();
@Test public void D1_S0_S0() {
@Test public void D1_S0_S0() {
fxt.Init__add(2, "a");
fxt.Init__add(2, "b");
fxt.Init__add(2, "c");
@@ -32,7 +32,7 @@ public class Xoh_toc_htmlr__basic__tst {
, " </ul>"
);
}
@Test public void D1_D1_D1() {
@Test public void D1_D1_D1() {
fxt.Init__add(2, "a");
fxt.Init__add(3, "a_a");
fxt.Init__add(4, "a_a_a");
@@ -51,7 +51,7 @@ public class Xoh_toc_htmlr__basic__tst {
, " </ul>"
);
}
@Test public void D1_D1_S0_U1() {
@Test public void D1_D1_S0_U1() {
fxt.Init__add(2, "a");
fxt.Init__add(3, "a_a");
fxt.Init__add(3, "a_b");
@@ -71,7 +71,7 @@ public class Xoh_toc_htmlr__basic__tst {
, " </ul>"
);
}
@Test public void D1_D1_U1_D1() {
@Test public void D1_D1_U1_D1() {
fxt.Init__add(2, "a");
fxt.Init__add(3, "a_a");
fxt.Init__add(2, "b");
@@ -93,7 +93,7 @@ public class Xoh_toc_htmlr__basic__tst {
, " </ul>"
);
}
@Test public void D1_D1_D1_U2() {
@Test public void D1_D1_D1_U2() {
fxt.Init__add(2, "a");
fxt.Init__add(3, "a_a");
fxt.Init__add(4, "a_a_a");
@@ -115,7 +115,7 @@ public class Xoh_toc_htmlr__basic__tst {
, " </ul>"
);
}
@Test public void D1_D2_U1_D1() {
@Test public void D1_D2_U1_D1() {
fxt.Init__add(2, "a");
fxt.Init__add(4, "a_a_a_a");
fxt.Init__add(3, "a_a_a");
@@ -137,7 +137,7 @@ public class Xoh_toc_htmlr__basic__tst {
, " </ul>"
);
}
@Test public void Div() {
@Test public void Div() {
fxt.Init__init_page("Table of contents", false);
fxt.Init__add(2, "a");
fxt.Init__add(2, "b");

View File

@@ -1,45 +1,45 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.xowa.addons.htmls.tocs; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.htmls.*;
import org.junit.*; import gplx.core.tests.*;
public class Xoh_toc_wkr__lvl__basic__tst {
@Before public void init() {fxt.Clear();} private final Xoh_toc_wkr__lvl__fxt fxt = new Xoh_toc_wkr__lvl__fxt();
@Test public void D1_S0_S0() {
@Test public void D1_S0_S0() {
fxt.Test__calc(2, fxt.Make(1, 1, Int_ary_.New(1)));
fxt.Test__calc(2, fxt.Make(2, 1, Int_ary_.New(2)));
fxt.Test__calc(2, fxt.Make(3, 1, Int_ary_.New(3)));
}
@Test public void D1_D1_D1() {
@Test public void D1_D1_D1() {
fxt.Test__calc(2, fxt.Make(1, 1, Int_ary_.New(1)));
fxt.Test__calc(3, fxt.Make(2, 2, Int_ary_.New(1, 1)));
fxt.Test__calc(4, fxt.Make(3, 3, Int_ary_.New(1, 1, 1)));
}
@Test public void D1_D1_S0_U1() {
@Test public void D1_D1_S0_U1() {
fxt.Test__calc(2, fxt.Make(1, 1, Int_ary_.New(1)));
fxt.Test__calc(3, fxt.Make(2, 2, Int_ary_.New(1, 1)));
fxt.Test__calc(3, fxt.Make(3, 2, Int_ary_.New(1, 2)));
fxt.Test__calc(2, fxt.Make(4, 1, Int_ary_.New(2)));
}
@Test public void D1_D1_U1_D1() {
@Test public void D1_D1_U1_D1() {
fxt.Test__calc(2, fxt.Make(1, 1, Int_ary_.New(1)));
fxt.Test__calc(3, fxt.Make(2, 2, Int_ary_.New(1, 1)));
fxt.Test__calc(2, fxt.Make(3, 1, Int_ary_.New(2)));
fxt.Test__calc(3, fxt.Make(4, 2, Int_ary_.New(2, 1)));
}
@Test public void D1_D1_D1_U2() {
@Test public void D1_D1_D1_U2() {
fxt.Test__calc(2, fxt.Make(1, 1, Int_ary_.New(1)));
fxt.Test__calc(3, fxt.Make(2, 2, Int_ary_.New(1, 1)));
fxt.Test__calc(4, fxt.Make(3, 3, Int_ary_.New(1, 1, 1)));

View File

@@ -1,50 +1,50 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.xowa.addons.htmls.tocs; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.htmls.*;
import org.junit.*; import gplx.core.tests.*; import gplx.langs.htmls.*;
public class Xoh_toc_wkr__txt__basic__tst {
@Before public void init() {fxt.Clear();} private final Xoh_toc_wkr__txt__fxt fxt = new Xoh_toc_wkr__txt__fxt();
@Test public void Basic() {
@Test public void Basic() {
fxt.Test__both("a b c", "a_b_c", "a b c");
}
@Test public void Ws() {
@Test public void Ws() {
fxt.Test__both(" a b ", "a_b", "a b");
}
@Test public void Nl() {
@Test public void Nl() {
fxt.Test__both("\na b\n", "a_b", "a b");
}
@Test public void Empty() { // PAGE:s.w:Colac,_Victoria DATE:2016-07-17
@Test public void Empty() { // PAGE:s.w:Colac,_Victoria DATE:2016-07-17
fxt.Test__both("", "", "");
}
@Test public void Amp__ncr() {
@Test public void Amp__ncr() {
fxt.Test__both("&#91;a&#93;", "[a]", "&#91;a&#93;");// ISSUE#:462; DATE:2019-05-12
}
@Test public void Encode() {
@Test public void Encode() {
fxt.Test__both("a+b", "a+b", "a+b");// ISSUE#:462; DATE:2019-05-12
}
@Test public void Comment() {
@Test public void Comment() {
fxt.Test__text("a<!--b-->c", "ac");
}
@Test public void Remove_comment__one() {
@Test public void Remove_comment__one() {
fxt.Test__remove_comment("a<!--b-->c", "ac");
}
@Test public void Remove_comment__many() {
@Test public void Remove_comment__many() {
fxt.Test__remove_comment("1<!--2-->3<!--4-->5", "135");
}
@Test public void Remove_comment__dangling() {
@Test public void Remove_comment__dangling() {
fxt.Test__remove_comment("1<!--2-->3<!--4->5", "13");
}
}

View File

@@ -1,36 +1,36 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.xowa.addons.htmls.tocs; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.htmls.*;
import org.junit.*; import gplx.core.tests.*;
public class Xoh_toc_wkr__txt__dupe__tst {
@Before public void init() {fxt.Clear();} private final Xoh_toc_wkr__txt__fxt fxt = new Xoh_toc_wkr__txt__fxt();
@Test public void Basic() {
@Test public void Basic() {
fxt.Test__anch("a" , "a");
fxt.Test__anch("a" , "a_2");
}
@Test public void Case_insensitive() {
@Test public void Case_insensitive() {
fxt.Test__anch("a" , "a");
fxt.Test__anch("A" , "A_2");
}
@Test public void Autonumber_exists() { // PAGE:fr.w:Itanium; EX: Itanium,Itanium_2,Itanium
@Test public void Autonumber_exists() { // PAGE:fr.w:Itanium; EX: Itanium,Itanium_2,Itanium
fxt.Test__anch("a" , "a");
fxt.Test__anch("a_2" , "a_2");
fxt.Test__anch("a" , "a_3");
}
@Test public void Autonumber_exists_2() {
@Test public void Autonumber_exists_2() {
fxt.Test__anch("a_2" , "a_2");
fxt.Test__anch("a" , "a");
fxt.Test__anch("a" , "a_3");

View File

@@ -1,49 +1,49 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.xowa.addons.htmls.tocs; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.htmls.*;
import org.junit.*; import gplx.core.tests.*;
public class Xoh_toc_wkr__txt__xnde__tst {
@Before public void init() {fxt.Clear();} private final Xoh_toc_wkr__txt__fxt fxt = new Xoh_toc_wkr__txt__fxt();
@Test public void I() {fxt.Test__both("<i>a</i>" , "a", "<i>a</i>");}
@Test public void I__id() {fxt.Test__both("<i id='1'>a</i>" , "a", "<i>a</i>");}
@Test public void B() {fxt.Test__both("<b>a</b>" , "a", "<b>a</b>");}
@Test public void Sup() {fxt.Test__both("<sup>a</sup>" , "a", "<sup>a</sup>");}
@Test public void Sub() {fxt.Test__both("<sub>a</sub>" , "a", "<sub>a</sub>");}
@Test public void Bdi() {fxt.Test__both("<bdi>a</bdi>" , "a", "<bdi>a</bdi>");}
@Test public void Mark() {fxt.Test__both("<mark>a</mark>" , "a", "<mark>a</mark>");}
@Test public void Span() {fxt.Test__both("<span>a</span>" , "a", "a");}
@Test public void Span__id() {fxt.Test__both("<span id='1'>a</span>" , "a", "a");}
@Test public void Span__dir() {fxt.Test__both("<span dir=\"ltr\">a</span>" , "a", "<span dir=\"ltr\">a</span>");}
@Test public void Span__dir_id() {fxt.Test__both("<span id='1' dir=\"ltr\">a</span>" , "a", "<span dir=\"ltr\">a</span>");}
@Test public void Small() {fxt.Test__text("<small>a</small>" , "a");}
@Test public void A() {fxt.Test__both("<a href=\"/wiki/A\">b</a>" , "b");}
@Test public void A__nest() {fxt.Test__both("<a href=\"/wiki/A\">b<i>c</i>d</a>" , "bcd", "b<i>c</i>d");}
@Test public void Br() {fxt.Test__both("a<br/>b" , "ab");}
@Test public void Br__ws() {fxt.Test__both2("a<br/ >b", "ab");}
@Test public void Br__dangling() {fxt.Test__both("a<br>b" , "ab");}
@Test public void Wbr__dangling() {fxt.Test__both("a<wbr>b" , "ab");}
@Test public void H2() {fxt.Test__both("a<h2>b</h2>c" , "abc");} // NOTE: not a valid test; MW actually generates "ab" b/c of tidy; see corresponding edit test; DATE:2016-06-28
@Test public void Li() {fxt.Test__text("a<ul><li>b</li></ul>c" , "abc");}
@Test public void Table() {fxt.Test__text("a<table><tr><td>b</td></tr></table>c" , "abc");}
@Test public void Unknown__i() {fxt.Test__both("a<unknown>b<i>c</i>d</unknown>e" , "abcde", "a<unknown>b<i>c</i>d</unknown>e");} // NOTE: technically, anch should be href_encoded a<unknown>b<i>c</i>d</unknown>e b/c <unknown> is not a valid tag; compare with known tags like <li> / <table> which are just stripped
@Test public void Unknown__a() {fxt.Test__both("a<unknown>b<a>c</a>d</unknown>e" , "abcde", "a<unknown>bcd</unknown>e");}
// @Test public void Br_w_space() {
@Test public void I() {fxt.Test__both("<i>a</i>" , "a", "<i>a</i>");}
@Test public void I__id() {fxt.Test__both("<i id='1'>a</i>" , "a", "<i>a</i>");}
@Test public void B() {fxt.Test__both("<b>a</b>" , "a", "<b>a</b>");}
@Test public void Sup() {fxt.Test__both("<sup>a</sup>" , "a", "<sup>a</sup>");}
@Test public void Sub() {fxt.Test__both("<sub>a</sub>" , "a", "<sub>a</sub>");}
@Test public void Bdi() {fxt.Test__both("<bdi>a</bdi>" , "a", "<bdi>a</bdi>");}
@Test public void Mark() {fxt.Test__both("<mark>a</mark>" , "a", "<mark>a</mark>");}
@Test public void Span() {fxt.Test__both("<span>a</span>" , "a", "a");}
@Test public void Span__id() {fxt.Test__both("<span id='1'>a</span>" , "a", "a");}
@Test public void Span__dir() {fxt.Test__both("<span dir=\"ltr\">a</span>" , "a", "<span dir=\"ltr\">a</span>");}
@Test public void Span__dir_id() {fxt.Test__both("<span id='1' dir=\"ltr\">a</span>" , "a", "<span dir=\"ltr\">a</span>");}
@Test public void Small() {fxt.Test__text("<small>a</small>" , "a");}
@Test public void A() {fxt.Test__both("<a href=\"/wiki/A\">b</a>" , "b");}
@Test public void A__nest() {fxt.Test__both("<a href=\"/wiki/A\">b<i>c</i>d</a>" , "bcd", "b<i>c</i>d");}
@Test public void Br() {fxt.Test__both("a<br/>b" , "ab");}
@Test public void Br__ws() {fxt.Test__both2("a<br/ >b", "ab");}
@Test public void Br__dangling() {fxt.Test__both("a<br>b" , "ab");}
@Test public void Wbr__dangling() {fxt.Test__both("a<wbr>b" , "ab");}
@Test public void H2() {fxt.Test__both("a<h2>b</h2>c" , "abc");} // NOTE: not a valid test; MW actually generates "ab" b/c of tidy; see corresponding edit test; DATE:2016-06-28
@Test public void Li() {fxt.Test__text("a<ul><li>b</li></ul>c" , "abc");}
@Test public void Table() {fxt.Test__text("a<table><tr><td>b</td></tr></table>c" , "abc");}
@Test public void Unknown__i() {fxt.Test__both("a<unknown>b<i>c</i>d</unknown>e" , "abcde", "a<unknown>b<i>c</i>d</unknown>e");} // NOTE: technically, anch should be href_encoded a<unknown>b<i>c</i>d</unknown>e b/c <unknown> is not a valid tag; compare with known tags like <li> / <table> which are just stripped
@Test public void Unknown__a() {fxt.Test__both("a<unknown>b<a>c</a>d</unknown>e" , "abcde", "a<unknown>bcd</unknown>e");}
// @Test public void Br_w_space() {
// fxt.Test__remove_comment("1<!--2-->3<!--4->5", "13");
// }
@Test public void Fail() {
@Test public void Fail() {
String html = "<i><a href='b'>c</i></a>";
fxt.Init__tidy(html, "<i><a href='b'>c</a></i>");
fxt.Test__both(html, "c", "<i>c</i>");

View File

@@ -1,24 +1,24 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.xowa.addons.htmls.tocs; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.htmls.*;
import org.junit.*; import gplx.xowa.parsers.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.htmls.*;
import gplx.xowa.parsers.hdrs.*;
public class Xowe_hdr_bldr__tst {
@Before public void init() {fxt.Clear();} private final Xowe_hdr_bldr_fxt fxt = new Xowe_hdr_bldr_fxt();
@Test public void Basic() {
@Test public void Basic() {
fxt.Test_html_toc(String_.Concat_lines_nl_skip_last
( "==a=="
, "==b=="
@@ -38,7 +38,7 @@ public class Xowe_hdr_bldr__tst {
)
);
}
@Test public void Hier_down() {
@Test public void Hier_down() {
fxt.Test_html_toc(String_.Concat_lines_nl_skip_last
( "==a=="
, "===b==="
@@ -63,7 +63,7 @@ public class Xowe_hdr_bldr__tst {
, " </ul>"
));
}
@Test public void Hier_up() {
@Test public void Hier_up() {
fxt.Test_html_toc(String_.Concat_lines_nl_skip_last
( "==a=="
, "===b==="
@@ -84,7 +84,7 @@ public class Xowe_hdr_bldr__tst {
, " </ul>"
));
}
@Test public void Down_up() {
@Test public void Down_up() {
fxt.Test_html_toc(String_.Concat_lines_nl_skip_last
( "==a=="
, "===b==="
@@ -107,7 +107,7 @@ public class Xowe_hdr_bldr__tst {
, " </ul>"
));
}
@Test public void D1_D1_D1_U2() {
@Test public void D1_D1_D1_U2() {
fxt.Test_html_toc(String_.Concat_lines_nl_skip_last
( "==a=="
, "===b==="
@@ -130,7 +130,7 @@ public class Xowe_hdr_bldr__tst {
, " </ul>"
));
}
@Test public void Err() { // PURPOSE: models strange case wherein jumping down does not work
@Test public void Err() { // PURPOSE: models strange case wherein jumping down does not work
fxt.Test_html_toc(String_.Concat_lines_nl_skip_last
( "==a=="
, "====b===="
@@ -153,7 +153,7 @@ public class Xowe_hdr_bldr__tst {
, " </ul>"
));
}
@Test public void Repeat_name() {
@Test public void Repeat_name() {
fxt.Test_html_toc(String_.Concat_lines_nl_skip_last
( "==a=="
, "==a=="
@@ -172,7 +172,7 @@ public class Xowe_hdr_bldr__tst {
, " </ul>"
));
}
@Test public void Id__encode() {
@Test public void Id__encode() {
fxt.Test_html_toc(String_.Concat_lines_nl_skip_last
( "__FORCETOC__"
, "==a+b=="
@@ -183,7 +183,7 @@ public class Xowe_hdr_bldr__tst {
, " </ul>"
));
}
@Test public void Ws() {
@Test public void Ws() {
fxt.Test_html_all(String_.Concat_lines_nl_skip_last
( "__FORCETOC__"
, "== a b =="
@@ -198,7 +198,7 @@ public class Xowe_hdr_bldr__tst {
, "<h2><span class='mw-headline' id='a_b'> a b </span></h2>"
));
}
@Test public void Apos_italic() {
@Test public void Apos_italic() {
fxt.Test_html_all(String_.Concat_lines_nl_skip_last
( "__FORCETOC__"
, "==''a''=="
@@ -214,7 +214,7 @@ public class Xowe_hdr_bldr__tst {
, ""
));
}
@Test public void Xnde__italic() {
@Test public void Xnde__italic() {
fxt.Test_html_all(String_.Concat_lines_nl_skip_last
( "__FORCETOC__"
, "==<i>a</i>=="
@@ -229,7 +229,7 @@ public class Xowe_hdr_bldr__tst {
, "<h2><span class='mw-headline' id='a'><i>a</i></span></h2>"
));
}
@Test public void Xnde__small() {
@Test public void Xnde__small() {
fxt.Test_html_all(String_.Concat_lines_nl_skip_last
( "__FORCETOC__"
, "==<small>a</small>=="
@@ -244,7 +244,7 @@ public class Xowe_hdr_bldr__tst {
, "<h2><span class='mw-headline' id='a'><small>a</small></span></h2>"
));
}
@Test public void Xnde__li() {
@Test public void Xnde__li() {
fxt.Test_html_all(String_.Concat_lines_nl_skip_last
( "__FORCETOC__"
, "==a<ul><li>b</li></ul>c=="
@@ -259,7 +259,7 @@ public class Xowe_hdr_bldr__tst {
, "<h2><span class='mw-headline' id='abc'>a<ul><li>b</li></ul>c</span></h2>"
));
}
@Test public void Xnde__table() {
@Test public void Xnde__table() {
fxt.Test_html_all(String_.Concat_lines_nl_skip_last
( "__FORCETOC__"
, "==a<table><tr><td>b</td></tr></table>c=="
@@ -275,7 +275,7 @@ public class Xowe_hdr_bldr__tst {
));
}
// TOMBSTONE: on MW, shows up as 'href="#ab"; <span class="toctext">ab</span>; '; TIDY doing strange things; ignore for now; DATE:2016-06-28
//@Test public void Xnde__h2() {
//@Test public void Xnde__h2() {
// fxt.Test_html_all(String_.Concat_lines_nl_skip_last
// ( "__FORCETOC__"
// , "==a<h2>b</h2>c=="
@@ -290,7 +290,7 @@ public class Xowe_hdr_bldr__tst {
// , "<h2><span class='mw-headline' id='abc'>a<h2>b</h2>c</span></h2>"
// ));
//}
@Test public void Xnde__dangling() { // PURPOSE: do not render dangling xndes; EX: Casualties_of_the_Iraq_War; ===<small>Iraqi Health Ministry<small>===
@Test public void Xnde__dangling() { // PURPOSE: do not render dangling xndes; EX: Casualties_of_the_Iraq_War; ===<small>Iraqi Health Ministry<small>===
fxt.Test_html_all(String_.Concat_lines_nl_skip_last
( "__FORCETOC__"
, "==<small>a<small>=="
@@ -305,7 +305,7 @@ public class Xowe_hdr_bldr__tst {
, "<h2><span class='mw-headline' id='a'><small>a<small></small></small></span></h2>"
));
}
@Test public void Nest__xnde__small() {
@Test public void Nest__xnde__small() {
fxt.Test_html_all(String_.Concat_lines_nl_skip_last
( "__FORCETOC__"
, "==a <sup>b<small>c</small>d</sup> e=="
@@ -320,7 +320,7 @@ public class Xowe_hdr_bldr__tst {
, "<h2><span class='mw-headline' id='a_bcd_e'>a <sup>b<small>c</small>d</sup> e</span></h2>"
));
}
@Test public void Nest__lnki() {
@Test public void Nest__lnki() {
fxt.Test_html_all(String_.Concat_lines_nl_skip_last
( "__FORCETOC__"
, "==<small>[[a|b]]</small>=="
@@ -335,7 +335,7 @@ public class Xowe_hdr_bldr__tst {
, "<h2><span class='mw-headline' id='b'><small><a href=\"/wiki/A\">b</a></small></span></h2>"
));
}
@Test public void Nest__br() { // PURPOSE: do not render inline xndes; EX: Magnetic_resonance_imaging
@Test public void Nest__br() { // PURPOSE: do not render inline xndes; EX: Magnetic_resonance_imaging
fxt.Test_html_all(String_.Concat_lines_nl_skip_last
( "__FORCETOC__"
, "==a<span id=\"b\">b<br/></span>=="
@@ -350,7 +350,7 @@ public class Xowe_hdr_bldr__tst {
, "<h2><span class='mw-headline' id='ab'>a<span id='b'>b<br/></span></span></h2>"
));
}
@Test public void Lnki_link() {
@Test public void Lnki_link() {
fxt.Test_html_all(String_.Concat_lines_nl_skip_last
( "__FORCETOC__"
, "==[[a]]=="
@@ -365,7 +365,7 @@ public class Xowe_hdr_bldr__tst {
, "<h2><span class='mw-headline' id='a'><a href=\"/wiki/A\">a</a></span></h2>"
));
}
@Test public void Lnki_caption() {
@Test public void Lnki_caption() {
fxt.Test_html_all(String_.Concat_lines_nl_skip_last
( "__FORCETOC__"
, "==[[a|b]]=="
@@ -380,7 +380,7 @@ public class Xowe_hdr_bldr__tst {
, "<h2><span class='mw-headline' id='b'><a href=\"/wiki/A\">b</a></span></h2>"
));
}
@Test public void Lnki_caption_nest() {
@Test public void Lnki_caption_nest() {
fxt.Test_html_all(String_.Concat_lines_nl_skip_last
( "__FORCETOC__"
, "==[[a|b<i>c</i>d]]=="
@@ -395,7 +395,7 @@ public class Xowe_hdr_bldr__tst {
, "<h2><span class='mw-headline' id='bcd'><a href=\"/wiki/A\">b<i>c</i>d</a></span></h2>"
));
}
@Test public void Html_ncr() {
@Test public void Html_ncr() {
fxt.Test_html_all(String_.Concat_lines_nl_skip_last
( "__FORCETOC__"
, "==&#91;a&#93;=="
@@ -410,7 +410,7 @@ public class Xowe_hdr_bldr__tst {
, "<h2><span class='mw-headline' id='[a]'>&#91;a&#93;</span></h2>"// ISSUE#:462; DATE:2019-05-12
));
}
@Test public void Fix_large_before_small() { // PURPOSE.fix: "===a===\n===b===\n" followed by "==c==" causes improper formatting; DATE:2013-05-16
@Test public void Fix_large_before_small() { // PURPOSE.fix: "===a===\n===b===\n" followed by "==c==" causes improper formatting; DATE:2013-05-16
fxt.Test_html_toc(String_.Concat_lines_nl_skip_last
( "===a==="
, "===b==="
@@ -429,7 +429,7 @@ public class Xowe_hdr_bldr__tst {
, " </ul>"
));
}
@Test public void Fix_large_before_small_2() { // PURPOSE.fix: similar to above, but has h3 after h2; PAGE:https://en.wikipedia.org/wiki/Wikipedia:Articles_for_creation/2006-08-27 DATE:2014-06-09
@Test public void Fix_large_before_small_2() { // PURPOSE.fix: similar to above, but has h3 after h2; PAGE:https://en.wikipedia.org/wiki/Wikipedia:Articles_for_creation/2006-08-27 DATE:2014-06-09
fxt.Test_html_toc(String_.Concat_lines_nl_skip_last
( "===a_0==="
, "==b_0=="
@@ -450,7 +450,7 @@ public class Xowe_hdr_bldr__tst {
, " </ul>"
));
}
@Test public void Translate_and_comment() { // PURPOSE: <translate> is an xtn and parses its innerText separately; meanwhile, toc_mgr defaults to using the innerText to build toc; EX:Wikidata:Introduction; DATE:2013-07-16
@Test public void Translate_and_comment() { // PURPOSE: <translate> is an xtn and parses its innerText separately; meanwhile, toc_mgr defaults to using the innerText to build toc; EX:Wikidata:Introduction; DATE:2013-07-16
fxt.Test_html_toc(String_.Concat_lines_nl_skip_last
( "__FORCETOC__"
, "==<translate><!--b-->ac</translate>=="
@@ -461,7 +461,7 @@ public class Xowe_hdr_bldr__tst {
, " </ul>"
));
}
@Test public void Ref() { // PURPOSE: ref contents should not print in TOC; DATE:2013-07-23
@Test public void Ref() { // PURPOSE: ref contents should not print in TOC; DATE:2013-07-23
fxt.Test_html_all(String_.Concat_lines_nl_skip_last
( "__FORCETOC__"
, "==a<ref>b</ref>=="
@@ -476,7 +476,7 @@ public class Xowe_hdr_bldr__tst {
, "<h2><span class='mw-headline' id='a[1]'>a<sup id=\"cite_ref-0\" class=\"reference\"><a href=\"#cite_note-0\">[1]</a></sup></span></h2>"// ISSUE#:462; DATE:2019-05-12
));
}
@Test public void Category() { // PURPOSE: Category should not show in in TOC; DATE:2013-12-09
@Test public void Category() { // PURPOSE: Category should not show in in TOC; DATE:2013-12-09
fxt.Test_html_all(String_.Concat_lines_nl_skip_last
( "__FORCETOC__"
, "==A[[Category:B]]=="
@@ -491,7 +491,7 @@ public class Xowe_hdr_bldr__tst {
, "<h2><span class='mw-headline' id='A'>A</span></h2>"
));
}
@Test public void Category_literal() { // PURPOSE: literal Category should show in in TOC; EX: de.w:1234; DATE:2014-01-21
@Test public void Category_literal() { // PURPOSE: literal Category should show in in TOC; EX: de.w:1234; DATE:2014-01-21
fxt.Test_html_all(String_.Concat_lines_nl_skip_last
( "__FORCETOC__"
, "==A[[:Category:B]]=="
@@ -506,7 +506,7 @@ public class Xowe_hdr_bldr__tst {
, "<h2><span class='mw-headline' id='ACategory:B'>A<a href=\"/wiki/Category:B\">Category:B</a></span></h2>"
));
}
@Test public void File() { // PURPOSE: file should show in in TOC; EX: tr.w:D<>nya_Miraslari; DATE:2014-06-06
@Test public void File() { // PURPOSE: file should show in in TOC; EX: tr.w:D<>nya_Miraslari; DATE:2014-06-06
fxt.Test_html_all(String_.Concat_lines_nl_skip_last
( "__FORCETOC__"
, "==[[File:A.png]] b=="
@@ -521,7 +521,7 @@ public class Xowe_hdr_bldr__tst {
, "<h2><span class='mw-headline' id='b'><a href=\"/wiki/File:A.png\" class=\"image\" xowa_title=\"A.png\"><img id=\"xoimg_0\" alt=\"\" src=\"file:///mem/wiki/repo/trg/orig/7/0/A.png\" width=\"0\" height=\"0\" /></a> b</span></h2>"
));
}
@Test public void Lnki_invalid() { // PURPOSE: invalid lnki was causing null ref; DATE:2014-02-07
@Test public void Lnki_invalid() { // PURPOSE: invalid lnki was causing null ref; DATE:2014-02-07
fxt.Test_html_all(String_.Concat_lines_nl_skip_last
( "__FORCETOC__"
, "==[[]]=="
@@ -536,7 +536,7 @@ public class Xowe_hdr_bldr__tst {
, "<h2><span class='mw-headline' id='[[]]'>[[]]</span></h2>" // ISSUE#:462; DATE:2019-05-12
));
}
@Test public void File_in_tbl() { // PURPOSE: two issues (a) don't show file if in tbl; (b) if v2, file inside tbl fails; PAGE:en.w:Holmes County,_Mississippi; DATE:2014-06-22
@Test public void File_in_tbl() { // PURPOSE: two issues (a) don't show file if in tbl; (b) if v2, file inside tbl fails; PAGE:en.w:Holmes County,_Mississippi; DATE:2014-06-22
fxt.Test_html_frag(String_.Concat_lines_nl_skip_last
( "__FORCETOC__"
, "==a <table><tr><td>[[File:A.png]]b</td></tr></table> c=="

View File

@@ -1,23 +1,23 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.xowa.addons.wikis.ctgs.bldrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.wikis.*; import gplx.xowa.addons.wikis.ctgs.*;
import org.junit.*; import gplx.core.tests.*;
public class Xob_catlink_mgr__tst {
private final Xob_catlink_mgr__fxt fxt = new Xob_catlink_mgr__fxt();
@Test public void Parse_timestamp() {// fix bad parsing b/c of "YYYY" instead of "yyyy"; ISSUE#:664; DATE:2020-02-05
@Test public void Parse_timestamp() {// fix bad parsing b/c of "YYYY" instead of "yyyy"; ISSUE#:664; DATE:2020-02-05
fxt.Test__Parse_timestamp("2016-02-01 18:34:08", 1454351648); // fails if 1451241248
}
}

View File

@@ -1,35 +1,35 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.xowa.addons.wikis.ctgs.htmls.catpages; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.wikis.*; import gplx.xowa.addons.wikis.ctgs.*; import gplx.xowa.addons.wikis.ctgs.htmls.*;
import org.junit.*; import gplx.xowa.htmls.core.htmls.*; import gplx.core.intls.ucas.*;
import gplx.xowa.addons.wikis.ctgs.htmls.catpages.doms.*; import gplx.xowa.addons.wikis.ctgs.htmls.catpages.fmts.*;
public class Xoctg_catpage_mgr__basic__tst {
@Before public void init() {fxt.Clear();} private Xoctg_catpage_mgr_fxt fxt = new Xoctg_catpage_mgr_fxt();
@Test public void Page_itm() {
@Test public void Page_itm() {
fxt .Init_itms__pages("A1")
.Test__html__page(Xoa_ctg_mgr.Tid__page, Byte_ascii.Ltr_A, "\n <li><a href=\"/wiki/A1\" title=\"A1\">A1</a></li>");
}
@Test public void Page_itm_missing() {
@Test public void Page_itm_missing() {
fxt.Init_itms__pages("A1");
Xoctg_catpage_itm itm = fxt.Ctg().Grp_by_tid(Xoa_ctg_mgr.Tid__page).Itms__get_at(0);
itm.Page_ttl_(Xoa_ttl.Null);
itm.Sortkey_handle_make(Bry_bfr_.New(), fxt.Wiki(), Bry_.Empty);
fxt.Test__html__page(Xoa_ctg_mgr.Tid__page, Byte_ascii.Ltr_A, "\n <li class=\"xowa-missing-category-entry\"><span title=\"id not found: #0 might be talk/user page\">missing page (0)</li>");
}
@Test public void Visited_doesnt_work_for_space() {// PURPOSE: xowa-visited not inserted for pages with space
@Test public void Visited_doesnt_work_for_space() {// PURPOSE: xowa-visited not inserted for pages with space
byte[] page_bry = Bry_.new_a7("A 1");
Xoa_url url = Xoa_url.New(Bry_.new_a7("en.wikipedia.org"), page_bry);
Xoa_ttl ttl = Xoa_ttl.Parse(fxt.Wiki(), page_bry);
@@ -55,7 +55,7 @@ public class Xoctg_catpage_mgr__basic__tst {
, "</div>"
));
}
@Test public void Page_all() {
@Test public void Page_all() {
fxt .Init_itms__pages("A1")
.Test__html__all(Xoa_ctg_mgr.Tid__page, String_.Concat_lines_nl_skip_last
( ""
@@ -77,7 +77,7 @@ public class Xoctg_catpage_mgr__basic__tst {
, "</div>"
));
}
@Test public void File_all() {
@Test public void File_all() {
fxt .Init_itms__files("File:A1.png")
.Test__html__all(Xoa_ctg_mgr.Tid__file, String_.Concat_lines_nl_skip_last
( ""
@@ -99,7 +99,7 @@ public class Xoctg_catpage_mgr__basic__tst {
, "</div>"
));
}
@Test public void Subc_all() {
@Test public void Subc_all() {
fxt .Init_itms__subcs("Category:Subc_1")
.Test__html__all(Xoa_ctg_mgr.Tid__subc, String_.Concat_lines_nl_skip_last
( ""
@@ -135,7 +135,7 @@ public class Xoctg_catpage_mgr__basic__tst {
, "</div>"
));
}
@Test public void Page_all_cols() {
@Test public void Page_all_cols() {
fxt.Init_itms__pages("A1", "A2", "A3", "B1", "C1");
fxt.Init__grp_max_(6); // SEE:FOOTNOTE:LT_NOT_LTE DATE:2019-12-14
fxt.Test__html__all(Xoa_ctg_mgr.Tid__page, String_.Concat_lines_nl_skip_last
@@ -175,7 +175,7 @@ public class Xoctg_catpage_mgr__basic__tst {
, "</div>"
));
}
@Test public void Page__numeric() { // PURPOSE: check numeric sorting; 0, 2, 3, 10; not 0, 10, 2, 3; DATE:2016-10-09
@Test public void Page__numeric() { // PURPOSE: check numeric sorting; 0, 2, 3, 10; not 0, 10, 2, 3; DATE:2016-10-09
fxt.Init_itms__pages("0", "2", "3", "10");
fxt.Init__grp_max_(5); // SEE:FOOTNOTE:LT_NOT_LTE DATE:2019-12-14
fxt.Test__html__all(Xoa_ctg_mgr.Tid__page, String_.Concat_lines_nl_skip_last
@@ -211,7 +211,7 @@ public class Xoctg_catpage_mgr__basic__tst {
, "</div>"
));
}
@Test public void Title__escape_quotes() {// PURPOSE: quotes in title should be escaped; DATE:2015-12-28
@Test public void Title__escape_quotes() {// PURPOSE: quotes in title should be escaped; DATE:2015-12-28
fxt .Init_itms__pages("A\"1")
.Test__html__all(Xoa_ctg_mgr.Tid__page, String_.Concat_lines_nl_skip_last
( ""
@@ -233,7 +233,7 @@ public class Xoctg_catpage_mgr__basic__tst {
, "</div>"
));
}
@Test public void Mixed_case_titles() {// PURPOSE: titles in mixed-case should sort under same upper-case letter; ISSUE#:637 DATE:2019-12-14
@Test public void Mixed_case_titles() {// PURPOSE: titles in mixed-case should sort under same upper-case letter; ISSUE#:637 DATE:2019-12-14
// init main ns to be case-sensitive, so that "A1" and "a2" get sorted into different groups (fr.wikisource)
fxt.Wiki().Ns_mgr().Ns_main().Case_match_(gplx.xowa.wikis.nss.Xow_ns_case_.Tid__all);
@@ -266,7 +266,7 @@ public class Xoctg_catpage_mgr__basic__tst {
, "</div>"
));
}
@Test public void Calc_col_len() {
@Test public void Calc_col_len() {
fxt.Test__calc_col_len(10, 0, 4); // for 10 items, col 0 has 4 items
fxt.Test__calc_col_len(10, 1, 3); // for 10 items, col 1 has 3 items
fxt.Test__calc_col_len(10, 2, 3); // for 10 items, col 2 has 3 items

View File

@@ -1,24 +1,24 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.xowa.addons.wikis.ctgs.htmls.catpages; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.wikis.*; import gplx.xowa.addons.wikis.ctgs.*; import gplx.xowa.addons.wikis.ctgs.htmls.*;
import org.junit.*; import gplx.xowa.htmls.core.htmls.*;
import gplx.xowa.addons.wikis.ctgs.htmls.catpages.doms.*; import gplx.xowa.addons.wikis.ctgs.htmls.catpages.fmts.*;
public class Xoctg_catpage_mgr__navlink__tst {
@Before public void init() {fxt.Clear();} private Xoctg_catpage_mgr_fxt fxt = new Xoctg_catpage_mgr_fxt();
@Test public void Navlink__basic() {
@Test public void Navlink__basic() {
fxt.Init_itms__pages("A2", "A3", "A4");
fxt.Init__next_sortkey_(Xoa_ctg_mgr.Tid__page, "A5");
fxt.Test__navlink(Bool_.Y, "Category:Ctg_1", String_.Concat_lines_nl
@@ -27,7 +27,7 @@ public class Xoctg_catpage_mgr__navlink__tst {
, "(<a href=\"/wiki/Category:Ctg_1?pagefrom=A5#mw-pages\" class=\"xowa_nav\" title=\"Category:Ctg_1\">next 3</a>)"
));
}
@Test public void Navlink__encoded() { // escape quotes and spaces; DATE:2016-01-11
@Test public void Navlink__encoded() { // escape quotes and spaces; DATE:2016-01-11
fxt.Init_itms__pages("A\" 2", "A\" 3", "A\" 4");
fxt.Init__next_sortkey_(Xoa_ctg_mgr.Tid__page, "A\" 5");
fxt.Test__navlink(Bool_.Y, "Category:Ctg_1", String_.Concat_lines_nl
@@ -36,7 +36,7 @@ public class Xoctg_catpage_mgr__navlink__tst {
, "(<a href=\"/wiki/Category:Ctg_1?pagefrom=A%22+5#mw-pages\" class=\"xowa_nav\" title=\"Category:Ctg_1\">next 3</a>)"
));
}
@Test public void Navlink__bos() {
@Test public void Navlink__bos() {
fxt.Init_itms__pages("A2", "A3", "A4");
fxt.Init__prev_hide_y_(Xoa_ctg_mgr.Tid__page);
fxt.Init__next_sortkey_(Xoa_ctg_mgr.Tid__page, "A5");
@@ -46,7 +46,7 @@ public class Xoctg_catpage_mgr__navlink__tst {
, "(<a href=\"/wiki/Category:Ctg_1?pagefrom=A5#mw-pages\" class=\"xowa_nav\" title=\"Category:Ctg_1\">next 3</a>)"
));
}
@Test public void Navlink__eos() {
@Test public void Navlink__eos() {
fxt.Init_itms__pages("A2", "A3", "A4");
fxt.Test__navlink(Bool_.Y, "Category:Ctg_1", String_.Concat_lines_nl
( ""

View File

@@ -1,27 +1,27 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.xowa.addons.wikis.ctgs.htmls.catpages.dbs; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.wikis.*; import gplx.xowa.addons.wikis.ctgs.*; import gplx.xowa.addons.wikis.ctgs.htmls.*; import gplx.xowa.addons.wikis.ctgs.htmls.catpages.*;
import org.junit.*; import gplx.core.tests.*; import gplx.xowa.apps.urls.*;
import gplx.xowa.langs.*; import gplx.xowa.addons.wikis.ctgs.htmls.catpages.langs.*;
public class Xoctg_catlink_loader__tst {
private final Xoctg_catlink_loader__fxt fxt = new Xoctg_catlink_loader__fxt();
@Test public void Build_sortkey_val__v4() { // PURPOSE: remove "\n" and afterwards else will omit 1 record
@Test public void Build_sortkey_val__v4() { // PURPOSE: remove "\n" and afterwards else will omit 1 record
fxt.Test__build_sortkey_sql(4, "A\nA", "x'41'"); // fails if "x'410a41'"
}
@Test public void Build_sortkey_val__v2() { // PURPOSE: remove "\n" and afterwards else SQL will be malformed
@Test public void Build_sortkey_val__v2() { // PURPOSE: remove "\n" and afterwards else SQL will be malformed
fxt.Test__build_sortkey_sql(2, "A\nA", "'A'"); // fails if "'A\nA'"
}
}

View File

@@ -1,18 +1,18 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.xowa.addons.wikis.ctgs.htmls.catpages.fmts; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.wikis.*; import gplx.xowa.addons.wikis.ctgs.*; import gplx.xowa.addons.wikis.ctgs.htmls.*; import gplx.xowa.addons.wikis.ctgs.htmls.catpages.*;
import gplx.langs.htmls.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.hrefs.*; import gplx.xowa.htmls.core.wkrs.lnkis.htmls.*; import gplx.xowa.htmls.core.htmls.*;
import gplx.xowa.langs.*; import gplx.xowa.langs.msgs.*; import gplx.core.intls.ucas.*;
@@ -72,7 +72,7 @@ public abstract class Xoctg_fmt_itm_base implements gplx.core.brys.Bfr_arg {
loop_end_idx = grp_end;
loop_ends_at_col = true;
}
@gplx.Virtual public void Bld_html(Bry_bfr bfr, Xow_wiki wiki, Xou_history_mgr history_mgr, Xoh_href_parser href_parser, Xoctg_catpage_itm itm, Xoa_ttl ttl) {
public void Bld_html(Bry_bfr bfr, Xow_wiki wiki, Xou_history_mgr history_mgr, Xoh_href_parser href_parser, Xoctg_catpage_itm itm, Xoa_ttl ttl) {
byte[] itm_full_ttl = Gfh_utl.Escape_html_as_bry(tmp_bfr, ttl.Full_txt());// NOTE: ttl.Full_txt() to get full ns; EX: Template:A instead of just "A"
byte[] itm_href = wiki.Html__href_wtr().Build_to_bry(wiki, ttl);
byte[] itm_atr_cls = Xoh_lnki_wtr.Lnki_cls_visited(history_mgr, wiki.Domain_bry(), ttl.Page_txt()); // NOTE: must be ttl.Page_txt() in order to match Xou_history_mgr.Add

View File

@@ -1,30 +1,30 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.xowa.addons.wikis.ctgs.htmls.catpages.langs; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.wikis.*; import gplx.xowa.addons.wikis.ctgs.*; import gplx.xowa.addons.wikis.ctgs.htmls.*; import gplx.xowa.addons.wikis.ctgs.htmls.catpages.*;
import org.junit.*; import gplx.core.tests.*;
public class Xoctg_collation_wkr___tst {
private final Xoctg_collation_wkr___fxt fxt = new Xoctg_collation_wkr___fxt();
@Test public void Uppercase() {fxt.Test__make("uppercase" , "uppercase");}
@Test public void Identity() {fxt.Test__make("identity" , "identity");}
@Test public void Unknown() {fxt.Test__make("unknown" , "uppercase");}
@Test public void Uca__uca_default() {fxt.Test__make__uca("uca-default" , "en", false);}
@Test public void Uca__xx_uca_ckb() {fxt.Test__make__uca("xx-uca-ckb" , "fa", false);}
@Test public void Uca__xx_uca_et() {fxt.Test__make__uca("xx-uca-et" , "et", false);}
@Test public void Uca__uca_default_u_kn() {fxt.Test__make__uca("uca-default-u-kn" , "en", true);}
@Test public void Uca__uca_at_logic() {fxt.Test__make__uca("uca-sv@collation=standard" , "sv", false);}
@Test public void Uppercase() {fxt.Test__make("uppercase" , "uppercase");}
@Test public void Identity() {fxt.Test__make("identity" , "identity");}
@Test public void Unknown() {fxt.Test__make("unknown" , "uppercase");}
@Test public void Uca__uca_default() {fxt.Test__make__uca("uca-default" , "en", false);}
@Test public void Uca__xx_uca_ckb() {fxt.Test__make__uca("xx-uca-ckb" , "fa", false);}
@Test public void Uca__xx_uca_et() {fxt.Test__make__uca("xx-uca-et" , "et", false);}
@Test public void Uca__uca_default_u_kn() {fxt.Test__make__uca("uca-default-u-kn" , "en", true);}
@Test public void Uca__uca_at_logic() {fxt.Test__make__uca("uca-sv@collation=standard" , "sv", false);}
}
class Xoctg_collation_wkr___fxt {
public void Test__make(String wm_name, String expd_type) {

View File

@@ -1,31 +1,31 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.xowa.addons.wikis.ctgs.htmls.catpages.urls; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.wikis.*; import gplx.xowa.addons.wikis.ctgs.*; import gplx.xowa.addons.wikis.ctgs.htmls.*; import gplx.xowa.addons.wikis.ctgs.htmls.catpages.*;
import org.junit.*; import gplx.core.tests.*; import gplx.xowa.apps.urls.*;
public class Xoctg_catpage_url__tst {
@Before public void init() {fxt.Clear();} private Xoctg_catpage_url__fxt fxt = new Xoctg_catpage_url__fxt();
@Test public void Specific() {
@Test public void Specific() {
fxt.Exec__parse("A?subcatfrom=B&filefrom=C&pagefrom=D" ).Test__keys("B", "C", "D").Test__fwds(Bool_.Y, Bool_.Y, Bool_.Y);
fxt.Exec__parse("A?subcatuntil=B&fileuntil=C&pageuntil=D" ).Test__keys("B", "C", "D").Test__fwds(Bool_.N, Bool_.N, Bool_.N);
}
@Test public void General() {
@Test public void General() {
fxt.Exec__parse("A?from=B" ).Test__keys("B", "B", "B").Test__fwds(Bool_.Y, Bool_.Y, Bool_.Y);
fxt.Exec__parse("A?until=B" ).Test__keys("B", "B", "B").Test__fwds(Bool_.N, Bool_.N, Bool_.N);
}
@Test public void Url_encoded() {
@Test public void Url_encoded() {
fxt.Exec__parse("A?from=B+C").Test__keys("B C", "B C", "B C").Test__fwds(Bool_.Y, Bool_.Y, Bool_.Y);
}
}

View File

@@ -1,24 +1,24 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.xowa.addons.wikis.ctgs.htmls.pageboxs.doubles; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.wikis.*; import gplx.xowa.addons.wikis.ctgs.*; import gplx.xowa.addons.wikis.ctgs.htmls.*; import gplx.xowa.addons.wikis.ctgs.htmls.pageboxs.*;
import org.junit.*;
import gplx.xowa.wikis.data.tbls.*;
public class Xoctg_double_box__tst {
@Before public void init() {fxt.Clear();} private Xoctg_double_box__fxt fxt = new Xoctg_double_box__fxt();
@Test public void Single() {
@Test public void Single() {
fxt.Init_ctg_hidden("Category:A");
fxt.Init_ctg_normal("Category:D");
fxt.Test_print_hidden(String_.Concat_lines_nl
@@ -41,7 +41,7 @@ public class Xoctg_double_box__tst {
, "</div>"
));
}
@Test public void Plural() {
@Test public void Plural() {
fxt.Init_ctg_hidden("Category:A", "Category:B", "Category:C");
fxt.Init_ctg_normal("Category:D", "Category:E", "Category:F");
fxt.Test_print_hidden(String_.Concat_lines_nl

View File

@@ -1,24 +1,24 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.xowa.addons.wikis.ctgs.htmls.pageboxs.singles; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.wikis.*; import gplx.xowa.addons.wikis.ctgs.*; import gplx.xowa.addons.wikis.ctgs.htmls.*; import gplx.xowa.addons.wikis.ctgs.htmls.pageboxs.*;
import org.junit.*;
import gplx.xowa.htmls.core.htmls.*;
public class Xoctg_single_box__tst {
@Before public void init() {fxt.Clear();} private final Xoh_ctg_mgr_fxt fxt = new Xoh_ctg_mgr_fxt();
@Test public void Basic() {
@Test public void Basic() {
fxt.Init__ctgs("Category:A", "Category:B").Test_html(String_.Concat_lines_nl
( "<div id=\"catlinks\" class=\"catlinks\">"
, "<div id=\"mw-normal-catlinks\" class=\"mw-normal-catlinks\">"

View File

@@ -1,18 +1,18 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.xowa.addons.wikis.directorys.dbs; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.wikis.*; import gplx.xowa.addons.wikis.directorys.*;
import org.junit.*; import gplx.core.tests.*;
import gplx.langs.jsons.*;
@@ -20,27 +20,27 @@ import gplx.xowa.wikis.data.*;
public class Xowdir_wiki_props_mgr__tst {
private final Xowdir_wiki_props_mgr__fxt fxt = new Xowdir_wiki_props_mgr__fxt();
@Test public void Import__wiki__missing_all() {
@Test public void Import__wiki__missing_all() {
// handle all imported .xowa wikis pre v4.3
fxt.Init__wiki_props(null, null, null);
fxt.Test__verify(Bool_.Y, "/dir/test.xowa", Bool_.Y, fxt.Make__json("test", "test", "Main_Page"));
}
@Test public void Import__wiki__missing_domain() {
@Test public void Import__wiki__missing_domain() {
// handle personal wikis from v4.2
fxt.Init__wiki_props(null, null, "Main_Page");
fxt.Test__verify(Bool_.Y, "/dir/test.xowa", Bool_.Y, fxt.Make__json("test", "test", "Main_Page"));
}
@Test public void Import__wiki__wmf_domain() {
@Test public void Import__wiki__wmf_domain() {
// handle wmf wikis with a core-file of "test-core.xowa"
fxt.Init__wiki_props(null, null, "Main_Page");
fxt.Test__verify(Bool_.Y, "/dir/test-core.xowa", Bool_.Y, fxt.Make__json("test", "test", "Main_Page"));
}
@Test public void Import__wiki__clean() {
@Test public void Import__wiki__clean() {
// handle clean wiki
fxt.Init__wiki_props("test", "test", "Main_Page");
fxt.Test__verify(Bool_.Y, "/dir/test.xowa", Bool_.N, fxt.Make__json("test", "test", "Main_Page"));
}
@Test public void Open__wiki__missing_name() {
@Test public void Open__wiki__missing_name() {
// handle missing name
fxt.Init__user_json("test", "my test", "Main_Page");
fxt.Init__wiki_props(null, null, "Main_Page");

View File

@@ -1,23 +1,23 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.xowa.addons.wikis.fulltexts.core; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.wikis.*; import gplx.xowa.addons.wikis.fulltexts.*;
import org.junit.*; import gplx.core.tests.*;
public class Xofulltext_extractor__tst {
private final Xofulltext_extractor__fxt fxt = new Xofulltext_extractor__fxt();
@Test public void Basic() {
@Test public void Basic() {
// simple node
fxt.Test__extract("a <i>b</i> c", "a b c");

Some files were not shown because too many files have changed in this diff Show More