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

Command-line: Fix curid argument not working 2

This commit is contained in:
gnosygnu
2017-02-22 08:44:14 -05:00
parent 0e85cc90ff
commit 5bd3371802
896 changed files with 1 additions and 69011 deletions

View File

@@ -1,31 +0,0 @@
/*
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.wikis.ttls; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
import org.junit.*;
public class Xoa_ttl__err_tst {
@Before public void init() {fxt.Clear();} private final Xoa_ttl_fxt fxt = new Xoa_ttl_fxt();
@Test public void Invalid__angle() {fxt.Parse("<!--a").Test__null();}
@Test public void Invalid__brace() {fxt.Parse("[[a]]").Test__null();}
@Test public void Invalid__curly() {fxt.Parse("{{a}}").Test__null();}
@Test public void Colon_is_last() {fxt.Parse("Help:").Test__null();}
@Test public void Len_max() {fxt.Parse(String_.Repeat("A", 512)).Test__page_txt(String_.Repeat("A", 512));}
@Test public void Len_0() {
fxt.Parse("").Test__null();
fxt.Parse(" ").Test__null();
fxt.Parse("_").Test__null();
fxt.Parse("_ _").Test__null();
}
}

View File

@@ -1,33 +0,0 @@
/*
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.wikis.ttls; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
import gplx.core.tests.*;
public class Xoa_ttl_fxt {
private Xowe_wiki wiki;
private String raw;
private Xoa_ttl ttl;
public void Clear() {
Xoae_app app = Xoa_app_fxt.Make__app__edit();
this.wiki = Xoa_app_fxt.Make__wiki__edit(app);
}
public Xoa_ttl_fxt Parse(String raw) {
this.raw = raw;
this.ttl = Xoa_ttl.Parse(wiki, Bry_.new_u8(raw));
return this;
}
public void Test__null() {Gftest.Eq__bool_y(ttl == null, "ttl is not null", "raw", raw);}
public void Test__page_txt(String expd) {Gftest.Eq__str(expd, String_.new_u8(ttl.Page_txt()), "page_txt", "raw", raw);}
}

View File

@@ -1,41 +0,0 @@
/*
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.wikis.ttls; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
import org.junit.*; import gplx.xowa.wikis.nss.*;
public class Xow_ttl__anchor_tst {
@Before public void init() {fxt.Reset();} private Xow_ttl_fxt fxt = new Xow_ttl_fxt();
@Test public void Page__main() {fxt.Init_ttl("a#b") .Expd_full_txt("A").Expd_page_txt("A").Expd_anch_txt("b").Test();}
@Test public void Page__ns() {fxt.Init_ttl("Help:A#B") .Expd_full_txt("Help:A").Expd_ns_id(Xow_ns_.Tid__help).Expd_page_txt("A").Expd_anch_txt("B").Test();}
@Test public void Pageless__main() {fxt.Init_ttl("#a") .Expd_full_txt("").Expd_page_txt("").Expd_anch_txt("a").Test();}
@Test public void Xwiki() { // PURPOSE: :#batch:Main Page causes ttl to fail b/c # is treated as anchor; DATE:2013-01-02
fxt.Wiki().Xwiki_mgr().Add_by_atrs(Bry_.new_a7("#batch"), Bry_.new_a7("none"));
fxt.Init_ttl(":#batch:Main Page").Expd_full_txt("Main Page").Test();
}
@Test public void Anch_has_angles() {// PURPOSE: angles in anchor should be encoded; DATE: 2013-01-23
fxt.Init_ttl("A#b<c>d").Expd_full_txt("A").Expd_anch_txt("b.3Cc.3Ed").Test();
}
@Test public void Anch_has_slash() { // PURPOSE: slash in anchor was being treated as a subpage; DATE:2014-01-14
fxt.Init_ttl("A#b/c").Expd_full_txt("A").Expd_anch_txt("b/c").Expd_leaf_txt("A").Test(); // NOTE: Leaf_txt should be Page_txt; used to fail
}
@Test public void Decode_ncr() { // PURPOSE: convert &#x23; to #; PAGE:en.s:The_English_Constitution_(1894) DATE:2014-09-07
fxt.Init_ttl("A&#x23;b").Expd_full_txt("A").Expd_page_txt("A").Expd_anch_txt("b").Test();
fxt.Init_ttl("A&#35;b").Expd_full_txt("A").Expd_page_txt("A").Expd_anch_txt("b").Test();
fxt.Init_ttl("A&#36;b").Expd_full_txt("A$b").Expd_page_txt("A$b").Expd_anch_txt("").Test();
}
@Test public void Multiple() {// PURPOSE: handle multiple anchors; en.w:Grand_Central_Terminal; DATE:2015-12-31
fxt.Init_ttl("A#b#c").Expd_page_txt("A").Expd_anch_txt("b#c").Test();
}
}

View File

@@ -1,59 +0,0 @@
/*
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.wikis.ttls; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
import org.junit.*; import gplx.xowa.wikis.nss.*;
public class Xow_ttl__basic_tst {
@Before public void init() {fxt.Reset();} private Xow_ttl_fxt fxt = new Xow_ttl_fxt();
@Test public void Ns() {fxt.Init_ttl("Help:Test") .Expd_ns_id(Xow_ns_.Tid__help).Expd_page_txt("Test").Test();}
@Test public void Ns_false() {fxt.Init_ttl("Helpx:Test") .Expd_ns_id(Xow_ns_.Tid__main).Expd_page_txt("Helpx:Test").Test();}
@Test public void Ns_multiple() {fxt.Init_ttl("Help:Talk:test") .Expd_page_txt("Talk:test").Test();}
@Test public void Full_txt() {fxt.Init_ttl("Help:a & b") .Expd_full_txt("Help:A & b").Test();} // preserve
@Test public void Full_url() {fxt.Init_ttl("Help:a & b") .Expd_full_url("Help:A_%26_b").Test();} // escape
@Test public void Page_txt() {fxt.Init_ttl("a & b") .Expd_page_txt("A & b").Test();} // preserve;
@Test public void Page_txt_underline() {fxt.Init_ttl("a_b") .Expd_page_txt("A b").Expd_page_url("A_b").Test();} // NOTE: raw is "a_b" but txt is "a b"
@Test public void Page_url() {fxt.Init_ttl("a & b") .Expd_page_url("A_%26_b").Test();} // escape
@Test public void Page_url_w_ns() {fxt.Init_ttl("Help:a & b") .Expd_page_url("A_%26_b").Test();} // remove ns
@Test public void Page_url_symbols() {fxt.Init_ttl(";:@&=$ -_.+!*'(),/").Expd_page_url(";:@%26%3D$_-_.%2B!*%27(),/").Test();}// symbols + space
@Test public void Leaf_txt() {fxt.Init_ttl("root/mid/leaf") .Expd_leaf_txt("leaf").Test();}
@Test public void Leaf_txt_slash_is_last() {fxt.Init_ttl("root/mid/leaf/") .Expd_leaf_txt("").Test();}
@Test public void Leaf_txt_no_slash() {fxt.Init_ttl("root") .Expd_leaf_txt("Root").Test();}
@Test public void Leaf_url() {fxt.Init_ttl("root/mid/a & b") .Expd_leaf_url("a_%26_b").Test();} // NOTE: a not capitalized ("root" would be)
@Test public void Base_txt() {fxt.Init_ttl("a & b/mid/leaf") .Expd_base_txt("A & b/mid").Test();}
@Test public void Base_url() {fxt.Init_ttl("a & b/mid/leaf") .Expd_base_url("A_%26_b/mid").Test();}
@Test public void Root_txt() {fxt.Init_ttl("root/mid/leaf") .Expd_root_txt("Root").Test();}
@Test public void Rest_txt() {fxt.Init_ttl("root/mid/leaf") .Expd_rest_txt("mid/leaf").Test();}
@Test public void Talk_txt() {fxt.Init_ttl("Help:test") .Expd_talk_txt("Help talk:Test").Test();}
@Test public void Talk_txt_identity() {fxt.Init_ttl("Help talk:test") .Expd_talk_txt("Help talk:Test").Test();}
@Test public void Talk_url() {fxt.Init_ttl("Help:a & b") .Expd_talk_url("Help_talk:A_%26_b").Test();}
@Test public void Talk_txt_main() {fxt.Init_ttl("test") .Expd_talk_txt("Talk:Test").Test();}
@Test public void Subj_txt() {fxt.Init_ttl("Help talk:test") .Expd_subj_txt("Help:Test").Test();}
@Test public void Subj_txt_identity() {fxt.Init_ttl("Help:test") .Expd_subj_txt("Help:Test").Test();}
@Test public void Subj_url() {fxt.Init_ttl("Help talk:a & b").Expd_subj_url("Help:A_%26_b").Test();}
@Test public void Subj_txt_main() {fxt.Init_ttl("Talk:test") .Expd_subj_txt("Test").Test();}
@Test public void Force_literal_link_y() {fxt.Init_ttl(":Help:test") .Expd_force_literal_link(1).Expd_page_txt("Test").Test();}
@Test public void Force_literal_link_n() {fxt.Init_ttl( "Help:test") .Expd_force_literal_link(0).Expd_page_txt("Test").Test();}
@Test public void Force_literal_link_y_2() {fxt.Init_ttl("::Help:test") .Expd_force_literal_link(1).Expd_page_txt("Test").Test();} // PURPOSE: 2nd initial colon should be ignored; EX:mw:MediaWiki; [[::MediaWiki]]; DATE:2013-12-14
@Test public void All_page() {fxt.Init_ttl("test") .Expd_xwik_txt("").Expd_ns_id(Xow_ns_.Tid__main).Expd_page_txt("Test").Expd_leaf_txt("Test").Expd_anch_txt("").Test();}
@Test public void All_ns() {fxt.Init_ttl("Help:test") .Expd_xwik_txt("").Expd_ns_id(Xow_ns_.Tid__help).Expd_page_txt("Test").Expd_leaf_txt("Test").Expd_anch_txt("").Test();}
@Test public void Special() {fxt.Init_ttl("Special:Random").Expd_ns_id(Xow_ns_.Tid__special).Expd_page_txt("Random").Test();}
@Test public void Special_xowa() {fxt.Init_ttl("Special:xowa/Search/Ttl").Expd_ns_id(Xow_ns_.Tid__special).Expd_page_txt("Xowa/Search/Ttl").Test();}
@Test public void Comment() {fxt.Init_ttl("Ab<!--b-->").Expd_page_txt("Ab").Test();}
@Test public void Comment_eos() {fxt.Init_ttl("Ab<!--b--").Expd_page_txt(null).Test();}
@Test public void Ns_case() {// PURPOSE: lowercase ns should be converted to proper case; EX: fr.w:Project:Sandbox (redirect link); en.w:Periclimenes imperator; [[commons:category:Periclimenes imperator|''Periclimenes imperator'']]; DATE: 2013-01-27
fxt.Init_ttl("help:A").Expd_full_txt("Help:A").Test();
fxt.Init_ttl("help talk:A").Expd_full_txt("Help talk:A").Test();
}
}

View File

@@ -1,27 +0,0 @@
/*
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.wikis.ttls; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
import org.junit.*; import gplx.xowa.wikis.nss.*;
public class Xow_ttl__html_entity_tst {
@Before public void init() {fxt.Reset();} private Xow_ttl_fxt fxt = new Xow_ttl_fxt();
@Test public void Eacute() {fxt.Init_ttl("&eacute;").Expd_page_txt("é").Test();} //É
@Test public void Amp_at_end() {fxt.Init_ttl("Bisc &").Expd_page_txt("Bisc &").Test();}
@Test public void Ncr_dec() {fxt.Init_ttl("A&#98;").Expd_page_txt("Ab").Test();}
@Test public void Ncr_hex() {fxt.Init_ttl("A&#x62;").Expd_page_txt("Ab").Test();}
// @Test public void Ncr_hex_ns() {fxt.Init_ttl("Help&#x3a;A").Expd_ns_id(Xow_ns_.Tid__help).Expd_page_txt("A").Test();}
@Test public void Nbsp() {fxt.Init_ttl("A&nbsp;b").Expd_page_txt("A b").Test();} // NOTE: &nbsp must convert to space; EX:w:United States [[Image:Dust Bowl&nbsp;- Dallas, South Dakota 1936.jpg|220px|alt=]]
@Test public void Amp() {fxt.Init_ttl("A&amp;b").Expd_page_txt("A&b").Test();} // PURPOSE: A&amp;B -> A&B; PAGE:en.w:Amadou Bagayoko?redirect=n; DATE:2014-09-23
}

View File

@@ -1,52 +0,0 @@
/*
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.wikis.ttls; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
import org.junit.*;
import gplx.xowa.langs.cases.*;
public class Xow_ttl__i18n_tst {
@Before public void init() {fxt.Reset();} private Xow_ttl_fxt fxt = new Xow_ttl_fxt();
@Test public void Bidi() { // PURPOSE: handle bidirectional characters; DATE:2015-07-28; DATE:2015-08-24
fxt.Init_ttl("A" + String_.new_u8(Bry_.New_by_ints(0xE2, 0x80, 0x8E)) + "B").Expd_page_txt("AB").Test();
fxt.Init_ttl("A" + String_.new_u8(Bry_.New_by_ints(0xE2, 0x80, 0x8F)) + "B").Expd_page_txt("AB").Test();
fxt.Init_ttl("A" + String_.new_u8(Bry_.New_by_ints(0xE2, 0x80, 0xAA)) + "B").Expd_page_txt("AB").Test();
fxt.Init_ttl("A" + String_.new_u8(Bry_.New_by_ints(0xE2, 0x80, 0xAB)) + "B").Expd_page_txt("AB").Test();
fxt.Init_ttl("A" + String_.new_u8(Bry_.New_by_ints(0xE2, 0x80, 0xAC)) + "B").Expd_page_txt("AB").Test();
fxt.Init_ttl("A" + String_.new_u8(Bry_.New_by_ints(0xE2, 0x80, 0xAD)) + "B").Expd_page_txt("AB").Test();
fxt.Init_ttl("A" + String_.new_u8(Bry_.New_by_ints(0xE2, 0x80, 0xAE)) + "B").Expd_page_txt("AB").Test();
}
@Test public void Multi_byte_char2() { // PURPOSE: multi-byte HTML entity causes array out of index error; EX: w:List_of_Unicode_characters; DATE:2013-12-25
fxt.Init_ttl("&#x2c65;").Expd_full_txt("").Test();
}
@Test public void First_char_is_multi_byte() { // PURPOSE: if multi-byte, uppercasing is complicated; EX: µ -> Μ; DATE:2013-11-27
fxt.Wiki().Lang().Case_mgr_u8_();
fxt.Init_ttl("µ").Expd_full_txt("Μ").Test(); // NOTE: this is not an ASCII "Μ"
fxt.Init_ttl("µab").Expd_full_txt("Μab").Test(); // check that rest of title works fine
fxt.Init_ttl("Help:µab").Expd_full_txt("Help:Μab").Test(); // check ns
fxt.Init_ttl("Ι").Expd_full_txt("Ι").Test(); // check that Ι is not upper-cased to COMBINING GREEK YPOGEGRAMMENI; DATE:2014-02-24
}
@Test public void First_char_is_multi_byte_assymetrical() { // PURPOSE: test multi-byte asymmetry (lc is 3 bytes; uc is 2 bytes)
fxt.Wiki().Lang().Case_mgr_u8_();
fxt.Init_ttl("").Expd_full_txt("Ⱥ").Test();
fxt.Init_ttl("ⱥab").Expd_full_txt("Ⱥab").Test(); // check that rest of title works fine
fxt.Init_ttl("Help:ⱥab").Expd_full_txt("Help:Ⱥab").Test(); // check ns
}
@Test public void Ws__basic() { // PURPOSE: replace other whitespace with underscore; PAGE:ja.w:Template:Location_map_USA New_York; DATE:2015-07-28
fxt.Init_ttl("A B").Expd_full_txt("A B").Test();
}
@Test public void Ws__many() { // PURPOSE: replace other whitespace with underscore; PAGE:ja.w:Template:Location_map_USA New_York; DATE:2015-07-28
fxt.Init_ttl("A\u00A0\u1680\u180E\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u2028\u2029\u202F\u205F\u3000B").Expd_full_txt("A B").Test();
}
}

View File

@@ -1,29 +0,0 @@
/*
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.wikis.ttls; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
import org.junit.*;
public class Xow_ttl__qarg_tst {
@Before public void init() {fxt.Reset();} private Xow_ttl_fxt fxt = new Xow_ttl_fxt();
@Test public void Base_txt_wo_qarg() {
fxt.Init_ttl("Special:Search/A?b=c").Expd_base_txt_wo_qarg("Search").Expd_qarg_txt("b=c").Test();
}
@Test public void Leaf_txt_wo_qarg() {
fxt.Init_ttl("Special:Search/A?b=c").Expd_leaf_txt_wo_qarg("A").Expd_qarg_txt("b=c").Test();
}
@Test public void Ttl_has_question_mark() { // PURPOSE: handle titles that have both question mark and leaf; PAGE:en.w:Portal:Organized_Labour/Did_You_Know?/1 DATE:2014-06-08
fxt.Init_ttl("A/B?/1").Expd_page_txt("A/B?/1").Expd_base_txt("A/B?").Expd_leaf_txt("1").Expd_leaf_txt_wo_qarg("1").Expd_qarg_txt(null).Test();
}
}

View File

@@ -1,27 +0,0 @@
/*
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.wikis.ttls; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
import org.junit.*;
public class Xow_ttl__ws_tst {
@Before public void init() {fxt.Reset();} private Xow_ttl_fxt fxt = new Xow_ttl_fxt();
@Test public void Space() {fxt.Init_ttl(" a b ") .Expd_page_url("A_b").Expd_page_txt("A b").Test();}
@Test public void Space_w_ns() {fxt.Init_ttl(" Help : a b ") .Expd_page_url("A_b").Expd_page_txt("A b").Test();}
@Test public void Nl() {fxt.Init_ttl("\n\na\n\n") .Expd_page_txt("A").Test();}
@Test public void Nl_end() {fxt.Init_ttl("a\nb") .Expd_page_txt("A b").Test();}
@Test public void Tab() {fxt.Init_ttl("\ta\t") .Expd_page_txt("A").Test();}
@Test public void Nbsp() {fxt.Init_ttl("A&nbsp;bc") .Expd_page_url("A_bc").Expd_page_txt("A bc").Test();} // PURPOSE:convert "&nbsp;" to " "; DATE:2014-09-25
@Test public void Nbsp_mix() {fxt.Init_ttl("A &nbsp; bc") .Expd_page_url("A_bc").Expd_page_txt("A bc").Test();} // PURPOSE:convert multiple "&nbsp;" to " "; PAGE:en.w:Greek_government-debt_crisis; DATE:2014-09-25
}

View File

@@ -1,40 +0,0 @@
/*
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.wikis.ttls; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
import org.junit.*; import gplx.xowa.wikis.nss.*;
public class Xow_ttl__xwik_tst {
@Before public void init() {fxt.Reset();} private Xow_ttl_fxt fxt = new Xow_ttl_fxt();
@Test public void Known() {fxt.Init_ttl("fr:a") .Expd_xwik_txt("fr").Expd_ns_id(Xow_ns_.Tid__main).Expd_page_txt("a").Test();}
@Test public void Known_ns() {fxt.Init_ttl("fr:Help:a") .Expd_xwik_txt("fr").Expd_ns_id(Xow_ns_.Tid__main).Expd_full_txt("Help:a").Expd_page_txt("Help:a").Test();} // NOTE: Page is "Help:a" b/c ns are unknowable in foreign wiki
@Test public void Unknown() {fxt.Init_ttl("frx:a") .Expd_xwik_txt("").Expd_ns_id(Xow_ns_.Tid__main).Expd_page_txt("Frx:a").Test();}
@Test public void Unknown_ns() {fxt.Init_ttl("frx:Help:a") .Expd_xwik_txt("").Expd_ns_id(Xow_ns_.Tid__main).Expd_page_txt("Frx:Help:a").Test();}
@Test public void Known_ns_leaf_anch() {fxt.Init_ttl("fr:Help:a/b/c#d").Expd_xwik_txt("fr").Expd_ns_id(Xow_ns_.Tid__main).Expd_page_txt("Help:a/b/c").Expd_leaf_txt("c").Expd_anch_txt("d").Expd_full_txt("Help:a/b/c").Test();}
@Test public void Colon_is_last() {
fxt.Init_ttl("fr:Help:").Expd_xwik_txt("fr").Expd_page_txt("Help:").Test();
fxt.Init_ttl("fr:_ _").Expd_xwik_txt("fr").Expd_page_txt("").Test(); // NOTE: fr:_ _ is invalid (resolves to "fr:");
fxt.Init_ttl("fr:Help:_ _").Expd_xwik_txt("fr").Expd_page_txt("Help:").Test();
}
@Test public void Colon_multiple() {
fxt.Init_ttl("fr::Help:Test").Expd_xwik_txt("fr").Expd_page_txt(":Help:Test").Test();
fxt.Init_ttl("fr::Test").Expd_xwik_txt("fr").Expd_page_txt(":Test").Test();
fxt.Init_ttl(":fr:Test").Expd_xwik_txt("fr").Expd_page_txt("Test").Expd_force_literal_link(1).Test();
fxt.Init_ttl(":::fr:Test").Expd_xwik_txt("").Expd_page_txt(":fr:Test").Expd_force_literal_link(1).Test();
}
@Test public void Ns_should_precede_xwiki() {// PURPOSE: the "Wikipedia" in "Wikipedia:Main page" should be interpreted as Srch_rslt_cbk, not an alias
fxt.Wiki().Xwiki_mgr().Add_by_atrs(Bry_.new_a7("Wikipedia"), Bry_.new_a7("en.wikipedia.org"));
fxt.Init_ttl("Wikipedia:Test").Expd_xwik_txt("").Expd_full_txt("Wikipedia:Test").Test();
}
}

View File

@@ -1,87 +0,0 @@
/*
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.wikis.ttls; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
import gplx.core.log_msgs.*;
class Xow_ttl_fxt {
private final Xop_fxt fxt = new Xop_fxt();
public Xow_ttl_fxt Init_ttl(String raw) {test_raw = raw; return this;} private String test_raw = "";
public Xow_ttl_fxt Expd_ns_id(int v) {expd_ns_id = v; return this;} private int expd_ns_id = Int_.Min_value;
public Xow_ttl_fxt Expd_page_txt(String v) {expd_page_txt = v; return this;} private String expd_page_txt;
public Xow_ttl_fxt Expd_page_url(String v) {expd_page_url = v; return this;} private String expd_page_url;
public Xow_ttl_fxt Expd_page_db (String v) {expd_page_db = v; return this;} private String expd_page_db;
public Xow_ttl_fxt Expd_full_txt(String v) {expd_full_txt = v; return this;} private String expd_full_txt;
public Xow_ttl_fxt Expd_full_url(String v) {expd_full_url = v; return this;} private String expd_full_url;
public Xow_ttl_fxt Expd_leaf_txt(String v) {expd_leaf_txt = v; return this;} private String expd_leaf_txt;
public Xow_ttl_fxt Expd_leaf_url(String v) {expd_leaf_url = v; return this;} private String expd_leaf_url;
public Xow_ttl_fxt Expd_base_txt(String v) {expd_base_txt = v; return this;} private String expd_base_txt;
public Xow_ttl_fxt Expd_base_url(String v) {expd_base_url = v; return this;} private String expd_base_url;
public Xow_ttl_fxt Expd_root_txt(String v) {expd_root_txt = v; return this;} private String expd_root_txt;
public Xow_ttl_fxt Expd_rest_txt(String v) {expd_rest_txt = v; return this;} private String expd_rest_txt;
public Xow_ttl_fxt Expd_talk_txt(String v) {expd_talk_txt = v; return this;} private String expd_talk_txt;
public Xow_ttl_fxt Expd_talk_url(String v) {expd_talk_url = v; return this;} private String expd_talk_url;
public Xow_ttl_fxt Expd_subj_txt(String v) {expd_subj_txt = v; return this;} private String expd_subj_txt;
public Xow_ttl_fxt Expd_subj_url(String v) {expd_subj_url = v; return this;} private String expd_subj_url;
public Xow_ttl_fxt Expd_qarg_txt(String v) {expd_qarg_txt = v; return this;} private String expd_qarg_txt;
public Xow_ttl_fxt Expd_xwik_txt(String v) {expd_xwik_txt = v; return this;} private String expd_xwik_txt;
public Xow_ttl_fxt Expd_anch_txt(String v) {expd_anch_txt = v; return this;} private String expd_anch_txt;
public Xow_ttl_fxt Expd_base_txt_wo_qarg(String v) {expd_base_txt_wo_qarg = v; return this;} private String expd_base_txt_wo_qarg;
public Xow_ttl_fxt Expd_leaf_txt_wo_qarg(String v) {expd_leaf_txt_wo_qarg = v; return this;} private String expd_leaf_txt_wo_qarg;
public Xow_ttl_fxt Expd_force_literal_link(int v) {expd_force_literal_link = v; return this;} private int expd_force_literal_link = -1;
public Xow_ttl_fxt Expd_err(Gfo_msg_itm v) {expd_err = v; return this;} private Gfo_msg_itm expd_err;
public Xowe_wiki Wiki() {return fxt.Wiki();}
public void Reset() {
fxt.Reset();
fxt.Wiki().Xwiki_mgr().Add_by_atrs(Bry_.new_a7("fr"), Bry_.new_a7("fr.wikipedia.org"));
test_raw = "Test page";
expd_ns_id = Int_.Min_value;
expd_xwik_txt = expd_full_txt = expd_full_url = expd_page_txt = expd_page_url = expd_leaf_txt = expd_leaf_url = expd_base_txt = expd_base_url
= expd_root_txt = expd_rest_txt = expd_talk_txt = expd_talk_url = expd_subj_txt = expd_subj_url = expd_anch_txt
= expd_base_txt_wo_qarg = expd_leaf_txt_wo_qarg = expd_qarg_txt = null;
expd_err = null;
expd_force_literal_link = -1;
fxt.Log_clear();
}
public void Test() {
Xoa_ttl actl = Xoa_ttl.Parse(fxt.Wiki(), Bry_.new_u8(test_raw));
if (expd_err == null) {
if (expd_ns_id != Int_.Min_value) Tfds.Eq(expd_ns_id, actl.Ns().Id(), "ns");
if (expd_xwik_txt != null) Tfds.Eq(expd_xwik_txt, String_.new_u8(actl.Wik_txt()), "Wiki");
if (expd_page_txt != null) Tfds.Eq(expd_page_txt, String_.new_u8(actl.Page_txt()), "Page_txt");
if (expd_page_url != null) Tfds.Eq(expd_page_url, String_.new_u8(actl.Page_url()), "Page_url");
if (expd_page_db != null) Tfds.Eq(expd_page_db , String_.new_u8(actl.Page_db()) , "Page_db");
if (expd_full_txt != null) Tfds.Eq(expd_full_txt, String_.new_u8(actl.Full_txt_w_ttl_case()), "Full_txt");
if (expd_full_url != null) Tfds.Eq(expd_full_url, String_.new_u8(actl.Full_url()), "Full_url");
if (expd_leaf_txt != null) Tfds.Eq(expd_leaf_txt, String_.new_u8(actl.Leaf_txt()), "Leaf_txt");
if (expd_leaf_url != null) Tfds.Eq(expd_leaf_url, String_.new_u8(actl.Leaf_url()), "Leaf_url");
if (expd_base_txt != null) Tfds.Eq(expd_base_txt, String_.new_u8(actl.Base_txt()), "Base_txt");
if (expd_base_url != null) Tfds.Eq(expd_base_url, String_.new_u8(actl.Base_url()), "Base_url");
if (expd_root_txt != null) Tfds.Eq(expd_root_txt, String_.new_u8(actl.Root_txt()), "Root_txt");
if (expd_rest_txt != null) Tfds.Eq(expd_rest_txt, String_.new_u8(actl.Rest_txt()), "Rest_txt");
if (expd_talk_txt != null) Tfds.Eq(expd_talk_txt, String_.new_u8(actl.Talk_txt()), "Talk_txt");
if (expd_talk_url != null) Tfds.Eq(expd_talk_url, String_.new_u8(actl.Talk_url()), "Talk_url");
if (expd_subj_txt != null) Tfds.Eq(expd_subj_txt, String_.new_u8(actl.Subj_txt()), "Subj_txt");
if (expd_subj_url != null) Tfds.Eq(expd_subj_url, String_.new_u8(actl.Subj_url()), "Subj_url");
if (expd_anch_txt != null) Tfds.Eq(expd_anch_txt, String_.new_u8(actl.Anch_txt()), "Anch_txt");
if (expd_qarg_txt != null) Tfds.Eq(expd_qarg_txt, String_.new_u8(actl.Qarg_txt()), "Qarg_txt");
if (expd_base_txt_wo_qarg != null) Tfds.Eq(expd_base_txt_wo_qarg, String_.new_u8(actl.Base_txt_wo_qarg()), "Expd_base_txt_wo_qarg");
if (expd_leaf_txt_wo_qarg != null) Tfds.Eq(expd_leaf_txt_wo_qarg, String_.new_u8(actl.Leaf_txt_wo_qarg()), "Expd_leaf_txt_wo_qarg");
if (expd_force_literal_link != -1) Tfds.Eq(expd_force_literal_link == 1, actl.ForceLiteralLink(), "ForceLiteralLink");
}
else {
Tfds.Eq_ary(String_.Ary(String_.new_u8(expd_err.Owner().Path()) + "." + String_.new_u8(expd_err.Key_bry())), fxt.Log_xtoAry());
}
}
}