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,94 +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.domains; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
import org.junit.*; import gplx.xowa.langs.*;
public class Xow_abrv_wm_tst {
private Xow_abrv_wm_fxt fxt = new Xow_abrv_wm_fxt();
@Test public void Parse() {
fxt.Test_parse("foundationwiki" , Xol_lang_stub_.Id__intl , Xow_domain_tid_.Tid__wmfblog);
fxt.Test_parse("wikidatawiki" , Xol_lang_stub_.Id__intl , Xow_domain_tid_.Tid__wikidata);
fxt.Test_parse("mediawikiwiki" , Xol_lang_stub_.Id__intl , Xow_domain_tid_.Tid__mediawiki);
fxt.Test_parse("commonswiki" , Xol_lang_stub_.Id__intl , Xow_domain_tid_.Tid__commons);
fxt.Test_parse("specieswiki" , Xol_lang_stub_.Id__intl , Xow_domain_tid_.Tid__species);
fxt.Test_parse("metawiki" , Xol_lang_stub_.Id__intl , Xow_domain_tid_.Tid__meta);
fxt.Test_parse("incubatorwiki" , Xol_lang_stub_.Id__intl , Xow_domain_tid_.Tid__incubator);
fxt.Test_parse("enwiki" , Xol_lang_stub_.Id_en , Xow_domain_tid_.Tid__wikipedia);
fxt.Test_parse("enwiktionary" , Xol_lang_stub_.Id_en , Xow_domain_tid_.Tid__wiktionary);
fxt.Test_parse("enwikisource" , Xol_lang_stub_.Id_en , Xow_domain_tid_.Tid__wikisource);
fxt.Test_parse("enwikibooks" , Xol_lang_stub_.Id_en , Xow_domain_tid_.Tid__wikibooks);
fxt.Test_parse("enwikiversity" , Xol_lang_stub_.Id_en , Xow_domain_tid_.Tid__wikiversity);
fxt.Test_parse("enwikiquote" , Xol_lang_stub_.Id_en , Xow_domain_tid_.Tid__wikiquote);
fxt.Test_parse("enwikinews" , Xol_lang_stub_.Id_en , Xow_domain_tid_.Tid__wikinews);
fxt.Test_parse("enwikivoyage" , Xol_lang_stub_.Id_en , Xow_domain_tid_.Tid__wikivoyage);
fxt.Test_parse("frwiki" , Xol_lang_stub_.Id_fr , Xow_domain_tid_.Tid__wikipedia);
fxt.Test_parse_null("unknown");
fxt.Test_parse("plwikimedia" , Xol_lang_stub_.Id_pl , Xow_domain_tid_.Tid__wikimedia);
}
@Test public void Parse_override() {
fxt.Test_parse("arwikimedia" , Xol_lang_stub_.Id_es , Xow_domain_tid_.Tid__wikimedia);
fxt.Test_parse("ukwikimedia" , Xol_lang_stub_.Id_uk , Xow_domain_tid_.Tid__wikimedia);
}
@Test public void To_domain_itm() {
fxt.Test_to_domain_itm("enwiki" , "en" , "en.wikipedia.org");
fxt.Test_to_domain_itm("zh_yuewiki" , "zh-yue" , "zh-yue.wikipedia.org");
}
@Test public void To_domain_bry() {
fxt.Test_to_domain_bry("enwiki" , "en.wikipedia.org");
fxt.Test_to_domain_bry("zh_yuewiki" , "zh-yue.wikipedia.org");
fxt.Test_to_domain_bry("arwikimedia", "ar.wikimedia.org");
fxt.Test_to_domain_bry("ukwikimedia", "ua.wikimedia.org");
}
@Test public void To_abrv() {
fxt.Test_to_abrv("simple.wikipedia.org" , "simplewiki");
fxt.Test_to_abrv("en.wikipedia.org" , "enwiki");
fxt.Test_to_abrv("commons.wikimedia.org" , "commonswiki");
}
@Test public void To_abrv_by_lang() {
fxt.Test_to_abrv_by_lang("en", Xow_domain_tid_.Tid__wikipedia, "enwiki");
}
}
class Xow_abrv_wm_fxt {
public void Test_parse(String raw, int expd_lang_id, int expd_domain_tid) {
byte[] raw_bry = Bry_.new_a7(raw);
Xow_abrv_wm abrv = Xow_abrv_wm_.Parse_to_abrv_or_null(raw_bry);
Xol_lang_stub actl_lang_itm = abrv.Lang_actl();
Tfds.Eq(expd_lang_id , actl_lang_itm == null ? Xol_lang_stub_.Id__unknown : actl_lang_itm.Id());
Tfds.Eq(expd_domain_tid , abrv.Domain_type());
}
public void Test_parse_null(String raw) {
byte[] raw_bry = Bry_.new_a7(raw);
Xow_abrv_wm abrv = Xow_abrv_wm_.Parse_to_abrv_or_null(raw_bry);
Tfds.Eq_true(abrv == null);
}
public void Test_to_abrv(String domain_str, String expd) {
Xow_domain_itm domain = Xow_domain_itm_.parse(Bry_.new_a7(domain_str));
byte[] actl = Xow_abrv_wm_.To_abrv(domain);
Tfds.Eq(expd, String_.new_a7(actl));
}
public void Test_to_abrv_by_lang(String lang_key, int wiki_tid, String expd) {
Bry_bfr tmp_bfr = Bry_bfr_.Reset(255);
Xow_abrv_wm_.To_abrv(tmp_bfr, Bry_.new_a7(lang_key), gplx.core.primitives.Int_obj_ref.New(wiki_tid));
Tfds.Eq_str(expd, tmp_bfr.To_str_and_clear(), "to_abrv");
}
public void Test_to_domain_bry(String wmf_key, String expd_domain) {
Tfds.Eq(expd_domain , String_.new_a7(Xow_abrv_wm_.Parse_to_domain_bry(Bry_.new_a7(wmf_key))));
}
public void Test_to_domain_itm(String wmf_key, String expd_lang_key, String expd_domain) {
Xow_domain_itm domain = Xow_abrv_wm_.Parse_to_domain_itm(Bry_.new_a7(wmf_key));
Tfds.Eq(expd_lang_key , String_.new_a7(domain.Lang_actl_key()));
Tfds.Eq(expd_domain , String_.new_a7(domain.Domain_bry()));
}
}

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.domains; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
import org.junit.*;
public class Xow_abrv_xo__tst {
@Before public void init() {fxt.Clear();} private final Xow_abrv_xo__fxt fxt = new Xow_abrv_xo__fxt();
@Test public void Basic() {
fxt.Test("en.wikipedia.org" , "en.w"); // multi.enwiki
fxt.Test("fr.wiktionary.org" , "fr.d"); // multi.frwiktionary
fxt.Test("commons.wikimedia.org" , "c"); // important.unique.commons
fxt.Test("species.wikimedia.org" , "species"); // important.unique.species
fxt.Test("www.wikidata.org" , "wd"); // important.unique.wikidata
fxt.Test("home" , "home"); // important.unique.xowa
fxt.Test("meta.wikimedia.org" , "meta"); // wikimedia.unique
fxt.Test("pl.wikimedia.org" , "pl.m"); // wikimedia.multi
fxt.Test("a.b.c" , "a.b.c"); // unkonwn
}
}
class Xow_abrv_xo__fxt {
public void Clear() {}
public void Test(String domain_str, String expd_abrv) {
Xow_domain_itm domain = Xow_domain_itm_.parse(Bry_.new_u8(domain_str));
byte[] actl_abrv = Xow_abrv_xo_.To_bry(domain.Domain_bry(), domain.Lang_actl_key(), domain.Domain_type());
Tfds.Eq(expd_abrv, String_.new_u8(actl_abrv), "To_bry");
domain = Xow_abrv_xo_.To_itm(actl_abrv);
Tfds.Eq(domain_str, domain.Domain_str(), "To_itm");
}
}

View File

@@ -1,53 +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.domains; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
import org.junit.*; import gplx.core.tests.*;
public class Xow_domain_itm_tst {
private final Xow_domain_fxt fxt = new Xow_domain_fxt();
@Test public void Parse_en_wikipedia() {fxt.Test_parse("en.wikipedia.org" , "en" , "en" , Xow_domain_tid_.Tid__wikipedia);}
@Test public void Parse_fr_wikipedia() {fxt.Test_parse("fr.wikipedia.org" , "fr" , "fr" , Xow_domain_tid_.Tid__wikipedia);}
@Test public void Parse_en_wiktionary() {fxt.Test_parse("en.wiktionary.org" , "en" , "en" , Xow_domain_tid_.Tid__wiktionary);}
@Test public void Parse_zh_classical_wikipedia() {fxt.Test_parse("zh-classical.wikipedia.org" , "zh-classical" , "lzh" , Xow_domain_tid_.Tid__wikipedia);}
@Test public void Parse_commons() {fxt.Test_parse("commons.wikimedia.org" , "" , "" , Xow_domain_tid_.Tid__commons);}
@Test public void Parse_species() {fxt.Test_parse("species.wikimedia.org" , "" , "" , Xow_domain_tid_.Tid__species);}
@Test public void Parse_ru_wikimedia_org() {fxt.Test_parse("ru.wikimedia.org" , "ru" , "ru" , Xow_domain_tid_.Tid__wikimedia);}
@Test public void Parse_home() {fxt.Test_parse("home" , "" , "" , Xow_domain_tid_.Tid__home);}
@Test public void Parse_other() {fxt.Test_parse("other.wiki" , "" , "" , Xow_domain_tid_.Tid__other);}
@Test public void Parse_ua_wikimedia_org() {fxt.Test_parse("ua.wikimedia.org" , "ua" , "uk" , Xow_domain_tid_.Tid__wikimedia);}
@Test public void Parse_ar_wikimedia_org() {fxt.Test_parse("ar.wikimedia.org" , "ar" , "es" , Xow_domain_tid_.Tid__wikimedia);}
@Test public void Parse_blank() {fxt.Test_parse("" , "" , "" , Xow_domain_tid_.Tid__other);}
@Test public void Match_lang() {
fxt.Test__match_lang_y("en", "en.wikipedia.org", "en.wiktionary.org", "simple.wikipedia.org", "species.wikimedia.org", "www.wikidata.org", "commons.wikimedia.org");
fxt.Test__match_lang_y("fr", "fr.wikipedia.org", "fr.wiktionary.org");
fxt.Test__match_lang_y("zh", "zh-classical.wikipedia.org");
}
}
class Xow_domain_fxt {
public void Test_parse(String domain, String expd_orig_lang, String expd_actl_lang, int expd_tid) {
Xow_domain_itm actl = Xow_domain_itm_.parse(Bry_.new_a7(domain));
Tfds.Eq_str(expd_orig_lang, String_.new_a7((actl.Lang_orig_key())));
Tfds.Eq_str(expd_actl_lang, String_.new_a7((actl.Lang_actl_key())));
Tfds.Eq_int(expd_tid, actl.Domain_type_id());
}
public void Test__match_lang_y(String lang_code, String... domains) {Test__match_lang(Bool_.Y, lang_code, domains);}
public void Test__match_lang(boolean expd, String lang_key_str, String[] domains) {
int len = domains.length;
for (int i = 0; i < len; ++i) {
Xow_domain_itm domain = Xow_domain_itm_.parse(Bry_.new_u8(domains[i]));
Gftest.Eq__bool(expd, Xow_domain_itm_.Match_lang(domain, lang_key_str), lang_key_str + "|" + domains[i]);
}
}
}

View File

@@ -1,35 +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.domains; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
import org.junit.*;
public class Xow_domain_uid__tst {
@Before public void init() {fxt.Clear();} private final Xow_domain_uid__fxt fxt = new Xow_domain_uid__fxt();
@Test public void Basic() {
fxt.Test(Xow_domain_uid_.Tid_commons , "commons.wikimedia.org" , "", Xow_domain_tid_.Tid__commons);
fxt.Test(100 , "en.wikipedia.org" , "en", Xow_domain_tid_.Tid__wikipedia);
}
}
class Xow_domain_uid__fxt {
public void Clear() {}
public void Test(int tid, String domain_str, String expd_lang, int expd_tid) {
byte[] domain_bry = Bry_.new_a7(domain_str);
Xow_domain_itm actl_domain = Xow_domain_uid_.To_domain(tid);
Tfds.Eq_bry(domain_bry , actl_domain.Domain_bry());
Tfds.Eq_bry(Bry_.new_a7(expd_lang) , actl_domain.Lang_actl_key());
Tfds.Eq(expd_tid , actl_domain.Domain_type_id());
Tfds.Eq(tid, Xow_domain_uid_.To_int(actl_domain));
}
}