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

App: Release v4.5.15.1709

This commit is contained in:
gnosygnu
2017-09-17 22:38:44 -04:00
parent 131c2f696c
commit 4ca98f7333
896 changed files with 0 additions and 69373 deletions

View File

@@ -1,72 +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.dbs.metas.parsers; import gplx.*; import gplx.dbs.*; import gplx.dbs.metas.*;
import org.junit.*;
public class Dbmeta_parser__fld_tst {
@Before public void init() {fxt.Clear();} private Dbmeta_parser__fld_fxt fxt = new Dbmeta_parser__fld_fxt();
@Test public void Parse_type() {
fxt.Test_parse_type("int" , fxt.Make_type(Dbmeta_fld_tid.Tid__int));
fxt.Test_parse_type("varchar(255)" , fxt.Make_type(Dbmeta_fld_tid.Tid__str, 255));
fxt.Test_parse_type("decimal(12,10)" , fxt.Make_type(Dbmeta_fld_tid.Tid__decimal, 12, 10));
fxt.Test_parse_type(" int" , fxt.Make_type(Dbmeta_fld_tid.Tid__int));
fxt.Test_parse_type(" decimal ( 12 , 10 )" , fxt.Make_type(Dbmeta_fld_tid.Tid__decimal, 12, 10));
}
@Test public void Parse_fld() {
fxt.Test_parse_fld("name_1 int" , fxt.Make_fld("name_1", Dbmeta_fld_tid.Tid__int, Dbmeta_fld_itm.Nullable_unknown));
fxt.Test_parse_fld("name_1 int null" , fxt.Make_fld("name_1", Dbmeta_fld_tid.Tid__int, Dbmeta_fld_itm.Nullable_null));
fxt.Test_parse_fld("name_1 int not null" , fxt.Make_fld("name_1", Dbmeta_fld_tid.Tid__int, Dbmeta_fld_itm.Nullable_not_null));
fxt.Test_parse_fld("name_1 int not null autoincrement" , fxt.Make_fld("name_1", Dbmeta_fld_tid.Tid__int, Dbmeta_fld_itm.Nullable_not_null, Bool_.N, Bool_.Y));
fxt.Test_parse_fld("name_1 int not null primary key" , fxt.Make_fld("name_1", Dbmeta_fld_tid.Tid__int, Dbmeta_fld_itm.Nullable_not_null, Bool_.Y, Bool_.N));
fxt.Test_parse_fld("name_1 int not null default -1" , fxt.Make_fld("name_1", Dbmeta_fld_tid.Tid__int, Dbmeta_fld_itm.Nullable_not_null, Bool_.Y, Bool_.N, -1));
fxt.Test_parse_fld("name_1 varchar(3) not null default 'abc'" , fxt.Make_fld("name_1", Dbmeta_fld_tid.Tid__str, Dbmeta_fld_itm.Nullable_not_null, Bool_.Y, Bool_.N, "abc"));
}
@Test public void Comment() {
fxt.Test_parse_fld("name_1 int --a\n" , fxt.Make_fld("name_1", Dbmeta_fld_tid.Tid__int, Dbmeta_fld_itm.Nullable_unknown));
}
}
class Dbmeta_parser__fld_fxt {
private final Dbmeta_parser__fld fld_parser = new Dbmeta_parser__fld();
private final Sql_bry_rdr rdr = new Sql_bry_rdr();
public void Clear() {}
public Dbmeta_fld_tid Make_type(int tid_ansi) {return new Dbmeta_fld_tid(tid_ansi, -1, null, Int_.Min_value, Int_.Min_value);}
public Dbmeta_fld_tid Make_type(int tid_ansi, int len_1) {return new Dbmeta_fld_tid(tid_ansi, -1, null, len_1, Int_.Min_value);}
public Dbmeta_fld_tid Make_type(int tid_ansi, int len_1, int len_2) {return new Dbmeta_fld_tid(tid_ansi, -1, null, len_1, len_2);}
public Dbmeta_fld_itm Make_fld(String name, int tid_ansi, int nullable) {return Make_fld(name, tid_ansi, nullable, false, false, null);}
public Dbmeta_fld_itm Make_fld(String name, int tid_ansi, int nullable, boolean autonumber, boolean primary_key) {return Make_fld(name, tid_ansi, nullable, false, false, null);}
public Dbmeta_fld_itm Make_fld(String name, int tid_ansi, int nullable, boolean autonumber, boolean primary_key, Object default_val) {
Dbmeta_fld_itm rv = new Dbmeta_fld_itm(name, Make_type(tid_ansi));
rv.Nullable_tid_(nullable);
if (autonumber) rv.Autonum_y_();
if (primary_key) rv.Primary_y_();
rv.Default_(default_val);
return rv;
}
public void Test_parse_type(String src, Dbmeta_fld_tid expd_type) {
rdr.Init_by_src(Bry_.new_u8(src));
Dbmeta_fld_tid actl_type = fld_parser.Parse_type(rdr);
Tfds.Eq(expd_type.Tid_ansi() , actl_type.Tid_ansi());
Tfds.Eq(expd_type.Len_1() , actl_type.Len_1());
Tfds.Eq(expd_type.Len_2() , actl_type.Len_2());
}
public void Test_parse_fld(String src, Dbmeta_fld_itm expd_fld) {
rdr.Init_by_src(Bry_.new_u8(src));
Dbmeta_fld_itm actl_fld = fld_parser.Parse_fld(rdr);
Tfds.Eq(expd_fld.Name() , actl_fld.Name());
Tfds.Eq(expd_fld.Type().Tid_ansi() , actl_fld.Type().Tid_ansi());
Tfds.Eq(expd_fld.Nullable_tid() , actl_fld.Nullable_tid());
Tfds.Eq(Object_.Xto_str_strict_or_empty(expd_fld.Default()), Object_.Xto_str_strict_or_empty(actl_fld.Default()));
}
}

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.dbs.metas.parsers; import gplx.*; import gplx.dbs.*; import gplx.dbs.metas.*;
import org.junit.*;
public class Dbmeta_parser__idx_tst {
@Before public void init() {fxt.Clear();} private final Dbmeta_parser__idx_fxt fxt = new Dbmeta_parser__idx_fxt();
@Test public void Unique() {fxt.Test_parse("CREATE UNIQUE INDEX idx_1 ON tbl_1 (fld_1, fld_2, fld_3)" , fxt.Make_idx(Bool_.Y, "idx_1", "tbl_1", "fld_1", "fld_2", "fld_3"));}
@Test public void Normal() {fxt.Test_parse("CREATE INDEX idx_1 ON tbl_1 (fld_1, fld_2, fld_3)" , fxt.Make_idx(Bool_.N, "idx_1", "tbl_1", "fld_1", "fld_2", "fld_3"));}
@Test public void Fld_1() {fxt.Test_parse("CREATE INDEX idx_1 ON tbl_1 (fld_1)" , fxt.Make_idx(Bool_.N, "idx_1", "tbl_1", "fld_1"));}
}
class Dbmeta_parser__idx_fxt {
private final Dbmeta_parser__idx parser = new Dbmeta_parser__idx();
public void Clear() {}
public Dbmeta_idx_itm Make_idx(boolean unique, String idx_name, String tbl_name, String... fld_names) {return new Dbmeta_idx_itm(unique, tbl_name, idx_name, Dbmeta_idx_itm.To_fld_ary(fld_names));}
public void Test_parse(String src, Dbmeta_idx_itm expd) {
Dbmeta_idx_itm actl = parser.Parse(Bry_.new_u8(src));
Tfds.Eq_bool(expd.Unique(), actl.Unique());
Tfds.Eq_str(expd.Name(), actl.Name());
Tfds.Eq_str(expd.Tbl(), actl.Tbl());
Tfds.Eq_bool(Bool_.Y, Dbmeta_idx_fld.Ary_eq(expd.Flds, actl.Flds));
}
}

View File

@@ -1,63 +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.dbs.metas.parsers; import gplx.*; import gplx.dbs.*; import gplx.dbs.metas.*;
import org.junit.*; import gplx.dbs.engines.sqlite.*;
public class Dbmeta_parser__tbl_tst {
@Before public void init() {fxt.Clear();} private Dbmeta_parser__tbl_fxt fxt = new Dbmeta_parser__tbl_fxt();
@Test public void Test_parse() {
fxt.Test_parse("CREATE TABLE tbl_1 (fld_1 int, fld_2 int)", fxt.Make_tbl("tbl_1", "fld_1", "fld_2"));
}
@Test public void Test_smoke() {
fxt.Test_parse(String_.Concat_lines_nl_skip_last
( "CREATE TABLE page"
, "( page_id integer NOT NULL PRIMARY KEY"
, ", page_namespace integer NOT NULL"
, ", page_title varchar(255) NOT NULL"
, ", page_is_redirect integer NOT NULL"
, ", page_touched varchar(14) NOT NULL"
, ", page_len integer NOT NULL"
, ", page_random_int integer NOT NULL"
, ", page_text_db_id integer NOT NULL"
, ", page_html_db_id integer NOT NULL DEFAULT -1"
, ", page_redirect_id integer NOT NULL DEFAULT -1"
, ");"
), fxt.Make_tbl("page", "page_id", "page_namespace", "page_title", "page_is_redirect", "page_touched", "page_len", "page_random_int", "page_text_db_id", "page_html_db_id", "page_redirect_id"));
}
}
class Dbmeta_parser__tbl_fxt {
private final Dbmeta_parser__tbl tbl_parser = new Dbmeta_parser__tbl();
public void Clear() {}
public Dbmeta_tbl_itm Make_tbl(String tbl_name, String... fld_names) {
int len = fld_names.length;
Dbmeta_fld_itm[] flds = new Dbmeta_fld_itm[len];
for (int i = 0; i < len; ++i)
flds[i] = new Dbmeta_fld_itm(fld_names[i], new Dbmeta_fld_tid(Dbmeta_fld_tid.Tid__int, Sqlite_tid.Tid_int, Bry_.new_a7("int"), Int_.Min_value, Int_.Min_value));
return Dbmeta_tbl_itm.New(tbl_name, flds);
}
public void Test_parse(String src, Dbmeta_tbl_itm expd_tbl) {
Dbmeta_tbl_itm actl_tbl = tbl_parser.Parse(Bry_.new_u8(src));
Tfds.Eq(expd_tbl.Name(), actl_tbl.Name());
Tfds.Eq_ary_str(To_str_ary(expd_tbl.Flds()), To_str_ary(actl_tbl.Flds()));
}
private static String[] To_str_ary(Dbmeta_fld_mgr fld_mgr) {
int len = fld_mgr.Len();
String[] rv = new String[len];
for (int i = 0; i < len; ++i) {
rv[i] = fld_mgr.Get_at(i).Name();
}
return rv;
}
}

View File

@@ -1,50 +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.dbs.metas.parsers; import gplx.*; import gplx.dbs.*; import gplx.dbs.metas.*;
import org.junit.*;
public class Sql_bry_rdr_tst {
@Before public void init() {fxt.Clear();} private Sql_bry_rdr_fxt fxt = new Sql_bry_rdr_fxt();
@Test public void Skip_ws() {
fxt.Test_skip_ws("a", 0); // char
fxt.Test_skip_ws("\ta", 1); // tab
fxt.Test_skip_ws("\na", 1); // \n
fxt.Test_skip_ws("\ra", 1); // \r
fxt.Test_skip_ws(" a", 1); // space
fxt.Test_skip_ws("\t\n\r a", 4); // multi
fxt.Test_skip_ws("", 0); // eos
}
@Test public void Read_sql_identifier() {
fxt.Test_read_sql_identifier("a", "a"); // one
fxt.Test_read_sql_identifier("abc_1", "abc_1"); // many
fxt.Test_read_sql_identifier("[abc_1]", "abc_1"); // bracket
fxt.Test_read_sql_identifier(" a ", "a"); // ws
fxt.Test_read_sql_identifier("", null); // eos
fxt.Test_read_sql_identifier("!@#", null); // sym
}
}
class Sql_bry_rdr_fxt {
private final Sql_bry_rdr rdr = new Sql_bry_rdr();
public void Clear() {}
public void Test_skip_ws(String src, int expd_pos) {
rdr.Init_by_src(Bry_.new_u8(src));
rdr.Skip_ws();
Tfds.Eq(expd_pos, rdr.Pos());
}
public void Test_read_sql_identifier(String src, String expd) {
rdr.Init_by_src(Bry_.new_u8(src));
Tfds.Eq(expd, String_.new_u8(rdr.Read_sql_identifier()));
}
}